Customer Login
Creates a one-time login code for an existing customer so they can be signed in to the storefront from your system (for example, a punch-out or single sign-on flow). You can also send cart items to fill the customer's cart.
HTTP Request
- URL:
/customer/login - Method:
POST - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_ORDERorREAD_WRITE_ORDER
Request Body
The request body is a JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
email | String | Yes | Email address of the customer. |
cart | Array | No | Items to put in the customer's cart. See Cart Item Object. |
Cart Item Object
| Field | Type | Required | Description |
|---|---|---|---|
sku | String | Yes | SKU of the product. |
quantity | Number | Yes | Quantity of the product. |
uom | String | No | Unit of measure, for example CS. |
cURL Example
curl --location '<BASE_URL>/customer/login' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"email": "maria.lopez@northwindsupply.com",
"cart": [
{ "sku": "MAR-2930", "uom": "CS", "quantity": 3 },
{ "sku": "GLV-1102", "quantity": 10 }
]
}'
Response
- 200 OK: The login code was created successfully.
- 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, or no customer matches the email (
Customer not exists).
Sample JSON Response
{
"success": true,
"code": "9f2c4e7a1b3d5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8"
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the login code was created. |
code | String | One-time login code for the customer. |
Notes
- To sign the customer in, send them to your storefront with the code in the
codequery parameter, for examplehttps://<store-domain>/?code=<code>. Add&next=/cartto choose the page they land on after signing in. - The code can be used once and expires after 24 hours.
- The customer cannot sign in if their account, role or company is inactive.
- When you send
cart, it replaces the customer's current cart. Prices follow the customer's company pricing when available. - Send the email in lowercase, as customer emails are stored in lowercase.