Create Customer
Creates a new customer account with personal, contact, address and company details. The customer sets their own password later through the storefront.
HTTP Request
- URL:
/customers - Method:
POST - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_CUSTOMER
Request Body
The request body is a JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | First name of the customer. |
email | String | Yes | Email address of the customer. Must be unique. |
lastName | String | No | Last name of the customer. |
phoneNumber | String | No | Phone number of the customer. |
company | String | No | ID of the company the customer belongs to. |
isB2B | Boolean | No | Whether the customer is a business (B2B) customer. If not sent, it is true when company is sent and false otherwise. Setting it to false removes the company. |
roleName | String | No | Name of the customer role, for example Admin, Buyer or Junior Buyer. Default is Admin. See Get All Customer Roles. |
status | String | No | active, pending, invited or inactive. Default is pending. |
notes | String | No | Internal notes about the customer. |
image | String | No | URL of the customer's profile image. |
address | Array | No | List of addresses. See Address Object. |
metaFields | Array | No | Custom field values. See MetaFields Object. |
productGroups | Object | No | Product groups the customer can or cannot see. See Product Groups Object. |
paymentAccess | Object | No | Payment methods the customer can use. See Payment Access Object. |
Address Object
| Field | Type | Required | Description |
|---|---|---|---|
address1 | String | Yes | Street address. |
city | String | Yes | City. |
state | String | Yes | State or province code, for example NJ. |
country | String | Yes | Two-letter country code, for example US. |
zipcode | String | Yes | Postal code. |
firstName | String | No | First name of the contact person. |
lastName | String | No | Last name of the contact person. |
address2 | String | No | Additional address line. |
phoneNumber | String | No | Phone number for the address. |
isDefaultAddress | Boolean | No | Whether this is the default address. Default is false. |
status | Boolean | No | Whether the address is active. Default is true. |
MetaFields Object
| Field | Type | Required | Description |
|---|---|---|---|
code | String | Yes | Code of an existing metafield. |
value | Mixed | No | Value of the metafield (string, number, boolean or array). |
Product Groups Object
| Field | Type | Required | Description |
|---|---|---|---|
groups | Array | No | List of product groups. Each item has productGroup (ID of an existing product group) and type (include or exclude). |
restrictStoreProductVisibility | Boolean | No | Show the customer only the included product groups. Default is false. |
Payment Access Object
| Field | Type | Required | Description |
|---|---|---|---|
mode | String | Yes | inherit to use the company or store settings, or selected to allow only the listed methods. |
methods | Array | No | Allowed payment methods when mode is selected. Each item has method (payment method ID) and types (list of payment types, for example card). |
cURL Example
curl --location '<BASE_URL>/customers' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"firstName": "Maria",
"lastName": "Lopez",
"email": "maria.lopez@northwindsupply.com",
"phoneNumber": "9735550142",
"company": "665434c100e82884676936b9",
"roleName": "Buyer",
"status": "active",
"notes": "Primary purchasing contact",
"address": [
{
"firstName": "Maria",
"lastName": "Lopez",
"address1": "1200 Industrial Ave",
"address2": "Suite 4",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202",
"isDefaultAddress": true
}
],
"metaFields": [
{ "code": "erp_contact_id", "value": 1254 }
]
}'
Response
- 200 OK: The customer was created successfully.
- 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, a field is missing or invalid, or the email is already in use.
Sample JSON Response
{
"success": true,
"message": "Customer created successfully",
"data": {
"id": "66a5023524b16685e42a1eda",
"firstName": "Maria",
"lastName": "Lopez",
"email": "maria.lopez@northwindsupply.com",
"phoneNumber": "9735550142",
"notes": "Primary purchasing contact",
"isB2B": true,
"status": "active",
"role": "663a0aff4587085935a4fb95",
"company": "665434c100e82884676936b9",
"verifiedEmail": false,
"newsletter": false,
"address": [
{
"id": "66a5023524b16685e42a1edb",
"firstName": "Maria",
"lastName": "Lopez",
"address1": "1200 Industrial Ave",
"address2": "Suite 4",
"city": "Elizabeth",
"state": { "code": "NJ", "name": "New Jersey" },
"country": { "code": "US", "name": "United States" },
"zipcode": "07202",
"isDefaultAddress": true,
"status": true
}
],
"metaFields": [
{
"id": "66a5023524b16685e42a1edc",
"metaFieldId": "6650c1a2b3c4d5e6f7a8b9c0",
"code": "erp_contact_id",
"label": "ERP Contact ID",
"valueType": "number",
"displayStorefront": false,
"value": 1254
}
],
"salesReps": [],
"createdBy": {
"id": "66a0f138a8323b0b86b0f1dc",
"name": "ERP Connector",
"type": "api"
},
"createdAt": "2024-07-27T14:20:37.573Z",
"updatedAt": "2024-07-27T14:20:37.573Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request was successful. |
message | String | Result message. |
data | Object | The new customer. The fields are the same as in Get All Customers. |
Notes
stateandcountrycodes are returned as objects withcodeandname.- Metafields sent with an empty value are skipped.
- If
roleNamedoes not match a role, the API returnsCustomer Role not found.