Create the signed-in shopper's customer record
const url = 'https://apibase.ecomweb.app/api/v1/storefront/stores/example/customers/auth/upsert';const options = { method: 'POST', headers: { 'x-storefront-api-key': '<x-storefront-api-key>', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"email":"john@example.com","name":"John Doe","phone":"+1234567890","avatar_url":"https://example.com/avatar.jpg"}'};
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/storefront/stores/example/customers/auth/upsert \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'x-storefront-api-key: <x-storefront-api-key>' \ --data '{ "email": "john@example.com", "name": "John Doe", "phone": "+1234567890", "avatar_url": "https://example.com/avatar.jpg" }'Creates the customer record for the signed-in shopper in this store, or returns the one that already exists. It is created with the email of the signed-in identity; any email in the body is ignored. Anonymous sessions and identities without an email get a 403. Storefronts call this once after sign-in so the shopper has a customer record for orders and addresses.
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
Ignored. The customer is created with the signed-in identity’s email.
Example
john@example.comCustomer full name
Example
John DoeCustomer phone number
Example
+1234567890Customer avatar URL
Example
https://example.com/avatar.jpgResponses
Section titled “Responses”object
Customer ID.
Email address.
Full name.
Phone number, or null.
Avatar image URL, or null.
When the customer was created, as an ISO 8601 timestamp.
When the customer was last updated, as an ISO 8601 timestamp.
Example generated
{ "id": 1, "email": "example", "name": "example", "phone": "example", "avatar_url": "example", "created_at": "example", "updated_at": "example"}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 on a Storefront route that needs a secret key, 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"}