Assign users to project roles in Jira using REST API
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs 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
Learn how to add users to Jira project roles using the REST API with step-by-step instructions and examples.
Solution
Administrators may need to bulk-assign users to project roles across multiple projects or automate role assignments for consistency and ease of management. Manually doing this can be time-consuming.
Follow these steps to add a user to a project role via the Jira REST API:
Generate a Personal Access Token (PAT) for authentication. More information on creating a PAT can be found here.
Use the API endpoint /rest/api/2/project to retrieve the project list and select the relevant project ID.
Use the project role endpoint to identify the role ID: /rest/api/2/project/{projectId}/role.
Identify the project and role IDs:
Prepare a PUT request:
Use the following cURL command to add a user to the specified role:
curl -X PUT \ -H "Authorization: Bearer <PAT_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "categorisedActors": { "atlassian-user-role-actor": ["username"] } }' \ <JIRA_BASE_URL>/rest/api/2/project/{PROJECT_ID}/role/{ROLE_ID}
Test and verify the role assignment:
The user will now have the role assigned in the specified project. You can repeat this for other projects by changing the project ID in the API endpoint.
Was this helpful?