Create a customer
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/customers';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"email":"example","name":"example","phone":"example","avatar_url":"example","user_id":"example","notes":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/stores/example/customers \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "email": "example", "name": "example", "phone": "example", "avatar_url": "example", "user_id": "example", "notes": "example" }'Creates a customer. At least one of email or phone is required. Customers are not de-duplicated: a second customer with the same email is created as a separate record, and merge joins duplicates afterwards. The creation is recorded on the customer’s timeline against the API key.
Required scopes: write:customers
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Omit for a phone-only customer
Full name.
Phone number. Optional when an email is given.
Avatar image URL.
ID of an existing sign-in identity to link to the customer.
Internal notes about the customer, not shown to the customer.
Example generated
{ "email": "example", "name": "example", "phone": "example", "avatar_url": "example", "user_id": "example", "notes": "example"}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"}