How to create a user on Jira using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

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



JSON returned
[
  {
    "key": "jira-servicedesk",
    "groups": [
      "jira-servicedesk-users"
    ],
    "name": "JIRA Service Desk",
    "defaultGroups": [
      "jira-servicedesk-users"
    ],
    "selectedByDefault": false,
    "defined": true,
    "numberOfSeats": 10,
    "remainingSeats": 9,
    "userCount": 1,
    "userCountDescription": "agent",
    "hasUnlimitedSeats": false,
    "platform": false
  },
  {
    "key": "jira-software",
    "groups": [
      "jira-administrators",
      "jira-software-users"
    ],
    "name": "Jira Software",
    "defaultGroups": [
      "jira-software-users"
    ],
    "selectedByDefault": true,
    "defined": true,
    "numberOfSeats": 10,
    "remainingSeats": 9,
    "userCount": 1,
    "userCountDescription": "user",
    "hasUnlimitedSeats": false,
    "platform": false
  }
]


2. Add the new user "user1" to the application (license assigned)
POST http://localhost:8081/rest/api/2/user - (HTTP response 201)


JSON provided
{
  "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:


JSON provided
{ "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


JSON provided
{
  "name": "user1"
}





Last modified on Sep 13, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.