Skip to content

MngCreateLeadLoginLink

Creates a one-time link that opens the trading terminal signed in as one lead, without the lead's password. The manager opens the link in a browser, and the terminal exchanges the code from the link for a customer session through AuthCustomerByCode.

The command is available through the manager command API only; there is no REST path for it. The kind is fixed by the command name, so customer_kind is not accepted on input. The client counterpart is MngCreateClientLoginLink. See Clients and Leads Commands.

The link:

  • has the form https://<terminal_host>/<language>/platform?code=<code>, where terminal_host is taken from the lead's brand and language is the lead's preferred_language, then the brand default_language, then en;
  • contains a 64-character code that is valid for expires_in seconds (60);
  • can be used once. The first exchange attempt consumes the code, whether it succeeds or not;
  • is a secret. The server keeps only a hash of the code, and the login_url value is masked in the journal.

The session created from the link is a full customer session: everything the lead can do in the terminal is available. It differs from a normal sign-in in three ways:

  • it carries impersonated_by with the manager id, and every journaled action in it records impersonated_by in the journal detail;
  • it expires 4 hours after the exchange. An open WebSocket connection receives session.update with action: logout and is closed;
  • it does not change the lead's last_login_time.

The lead is not notified.

Access Control

Allowed sessions:

  • SESSION_MANAGER
  • SESSION_ADMIN
  • SESSION_DEALER
  • SESSION_CRM_MANAGER
  • SESSION_CRM_ADMIN

The caller must have CRM access and login_as_leads. The record brand and desk must be inside the manager scope; admin scope bypasses this check. Every call is journaled.

The lead must be enabled, have at least one trading account, and belong to an active, enabled brand that is available for the API and has a terminal_host.

Request

{
  "command": "MngCreateLeadLoginLink",
  "extID": "1",
  "data": {
    "customer_id": 1
  }
}

Request Data

Field Type Required Description
customer_id int Yes Target customer id, 1 or greater

Response Data

{
  "customer_id": 1,
  "login_url": "https://terminal.example.com/en/platform?code=3f9c1e0b7a6d5c4b3a291807f6e5d4c3b2a1908f7e6d5c4b3a2918070f6e5d4c",
  "expires_in": 60
}
Field Type Description
customer_id int Target customer id
login_url string One-time terminal link; open it in a browser
expires_in int Lifetime of the code in the link, seconds

Errors

HTTP Error Description
400 INVALID_DATA Request validation failed
400 RET_INVALID_DATA The customer exists but is not a lead, or the link cannot be built (invalid language value, too many outstanding codes)
400 CUSTOMER_HAS_NO_ACCOUNTS The lead has no trading accounts
403 RET_NOT_ENOUGH_RIGHTS Missing permission, missing scope, or the record is outside the caller's visibility
403 CUSTOMER_DISABLED The lead is disabled
403 BRAND_NOT_AVAILABLE The lead's brand is inactive, disabled, not available for the API, or has no terminal_host
404 RET_NOT_FOUND No customer with that identifier exists

Every error carries a message field with free-form text. Its contents are not part of the contract; branch on error.