Skip to main content

Update Customer

Updates an existing customer. Only the fields you send are changed.

HTTP Request​

  • URL: /customers/{id}
  • Method: PUT
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_CUSTOMER

Path Parameters​

ParameterTypeDescription
idStringRequired. The ID of the customer to update.

Request Body​

The request body is a JSON object. All fields are optional, but at least one must be sent.

FieldTypeRequiredDescription
firstNameStringNoFirst name of the customer.
lastNameStringNoLast name of the customer.
emailStringNoEmail address of the customer. Must be unique.
phoneNumberStringNoPhone number of the customer.
companyStringNoID of the company the customer belongs to.
isB2BBooleanNoWhether the customer is a business (B2B) customer. Setting it to false removes the company.
roleNameStringNoName of the customer role, for example Buyer. See Get All Customer Roles.
statusStringNoactive, pending, invited or inactive.
notesStringNoInternal notes about the customer.
imageStringNoURL of the customer's profile image.
addressArrayNoReplaces all saved addresses. See Address Object.
metaFieldsArrayNoCustom field values. See MetaFields Object.
productGroupsObjectNoReplaces the product group settings. See Product Groups Object.
paymentAccessObjectNoReplaces the payment method settings. See Payment Access Object.

cURL Example​

curl --location --request PUT '<BASE_URL>/customers/66a5023524b16685e42a1eda' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"phoneNumber": "9735550199",
"roleName": "Admin",
"status": "active",
"metaFields": [
{ "code": "erp_contact_id", "value": 2048 }
]
}'

Response​

  • 200 OK: The request was processed. Check success: it is false with the message Customer not exists if no customer matches the ID.
  • 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, the request body is empty, or a field is invalid.

Sample JSON Response​

{
"success": true,
"message": "Customer updated successfully.",
"data": {
"id": "66a5023524b16685e42a1eda",
"firstName": "Maria",
"lastName": "Lopez",
"email": "maria.lopez@northwindsupply.com",
"phoneNumber": "9735550199",
"isB2B": true,
"status": "active",
"role": "663a0aff4587085935a4fb94",
"company": "665434c100e82884676936b9",
"verifiedEmail": true,
"newsletter": false,
"address": [],
"metaFields": [
{
"_id": "66a5023524b16685e42a1edc",
"metaFieldId": "6650c1a2b3c4d5e6f7a8b9c0",
"code": "erp_contact_id",
"label": "ERP Contact ID",
"valueType": "number",
"displayStorefront": false,
"value": 2048
}
],
"createdBy": {
"id": "66a0f138a8323b0b86b0f1dc",
"name": "ERP Connector",
"type": "api"
},
"createdAt": "2024-07-27T14:20:37.573Z",
"updatedAt": "2024-10-09T13:05:59.036Z"
}
}

Response Details​

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

Notes​

  • Metafields you send are added or updated by code. Metafields you leave out are kept.
  • Changing the customer's company removes their access to other companies' corporate accounts.