Skip to content

AuthCustomerByCode

Endpoint

POST /customer/auth/code

Description

Public endpoint; No bearer token is required. Exchanges the one-time code from a link created by MngCreateClientLoginLink or MngCreateLeadLoginLink for a customer session. The terminal calls it when it is opened with ?code= in the URL.

The code is single-use and valid for 60 seconds after the link is created. The first request with the code consumes it, whether the exchange succeeds or not.

Brand resolution follows CustomerResetPassword: server-provided __hostname, or explicit brand when hostname is absent or the negotiated license brand policy allows it. The resolved brand must match the brand the code was created for.

The returned session is a normal customer session (SESSION_CUSTOMER), so every customer endpoint and the WebSocket accept it. It differs from AuthCustomer in three ways:

  • the token carries impersonated_by with the manager id, and every journaled action in the session records impersonated_by in the journal detail;
  • the token expires 4 hours after the exchange. After that HTTP requests return 401 INCORRECT_TOKEN, WebSocket authorization returns INVALID_TOKEN, and an open WebSocket connection receives {"event":"session.update","data":{"action":"logout","reason":"SESSION_EXPIRED"}} on its next incoming message and is then closed;
  • the customer's last_login_time is not changed and OTP is not requested.

The response contains only the session. Load the profile and linked accounts with GetCustomerSelf.

Request

{
  "login_code": "3f9c1e0b7a6d5c4b3a291807f6e5d4c3b2a1908f7e6d5c4b3a2918070f6e5d4c"
}

Body Parameters

Field Type Required Description
login_code string Yes The code value from the link, exactly 64 characters

Response

{
  "customer_id": 1,
  "impersonated_by": 7,
  "__token": "..."
}

Response Parameters

Field Type Description
customer_id int Customer the session belongs to
impersonated_by int Id of the manager who created the link
__token string Customer session token; also returned in the Authorization response header

With runtime protocol v2, the endpoint returns HTTP 503 with error: "LICENSE_NOT_ACTIVE" if a lease is unavailable; the code is not consumed in that case.

Errors

HTTP Error Description
400 INVALID_DATA Invalid request body
400 CUSTOMER_LOGIN_CODE_INVALID_OR_EXPIRED Unknown, used or expired code; brand of the request does not match the code; unavailable or disabled brand; customer not found or moved to another brand
403 CUSTOMER_DISABLED Customer is disabled
403 BRAND_NOT_AVAILABLE Customer brand is not admitted by the negotiated license policy
503 LICENSE_NOT_ACTIVE A v2 license runtime lease is required before issuing a new session token