Create a customer

How to create a customer via API

To create a new customer, send a POST request to the /api/customers endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/customers

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.email

string

Required

attributes.password

string

Optional

attributes.shopper_reference

string

Required, auto generated if missing

attributes.profile_id

string

Required, auto generated if missing

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.customer_group

object

Optional

relationships.tags

array

Optional

Example

The following request creates a new customer:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/customers' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "customers",
    "attributes": {
      "email": "john@example.com",
      "shopper_reference": "xxx-yyy-zzz",
      "profile_id": "xxx-yyy-zzz"
    }
  }
}'

Last updated