Add personal access token

POST /api/users/{userId}/personal-access-tokens

Add a new personal access token for the user.

Path parameters

  • userId string Required

    The unique identifier of the user.

application/json

Body Required

  • name string Required

    The personal access token name. Must be unique within the user.

    Minimum length is 1, maximum length is 256.

  • expiresAt number | null

    The epoch time in milliseconds when the token will expire. If not provided, the token will never expire.

Responses

  • 201 application/json

    The personal access token was added successfully.

    Hide response attributes Show response attributes object
    • tenantId string Required

      Maximum length is 21.

    • userId string Required

      Minimum length is 1, maximum length is 21.

    • name string Required

      Minimum length is 1, maximum length is 256.

    • value string Required

      Minimum length is 1, maximum length is 64.

    • createdAt number Required
    • expiresAt number | null Required
  • Bad Request

  • Unauthorized

  • Forbidden

  • The personal access token name is already in use.

POST /api/users/{userId}/personal-access-tokens
curl \
 -X POST https://[tenant_id].logto.app/api/users/{userId}/personal-access-tokens \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"name":"string","expiresAt":42.0}'
Request examples
{
  "name": "string",
  "expiresAt": 42.0
}
Response examples (201)
{
  "tenantId": "string",
  "userId": "string",
  "name": "string",
  "value": "string",
  "createdAt": 42.0,
  "expiresAt": 42.0
}