POST
/api/users/{userId}/tokensCreate a personal access token
Creates a personal access token for a user. Provide a token name and an expires_in value from 1 to 365 days. The response includes the generated token in plain text, so save it when you create it.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
userIdstringrequired
The unique identifier of the user for whom to create the token.
Personal access token creation parameters.
expires_inintegerrequired
Expiration in days
namestringrequired
Name of the token
200Returns the generated token as `plain_token` and a `personal_access_token` object containing token metadata.
personal_access_tokenobjectrequired
plain_tokenstringrequired
Plain text representation of the generated token
400Returned when the request is invalid, including when required token fields are missing or `expires_in` is outside the allowed range.
401Returned when the request lacks valid authentication.
403Returned when access to the requested operation is forbidden.
500Returned when the server encounters an internal error.
Error handling
A 400 is returned when the request is invalid; a 401 when authentication is missing or invalid; a 403 when access is forbidden; and a 500 when the server encounters an internal error. The userId path parameter identifies the user for whom you are creating the token. The request body must include name and expires_in, and expires_in must be between 1 and 365 days.