Skip to main content

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:

FieldTypeRequiredDescription
firstNameStringYesFirst name of the customer.
emailStringYesEmail address of the customer. Must be unique.
lastNameStringNoLast name of the customer.
phoneNumberStringNoPhone number of the customer.
companyStringNoID of the company the customer belongs to.
isB2BBooleanNoWhether 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.
roleNameStringNoName of the customer role, for example Admin, Buyer or Junior Buyer. Default is Admin. See Get All Customer Roles.
statusStringNoactive, pending, invited or inactive. Default is pending.
notesStringNoInternal notes about the customer.
imageStringNoURL of the customer's profile image.
addressArrayNoList of addresses. See Address Object.
metaFieldsArrayNoCustom field values. See MetaFields Object.
productGroupsObjectNoProduct groups the customer can or cannot see. See Product Groups Object.
paymentAccessObjectNoPayment methods the customer can use. See Payment Access Object.

Address Object​

FieldTypeRequiredDescription
address1StringYesStreet address.
cityStringYesCity.
stateStringYesState or province code, for example NJ.
countryStringYesTwo-letter country code, for example US.
zipcodeStringYesPostal code.
firstNameStringNoFirst name of the contact person.
lastNameStringNoLast name of the contact person.
address2StringNoAdditional address line.
phoneNumberStringNoPhone number for the address.
isDefaultAddressBooleanNoWhether this is the default address. Default is false.
statusBooleanNoWhether the address is active. Default is true.

MetaFields Object​

FieldTypeRequiredDescription
codeStringYesCode of an existing metafield.
valueMixedNoValue of the metafield (string, number, boolean or array).

Product Groups Object​

FieldTypeRequiredDescription
groupsArrayNoList of product groups. Each item has productGroup (ID of an existing product group) and type (include or exclude).
restrictStoreProductVisibilityBooleanNoShow the customer only the included product groups. Default is false.

Payment Access Object​

FieldTypeRequiredDescription
modeStringYesinherit to use the company or store settings, or selected to allow only the listed methods.
methodsArrayNoAllowed 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​

FieldTypeDescription
successBooleanWhether the request was successful.
messageStringResult message.
dataObjectThe new customer. The fields are the same as in Get All Customers.

Notes​

  • state and country codes are returned as objects with code and name.
  • Metafields sent with an empty value are skipped.
  • If roleName does not match a role, the API returns Customer Role not found.