Skip to main content

Create a new personal access token (PAT) for the current user.

POST 

<your-unleash-url>/api/admin/user/tokens

Creates a new [personal access token](https://docs.getunleash.io/reference/api-tokens-and-client-keys#personal-access-tokens (PAT) belonging to the current user.

Request

Bodyrequired

#/components/schemas/createPatSchema

    descriptionstringrequired

    The PAT's description.

    Example: user:xyzrandomstring
    expiresAtdate-timerequired

    The PAT's expiration date.

    Example: 2023-04-19T08:15:14.000Z

Responses

The resource was successfully created.

Response Headers
    location

    The location of the newly created resource.

Schema
    idintegerrequired

    The PAT's ID. PAT IDs are incrementing integers. In other words, a more recently created PAT will always have a higher ID than an older one.

    Possible values: >= 1

    Example: 1
    secretstring

    The token used for authentication. It is automatically generated by Unleash when the PAT is created and that is the only time this property is returned.

    Example: user:xyzrandomstring
    createdAtdate-timerequired

    The date and time of when the PAT was created.

    Example: 2023-04-19T08:15:14.000Z
    seenAtdate-timenullable

    When the PAT was last seen/used to authenticate with. null if it has not been used yet.

    Example: 2023-04-19T08:15:14.000Z
    userIdinteger

    The ID of the user this PAT belongs to.

    Example: 1337
    descriptionstringrequired

    The PAT's description.

    Example: user:xyzrandomstring
    expiresAtdate-timerequired

    The PAT's expiration date.

    Example: 2023-04-19T08:15:14.000Z

Authorization: Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API
curl -L '<your-unleash-url>/api/admin/user/tokens' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: <Authorization>' \
-d '{
"description": "user:xyzrandomstring",
"expiresAt": "2023-04-19T08:15:14.000Z"
}'
Request Collapse all
Base URL
<your-unleash-url>
Auth
Body required
{
  "description": "user:xyzrandomstring",
  "expiresAt": "2023-04-19T08:15:14.000Z"
}
ResponseClear

Click the Send API Request button above and see the response here!