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
| Parameter | Type | Description |
|---|---|---|
id | String | Required. 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.
| Field | Type | Required | Description |
|---|---|---|---|
firstName | String | No | First name of the customer. |
lastName | String | No | Last name of the customer. |
email | String | No | Email address of the customer. Must be unique. |
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. Setting it to false removes the company. |
roleName | String | No | Name of the customer role, for example Buyer. See Get All Customer Roles. |
status | String | No | active, pending, invited or inactive. |
notes | String | No | Internal notes about the customer. |
image | String | No | URL of the customer's profile image. |
address | Array | No | Replaces all saved addresses. See Address Object. |
metaFields | Array | No | Custom field values. See MetaFields Object. |
productGroups | Object | No | Replaces the product group settings. See Product Groups Object. |
paymentAccess | Object | No | Replaces 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 isfalsewith the messageCustomer not existsif 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
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the customer was updated. |
message | String | Result message. |
data | Object | The 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.