Skip to navigation

Passwordless Customer Login

Your application can send shoppers a one-time link via email that signs them in to their storefront account.

Use cases for this include:

  • Reducing friction for customers, allowing them to proceed without needing to reset their passwords
  • Providing an alternate method for signing in customers versus using the Customer Login API

Sending the request

Send a POST request to {store_url}/login.php?action=passwordless_login, where {store_url} is the storefront URL of the channel the customer belongs to.

The request body must be a JSON object. The endpoint reads only the raw JSON body; it ignores form-encoded fields and query string parameters other than action. Include the following properties:

  • email: The customer’s email address. This is where they receive the one-time login link. The address must belong to an existing customer account on the channel you send the request to.
  • redirect_url: The page to send the customer to after they sign in. BigCommerce keeps only the path of this value and discards any scheme, domain, or query string. For example, https://example.com/cart.php?x=1 becomes /cart.php. If you omit this property, the customer is redirected to /account.php.
Example request
POST https://{store_url}/login.php?action=passwordless_login
Content-Type: application/json
{
"email": "jane_doe@example.com",
"redirect_url": "/checkout"
}

Requests from a page with an active storefront session

If the request carries a storefront session cookie, for example when you send it from a theme script or an embedded checkout, the storefront also validates a CSRF token. Send the value of the SF-CSRF-TOKEN cookie in the X-Sf-Csrf-Token header. A request with a session cookie and a wrong token is redirected to /login.php with a 302 status, and no email is sent. A browser fetch call follows that redirect and resolves with a 200 HTML page, which is easy to mistake for success. Server-to-server requests that send no cookies skip this check.

Response

A 200 response means BigCommerce accepted the request and queued an email. Delivery is asynchronous, so the response does not confirm that the email reached the customer’s inbox. The response body contains:

  • sent_email: The type of email that was queued.
    • sign_in: BigCommerce queued the one-time login link.
    • reset_password: The customer’s account requires a password reset on next login, so BigCommerce queued the password reset email instead of a sign-in link. No sign-in link is sent in this case.
  • expiry: For sign_in, the number of seconds the login link stays valid, normally 900. For reset_password, this value reflects the account’s login lockout timer rather than the reset email, and can be -2, -1, or null. Do not rely on it for the reset flow.
Example response
{
"expiry": 900,
"sent_email": "sign_in"
}

Status codes

StatusMeaningBody
200Email queued. Check sent_email to see which email was sent.{"expiry": 900, "sent_email": "sign_in"}
400The body is not valid JSON.{"error": "Please provide a payload in valid JSON format"}
400The email is not a valid address.{"error": "Please type in a valid email address, such as joe@example.com"}
400The redirect_url has no path, for example https://example.com. If both values are invalid, the two messages are joined.{"error": "Please provide a valid return URL"}
404No customer account with that email exists on this channel.Empty
429Rate limited. See Rate limits.{"error": "Too many requests made when trying to send password-less login, please try again later."}
503BigCommerce could not queue the email, or the Sign-in Link Request email is turned off under Marketing > Transactional Emails.{"error": "Email failed to send, please try again later."}

Rate limits

BigCommerce counts sign-in link requests per shopper session. Requests that send no session cookie share a single bucket, so run server-side tests with care.

Email text

The customer receives an email with the following default subject line:

{Store name} - Log in to your account

The body of the email contains the following:

Please click the link below to sign in to your account with {store name}.
You have requested a sign-in link. Please click here to sign in and continue.
Alternatively, paste the following link in your browser:
https://{store_url}/login.php?action=check_passwordless_login&token={token}&redirectUrl={redirect_url}
This login is for {Store name} if you did not request this link, please ignore this email. Your account is still secure.

The link is single-use and expires 15 minutes after it is issued. Store owners can customize the subject and body in the control panel; see the Sign in Link Request email template for the available template variables.

Troubleshooting

If the POST returns 200 but the customer reports no email, check the following in order:

  • The response says reset_password. The customer received a “Password change request” email, not a sign-in link, because their account has Force password reset on next login enabled. Clear that setting on the customer record, or let the customer complete the reset.
  • The store is a new trial. Stores less than three weeks old have a store-wide limit on outgoing emails. When the limit is reached, the sign-in link request still returns 200 but no email is queued.
  • The request never reached BigCommerce. A browser request from a page with a storefront session is redirected to the login page when its CSRF token is invalid, or missing on stores with strict validation. Inspect the network response: a successful request returns JSON, not HTML.
  • Wrong channel. The account must exist on the channel whose storefront URL you call. A customer created on one storefront channel returns 404 from another.
  • Deliverability. Ask the customer to check their spam folder, and confirm the store’s other transactional emails arrive.

Articles

Endpoints