Skip to main content
POST
/
users
/
gettokenbycustomerid
Get token by customer ID
curl --request POST \
  --url https://www.tryunleashx.com/api/v1/global/users/gettokenbycustomerid \
  --header 'Content-Type: application/json' \
  --header 'token: <token>' \
  --data '
{
  "customer_id": "<string>",
  "name": "<string>",
  "expiration_days": 2
}
'
{
  "message": "<string>",
  "customerid": "<string>",
  "customer_api_key": "<string>",
  "name": "<string>",
  "expires": 123
}
Use this endpoint to generate an API token for an onboarded customer using their customer_salt (Customer ID).

Endpoint

POST /users/gettokenbycustomerid Content-Type: application/json Authentication: Required (API token)

Request Body

{
  "customer_id": "048372910564",
  "name": "My API Token",
  "expiration_days": 30
}

Parameters

ParameterTypeRequiredDescription
customer_idstringYesThe 12-digit customer identifier returned from the Onboard User endpoint. Also accepts customerid or customer_salt.
namestringNoA friendly name for the token.
expiration_daysnumberNoNumber of days until the token expires. If omitted, the token does not expire.

Notes

  • The customer_id must belong to an active, non-blocked user.
  • The user must have at least one active workspace.
  • If expiration_days is provided, it must be a positive integer.
  • Each call generates a new token — previous tokens are not revoked.

Success Response

{
  "message": "API token generated successfully",
  "customerid": "048372910564",
  "customer_api_key": "a1b2c3d4e5f6...generated_token_hex",
  "name": "My API Token",
  "expires": 1743033600
}

Response Fields

FieldTypeDescription
customeridstringThe customer identifier used in the request.
customer_api_keystringThe newly generated API token.
namestring/nullThe token name, if provided.
expiresnumber/nullUnix timestamp when the token expires, or null if no expiration.

Error Responses

ErrorDescription
CUSTOMER_ID_NOT_FOUNDNo active user found with the given customer ID.
WORKSPACE_NOT_FOUNDThe user does not have an active workspace.
INVALID_EXPIRATION_DAYSThe expiration_days value is not a valid positive number.

Example cURL

curl -X POST https://www.tryunleashx.com/api/v1/global/users/gettokenbycustomerid \
  -H "Content-Type: application/json" \
  -H "Authorization: <api_key>" \
  -d '{
    "customer_id": "048372910564",
    "name": "My API Token",
    "expiration_days": 30
  }'

Headers

token
string
required

API token for authentication

Body

application/json
customer_id
string
required

The 12-digit customer identifier returned from the /users/onboard endpoint. Also accepts 'customerid' or 'customer_salt'.

name
string

A friendly name for the token

expiration_days
integer

Number of days until the token expires. If omitted, the token does not expire.

Required range: x >= 1

Response

API token generated successfully

message
string
customerid
string

The customer identifier used in the request

customer_api_key
string

The newly generated API token

name
string | null

The token name, if provided

expires
integer | null

Unix timestamp when the token expires, or null if no expiration