POST/v2/pats

Create a personal access token

Creates a personal access token (PAT) for the authenticated user. Supply a non-empty description and optionally set expiresAt to an expiration time in epoch milliseconds; use null for a token that does not expire. Store the returned token securely because the response contains its value.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields

Personal access token details, including a description and optional expiration time.

descriptionstringrequired
Description of the PAT
expiresAtintegeroptional
Expiration date in epoch format (milliseconds). When null, token never expires.

5 status codes
201Returns the created token record, including its identifier, description, creation and update times, and token value; expiration and last-used times are included when available.
createdAtintegerrequired
descriptionstringrequired
expiresAtintegeroptional
idintegerrequired
lastUsedAtintegeroptional
tokenstringrequired
updatedAtintegerrequired
400Returned when `description` is missing or empty, or a body value fails validation.
codestringrequired
Allowed:unauthenticatedapi_access_forbiddenapi_key_not_foundinvalid_api_keyinvalid_project_api_keyproject_api_key_expiredbad_credentialsmfa_enabledinvalid_otp_codemfa_not_enabledcan_not_revoke_own_permissionsdata_corrupted
paramsarray<object>optional
401Returned when the request is not authenticated.
codestringrequired
Allowed:unauthenticatedapi_access_forbiddenapi_key_not_foundinvalid_api_keyinvalid_project_api_keyproject_api_key_expiredbad_credentialsmfa_enabledinvalid_otp_codemfa_not_enabledcan_not_revoke_own_permissionsdata_corrupted
paramsarray<object>optional
403Returned when the authenticated user is not permitted to create a personal access token.
codestringrequired
Allowed:unauthenticatedapi_access_forbiddenapi_key_not_foundinvalid_api_keyinvalid_project_api_keyproject_api_key_expiredbad_credentialsmfa_enabledinvalid_otp_codemfa_not_enabledcan_not_revoke_own_permissionsdata_corrupted
paramsarray<object>optional
404Returned when a resource required by the request cannot be found.
codestringrequired
Allowed:unauthenticatedapi_access_forbiddenapi_key_not_foundinvalid_api_keyinvalid_project_api_keyproject_api_key_expiredbad_credentialsmfa_enabledinvalid_otp_codemfa_not_enabledcan_not_revoke_own_permissionsdata_corrupted
paramsarray<object>optional

Error handling

A 400 is returned when description is missing or empty, or when the request body is invalid. A 401 is returned when the request is not authenticated, and a 403 when the authenticated user cannot create a token. A 404 is returned when a resource required by the request cannot be found. expiresAt, when provided, must be an epoch timestamp in milliseconds.