How to create Personal Acess Tokens(PAT) in Bamboo for a user through REST API
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This document explains how to generate Personal Access Tokens in Bamboo through the REST API curl command.
Environment
All supported versions of Bamboo
Solution
REST API endpoint to create a access token (PAT) for a user: POST /api/latest/access-token
Please refer to this REST API documentation for more details.
Curl command to generate a token:
curl --request POST \
--url 'http://{baseurl}/rest/api/latest/access-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"daysUntilExpiry": 2154,
"name": "token name",
"permissions": [
"<string>"
]
}'
Parameter "daysUntilExpiry"(in data) was introduced in Bamboo 9.4.0 version. This parameter can't be used in data value(in the above curl command) with Bamboo versions < 9.4.0. Other parameters ("name" and "permissions") can be used with Bamboo versions below 9.4.0.
Permissions can be passed like ["READ", "TRIGGER", "USER"]
Below is the sample command to generate a token for user "user1" with "READ" permission:
curl --request POST \
-u user1:<password> --url 'https://test.prod.atl-cd.net/bamboo/rest/api/latest/access-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"name": "bamboouser1",
"permissions": [
"READ"
]
}