Skip to content

Create the signed-in shopper's customer record

POST
/storefront/stores/{storeRef}/customers/auth/upsert
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.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
email

Ignored. The customer is created with the signed-in identity’s email.

string

Example

john@example.com
name
required

Customer full name

string

Example

John Doe
phone

Customer phone number

string
nullable

Example

+1234567890
avatar_url

Customer avatar URL

string
nullable

Example

https://example.com/avatar.jpg
Media typeapplication/json
object
id
required

Customer ID.

number
email
required

Email address.

string
name
required

Full name.

string
phone

Phone number, or null.

string
nullable
avatar_url

Avatar image URL, or null.

string
nullable
created_at
required

When the customer was created, as an ISO 8601 timestamp.

string
updated_at
required

When the customer was last updated, as an ISO 8601 timestamp.

string

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.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

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.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}