Skip to content

MngCreateManagerApiToken

Description: Creates a time-limited manager API token using the target manager's normal permissions by default; no command list is required. An optional explicit command list restricts the token further. A live super-admin session can create a token for itself or another manager without password or OTP. Other staff must confirm their current password and, if OTP is enabled, supply a valid OTP. The token is intended for TCP Server API integrations. With the default manager scope, it has the same TCP command and subscription permissions as the target manager, including session management and SSO, subject to the manager's live role, brand, group, desk, and command-specific checks. Manager API tokens cannot access Data Lake, authenticate direct WebSocket connections, or upload files. An optional explicit commands list further restricts commands, including TCP subscription commands. The existing HTTP token subset remains available for compatibility; the token is not a WebSocket credential.

Access Control

🛡️ Access Level Required: An ordinary staff session or a manager API token over TCP (SESSION_MANAGER, SESSION_ADMIN, SESSION_DEALER, SESSION_CRM_MANAGER, or SESSION_CRM_ADMIN). Creating a token still follows the command's password/OTP confirmation and super-admin rules. The server resolves the actor's current manager profile; stale claims do not grant super-admin authority.

Request Parameters

Name Type Required Validation Description
name string Yes 1–128 bytes Label for the token in session management.
expires_days int Yes 1–365 Token lifetime in days.
commands array of strings No If supplied: 1–128 entries; each command is 1–128 ASCII letters, digits, or underscores. Empty arrays and wildcard values are invalid. Optional explicit command restriction. Omit it to use the target manager's current permission mode. Duplicate names are collapsed.
password string Conditional Required for non-super-admin staff; if supplied it must be a string. Current password used to confirm a non-super-admin actor. A live super admin does not need to supply it. The target manager's password is never used.
otp_code string Conditional Required for non-super-admin staff when OTP is enabled; if supplied it must be a string. Current authenticator code for the acting non-super-admin staff member. A live super admin does not need to supply it.
manager_id int No Positive existing manager ID. A different target is allowed only to a live super admin. Manager who will own the issued token. Defaults to the authenticated manager. The target must be enabled.

Request Example

{
  "command": "MngCreateManagerApiToken",
  "extID": "request-1",
  "__token": "<compact Ed25519 session JWT>",
  "data": {
    "name": "Nightly reconciliation",
    "manager_id": 1002,
    "expires_days": 30
  }
}

A non-super-admin manager must confirm their own credentials. When OTP is enabled for that manager, include both password and otp_code, for example:

{
  "command": "MngCreateManagerApiToken",
  "extID": "request-2",
  "__token": "<compact Ed25519 session JWT>",
  "data": {
    "name": "Nightly reconciliation",
    "expires_days": 30,
    "password": "current-manager-password",
    "otp_code": "123456"
  }
}

Response Parameters

Field Type Description
sid string UUIDv4 session identifier; use it to inspect or revoke the token's session record.
token string Compact Ed25519 JWT. Treat as a secret; it is returned only when created.
expires_at int64 Expiry time, Unix seconds.
command_scope string manager when the token uses the target manager's permissions, or commands when it uses an explicit command allowlist.
commands array of strings Effective explicit command list. Empty in manager scope; contains the unique accepted command names in commands scope. Every request remains subject to the target manager's current rights and the stored policy fingerprint. Any change to role, permission flags, brand, groups, or desks invalidates the existing manager API grant.

Response Example

{
  "sid": "07a6d2f8-caa6-41f0-a18f-9f860baf9a63",
  "token": "<compact Ed25519 manager API JWT>",
  "expires_at": 1795854000,
  "command_scope": "manager",
  "commands": []
}

The successful response is returned only after the new manager API credential is committed to the session store. This allows the credential to survive an unclean server restart. If the commit fails, token issuance fails and no usable credential is returned. An already-revoked or expired token is never restored during recovery.

Store the returned token securely. It cannot be retrieved again; revoke its sid and create a replacement if it is lost or exposed. Send it in the TCP request envelope's root __token field on each command; no AuthManager password login is needed. One token can be used by multiple TCP connections at once, including connections from different machines or network addresses; the token is not bound to its creation IP. Each connection has independent subscriptions; closing one connection does not revoke the token. Server firewall and network controls still apply. SessionLogout or an authorized revoke ends access for all connections. The expiry is the requested expires_days, independently of normal interactive session TTL configuration. Existing valid manager API tokens also gain the TCP permissions when used with a server that supports this behavior; they do not need to be reissued. Both permission modes use the target manager's live permissions and a policy fingerprint; a permission change invalidates the existing grant, which must be reissued. Later promotion cannot expand an older token. To use explicit restriction mode, include a non-empty commands array; the response then returns command_scope: "commands" and the accepted list.

An explicit restriction example is "commands": ["MngGetAccountsByFilter"]. Wildcard entries and an empty array are invalid.

Errors

Status Error Description
400 INVALID_DATA Invalid/missing name, lifetime, supplied empty/invalid command list (including wildcard entries), manager_id, or a supplied password/OTP value with the wrong type.
403 PERMISSION_DENIED Caller is not using an ordinary staff session or is attempting a blocked operation.
403 USER_NOT_FOUND_OR_INCORRECT Caller is disabled/not found or password confirmation failed.
403 OTP_REQUIRED OTP is enabled but otp_code was omitted.
403 INVALID_OTP_CODE Supplied OTP did not verify.
403 MANAGER_DISABLED The selected target manager is disabled.
404 MANAGER_NOT_FOUND The selected target manager does not exist.
400 INVALID_DATA manager_id is not a positive integer.
503 LICENSE_NOT_ACTIVE A valid active license runtime lease is required to issue a token.
503 SESSION_TOKEN_UNAVAILABLE Token signing or authorization resolution failed, or SessionGuard could not commit the new API credential to its session store. No successful token response is returned.