Link Search Menu Expand Document

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 stringNombre.
lastname stringApellidos.
email stringCorreo electrónico.
password stringConstraseña.
confirm stringConfirmar contraseña.
telephone stringNúmero de teléfono.
fax stringNúmero de fax.
newsletter integerSucripción al Newsletter (1 subcribir; 0 no subcribir).
status integerEstado del cliente (1 activado; 0 desactivado).
approved integerSi ha sido aprobado el cliente o no (1 aprobado; 0 no aprobado).
safe integerPor defecto 0.
customer_group_idId del grupo dónde pertence el cliente. Por defecto 1.
custome_fieldCampos personalizados.
custome_field > 1 stringNIF/CIF.
addressDirección principal del cliente.
address > address_id integerPor defecto vacio.
address > firstname stringNombre.
address > lastname stringApellidos.
address > company stringNombre de la empresa.
address > address_1 stringPrimera línea de la dirección postal.
address > address_2 stringSegunda línea de la dirección postal.
address > city stringCiudad.
address > postcode stringCódigo postal.
address > country_id integerId del país.
address > zone_id integerId de la zona.
address > default integerSi es la dirección por defecto. Por defecto 1.

Cabeceras HTTP

X-Sushi-Token-IdToken de autorización.

Respuesta

{
    "success": 1,
    "error": [],
    "data": {
        "customer_id": 8
    }
}
success integer0 si hay error, 1 si no hay error.
error stringDescripción del error.
data json objectDatos de respuesta.
customer_id integerId 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;