Update a customer
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/customers/1';const options = { method: 'PATCH', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"name":"example","phone":"example","avatar_url":"example","status":"active","notes":"example","reason":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://apibase.ecomweb.app/api/v1/stores/example/customers/1 \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "name": "example", "phone": "example", "avatar_url": "example", "status": "active", "notes": "example", "reason": "example" }'Changes the fields you send; fields you leave out stay as they are. Setting status to inactive also blocks the customer’s sign-in. Each changed field is recorded on the customer’s timeline, with the optional reason. The email cannot be changed.
Required scopes: write:customers
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The customer ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Full name.
Phone number, or null to clear it.
Avatar image URL, or null to clear it.
Account status. Setting inactive blocks the customer from signing in.
Internal notes, or null to clear them.
Why the change was made. Recorded on the customer timeline.
Responses
Section titled “Responses”object
Account status set by the store. An inactive customer cannot sign in.
Ordering activity: active for a recent order, inactive for an old one, never_ordered for none. Separate from status.
Customer ID.
Email address. Empty for a customer created with a phone number only.
Full name.
Phone number, or null.
Avatar image URL, or null.
ID of the sign-in identity linked to the customer, or null for a customer who never signed in.
Internal notes about the customer, or null.
When the customer was created, as an ISO 8601 timestamp.
When the customer was last updated, as an ISO 8601 timestamp.
When the customer was deleted, or null while the customer is live.
Date of the first order, as an ISO 8601 timestamp. Absent when the customer has no orders.
Date of the latest order, as an ISO 8601 timestamp. Absent when the customer has no orders.
Days since the latest order. Absent when the customer has no orders.
Orders placed by the customer.
Cancelled orders.
Refunded orders.
Orders that count towards revenue: those neither cancelled nor refunded.
Total spent across revenue orders, in the store currency.
Average value of a revenue order, in the store currency.
Orders placed as a guest with the customer’s email and linked to them by it.
Example
{ "status": "active", "activity_state": "active"}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}