How to create a user on Jira using REST API
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Samples of REST API commands for user management on Jira. The samples are based on the following documentation:
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/group
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/user
The plugin "REST API Browser" was used for the REST API execution, but the requests can be done using curl or any REST tool.
New user added with license, Project role, and member of a Group
On this sample, we will add a new user called "user1", using the application Service Desk (consuming one license) and then adding the user with the role of "Service Desk Team member" on one project "ITSD" and as a member of a Jira's group "Mygroup".
1. Get the application key:
GET http://localhost:8081/rest/api/2/applicationrole
2. Add the new user "user1" to the application (license assigned)
POST http://localhost:8081/rest/api/2/user - (HTTP response 201)
{
"name": "user1",
"password": "user1",
"emailAddress": "user1@test.com",
"displayName": "user1",
"applicationKeys": [
"jira-servicedesk"
]
}
3. Get the role ID
GET http://localhost:8081/rest/api/2/project/ITSD/role (HTTP Response 200)
4. Assign the user to a role:
The user was added, but now you might need to grant user access to a Service Management project. For instance, adding the user as a "Service Desk Team" member for the project "ITSD".
From the previous request, we know that the ID of this role is 10101:
- Adding the user:
POST http://localhost:8081/rest/api/2/project/ITSD/role/10101 (200)
{ "user" : ["user1"] }
5. Add the user as a member of a Jira's group:
- Adding this user to the group "Mygroup":
POST http://localhost:8080/rest/api/2/group/user?groupname=Mygroup
{
"name": "user1"
}