Create a Personal-Access-Token (PAT)​
Generates a new PAT for the user. Currently only available for machine users. The token will be returned in the response, make sure to store it. PATs are ready-to-use tokens and can be sent directly in the authentication header.
Path Parameters
userId string required
Header Parameters
x-zitadel-orgid string
The default is always the organization of the requesting user. If you like to update a user from another organization include the header. Make sure the requesting user has permission in the requested organization.
application/json
application/grpc
application/grpc-web+proto
Request Body required
expirationDate date-time
The date the token will expire and no logins will be possible
Request Body required
expirationDate date-time
The date the token will expire and no logins will be possible
Request Body required
expirationDate date-time
The date the token will expire and no logins will be possible
Responses
- 200
- default
OK
application/json
application/grpc
application/grpc-web+proto
Schema
Example (from schema)
Schema
tokenId string
token string
details object
{
"tokenId": "string",
"token": "string",
"details": {
"sequence": "2",
"creationDate": "2024-06-17T09:46:07.740Z",
"changeDate": "2024-06-17T09:46:07.740Z",
"resourceOwner": "69629023906488334"
}
}
Schema
Example (from schema)
Schema
tokenId string
token string
details object
{
"tokenId": "string",
"token": "string",
"details": {
"sequence": "2",
"creationDate": "2024-06-17T09:46:07.740Z",
"changeDate": "2024-06-17T09:46:07.740Z",
"resourceOwner": "69629023906488334"
}
}
Schema
Example (from schema)
Schema
tokenId string
token string
details object
{
"tokenId": "string",
"token": "string",
"details": {
"sequence": "2",
"creationDate": "2024-06-17T09:46:07.740Z",
"changeDate": "2024-06-17T09:46:07.740Z",
"resourceOwner": "69629023906488334"
}
}
An unexpected error response.
application/json
application/grpc
application/grpc-web+proto
Schema
Example (from schema)
Schema
code int32
message string
details object[]
{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
Schema
Example (from schema)
Schema
code int32
message string
details object[]
{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
Schema
Example (from schema)
Schema
code int32
message string
details object[]
{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
POST /users/:userId/pats
Authorization
name: OAuth2type: oauth2scopes:openid,urn:zitadel:iam:org:project:id:zitadel:aud
flows: { "authorizationCode": { "authorizationUrl": "$CUSTOM-DOMAIN/oauth/v2/authorize", "tokenUrl": "$CUSTOM-DOMAIN/oauth/v2/token", "scopes": { "openid": "openid", "urn:zitadel:iam:org:project:id:zitadel:aud": "urn:zitadel:iam:org:project:id:zitadel:aud" } } }
Request
Request
curl / cURL
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
python / requests
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
go / native
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
nodejs / axios
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
ruby / Net::HTTP
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
csharp / RestSharp
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
php / cURL
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
java / OkHttp
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'
powershell / RestMethod
curl -L -X POST 'https://$CUSTOM-DOMAIN/management/v1/users/:userId/pats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"expirationDate": "2519-04-01T08:45:00.000000Z"
}'