Skip to main content

Token - Token Create

Endpoint

/i/token/create

Overview

Creates an auth token owned by the authenticated dashboard user.

Authentication

  • API Key (parameter): api_key=YOUR_API_KEY
  • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
  • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

Permissions

  • Any authenticated dashboard user.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)Dashboard API key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
purposeStringNoOptional token description.
ttlNumberNoToken lifetime in seconds. Default: 1800.
multiBoolean/StringNoReuse flag. false or "false" disables reuse. Default: true.
appsStringNoComma-separated app IDs to restrict token scope.
endpointStringNoComma-separated endpoint regex patterns for token scope.
endpointqueryJSON String (Array/Object)NoStructured endpoint restrictions. If parse fails, endpoint fallback is used.

Response

Success Response

{
"result": "0e1c012f855e7065e779b57a616792fb5bd03834"
}

Response Fields

FieldTypeDescription
resultStringGenerated token value.

Error Responses

Status Code: 400 Bad Request

{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}

Status Code: 404 Not Found

{
"result": "Token must have owner. Please provide correct user id"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Standard createAuthenticated user, token options parsedSaves token with defaults/overrides.Wrapped token string.
Endpoint query modeendpointquery parsed successfullyStores parsed endpoint restrictions.Wrapped token string.
Endpoint fallback modeendpointquery parse fails and endpoint existsStores comma-split endpoint patterns.Wrapped token string.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersOwner validationValidates token owner identity before save.
countly.auth_tokensToken storageRemoves expired rows, inserts new token row.

Examples

Example 1: Create basic token

/i/token/create?api_key=YOUR_API_KEY&purpose=Mobile Integration

Example 2: Create endpoint-restricted token

/i/token/create?api_key=YOUR_API_KEY&purpose=Read Analytics&endpoint=/o/apps,/o/analytics&ttl=3600&multi=false

Limitations

  • Endpoint regex patterns are stored as provided; invalid regex patterns are not deeply validated during token creation.

Last Updated

2026-02-17