Manage API token through API REST call

Valentin Mercier January 29, 2025

Hey everyone, 
Here is my use case, my account is an org admin of atlassian and I created a org API token. 
What I would like to do, is creating a new API token, for a specific user, via an API call. 
Something like 

 

https://api.atlassian.com/users/{account_id}/manage/api-tokens/

and a body with the name and the expiry date, which the API should response with the token. 
I know that's what is used in the background when doing it in the UI. 
When I try to do so, the answer is the following:

 

"key": "forbidden.action",
    "context": {
        "allowed": false,
        "reason": {
            "key": "myselfOnly"
        }
}
And I can't figure how to do so with the user. 
Thanks in advance for your help ! 

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 29, 2025

Hi,

you can't create a token for different user. Each user have to create his own token.

https://community.atlassian.com/t5/Jira-questions/API-Token-for-different-user/qaq-p/1075828

Valentin Mercier January 29, 2025

Hi @Mohamed Benziane 
Thanks for the answer, I realized that already. 

My question was more, with a user, can I then create an API token with an API call? The thread you linked doesn't seems to answer that question unfortunately. 

Cheers

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 29, 2025
Valentin Mercier January 29, 2025

Seems strange tho, an API call is done when I click the button in the page. 
And I already have a token for such things, the goal is to replace it when it's almost expired with an automated process that will let me store it in a PAM system. 

Using the https://api.atlassian.com/users/{account_id}/manage/api-tokens/ with an authenticated user with his own API token returns me "Unauthorized" which means that the Bearer Token for the user cannot and is not used correctly for such a call. 

It's kind of a shame that can't do that, or that Atlassian is not willing to share how we could do that :( 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events