Añadir nuevo cliente
Añadir un nuevo cliente.
POST /api/rest_admin/customers
Parámetros
post
{
    "firstname": "Pere",
    "lastname": "Monjo",
    "email": "peremonjo2@example.com",
    "password": "password",
    "confirm": "password",
    "telephone": "935555555",
    "fax": "",
    "newsletter": "0",
    "status": "1",
    "approved": "1",
    "safe": "0",
    "customer_group_id": "1",
    "custom_field": {
        "1": "55555555T"
    },
    "address": [
        {
            "address_id": "",
            "firstname": "Pere",
            "lastname": "Monjo",
            "company": " My Company Name",
            "address_1": "Address 1",
            "address_2": "Address 2",
            "city": "Vilassar",
            "postcode": "12345",
            "country_id": "195",
            "zone_id": "2979",
            "default": "1"
        }
    ]
}
| firstname string | Nombre. | 
| lastname string | Apellidos. | 
| email string | Correo electrónico. | 
| password string | Constraseña. | 
| confirm string | Confirmar contraseña. | 
| telephone string | Número de teléfono. | 
| fax string | Número de fax. | 
| newsletter integer | Sucripción al Newsletter (1 subcribir; 0 no subcribir). | 
| status integer | Estado del cliente (1 activado; 0 desactivado). | 
| approved integer | Si ha sido aprobado el cliente o no (1 aprobado; 0 no aprobado). | 
| safe integer | Por defecto 0. | 
| customer_group_id | Id del grupo dónde pertence el cliente. Por defecto 1. | 
| custome_field | Campos personalizados. | 
| custome_field > 1 string | NIF/CIF. | 
| address | Dirección principal del cliente. | 
| address > address_id integer | Por defecto vacio. | 
| address > firstname string | Nombre. | 
| address > lastname string | Apellidos. | 
| address > company string | Nombre de la empresa. | 
| address > address_1 string | Primera línea de la dirección postal. | 
| address > address_2 string | Segunda línea de la dirección postal. | 
| address > city string | Ciudad. | 
| address > postcode string | Código postal. | 
| address > country_id integer | Id del país. | 
| address > zone_id integer | Id de la zona. | 
| address > default integer | Si es la dirección por defecto. Por defecto 1. | 
Cabeceras HTTP
| X-Sushi-Token-Id | Token de autorización. | 
Respuesta
{
    "success": 1,
    "error": [],
    "data": {
        "customer_id": 8
    }
}
| success integer | 0 si hay error, 1 si no hay error. | 
| error string | Descripción del error. | 
| data json object | Datos de respuesta. | 
| customer_id integer | Id del cliente. | 
Ejemplos
cURL
curl --location --request POST 'http://sushi.loc/api/rest_admin/customers' \
--header 'X-Sushi-Token-Id: lssvgdbtb1oigvvnp057q0n122' \
--header 'Content-Type: application/json' \
--data-raw '{
    "firstname": "Pere",
    "lastname": "Monjo",
    "email": "peremonjo4@example.com",
    "password": "password",
    "confirm": "password",
    "telephone": "935555555",
    "fax": "",
    "newsletter": "0",
    "status": "1",
    "approved": "1",
    "safe": "0",
    "customer_group_id": "1",
    "custom_field": {
        "1": "55555555T"
    },
    "address": [
        {
            "address_id": "",
            "firstname": "Pere",
            "lastname": "Monjo",
            "company": " My Company Name",
            "address_1": "Address 1",
            "address_2": "Address 2",
            "city": "Vilassar",
            "postcode": "12345",
            "country_id": "195",
            "zone_id": "2979",
            "default": "1"
        }
    ]
    }'
PHP - cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "http://sushi.loc/api/rest_admin/customers",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"firstname\": \"Pere\",\n    \"lastname\": \"Monjo\",\n    \"email\": \"peremonjo4@example.com\",\n    \"password\": \"password\",\n    \"confirm\": \"password\",\n    \"telephone\": \"935555555\",\n    \"fax\": \"\",\n    \"newsletter\": \"0\",\n    \"status\": \"1\",\n    \"approved\": \"1\",\n    \"safe\": \"0\",\n    \"customer_group_id\": \"1\",\n    \"custom_field\": {\n        \"1\": \"55555555T\"\n    },\n    \"address\": [\n        {\n            \"address_id\": \"\",\n            \"firstname\": \"Pere\",\n            \"lastname\": \"Monjo\",\n            \"company\": \" My Company Name\",\n            \"address_1\": \"Address 1\",\n            \"address_2\": \"Address 2\",\n            \"city\": \"Vilassar\",\n            \"postcode\": \"12345\",\n            \"country_id\": \"195\",\n            \"zone_id\": \"2979\",\n            \"default\": \"1\"\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
    "X-Sushi-Token-Id: lssvgdbtb1oigvvnp057q0n122",
    "Content-Type: application/json"
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;