Skip to main content

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_ORDER or READ_WRITE_ORDER

Request Body​

The request body is a JSON object with the following fields:

FieldTypeRequiredDescription
emailStringYesEmail address of the customer.
cartArrayNoItems to put in the customer's cart. See Cart Item Object.

Cart Item Object​

FieldTypeRequiredDescription
skuStringYesSKU of the product.
quantityNumberYesQuantity of the product.
uomStringNoUnit 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​

FieldTypeDescription
successBooleanWhether the login code was created.
codeStringOne-time login code for the customer.

Notes​

  • To sign the customer in, send them to your storefront with the code in the code query parameter, for example https://<store-domain>/?code=<code>. Add &next=/cart to 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.