How to update/add scope to project role created using API?
Asked by arsen.davidson:

Hi,

I've been exploring and try the Jira [rest api](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-roles/#api-rest-api-3-role-post) to adjust things on my org. and I need some insight for **Project Role** API.

On the docs we can create and update (fully or partially) project role by the ID, my concern is the payload from creating the new project role are just **name** and **description** . I need to create roles specified on project as this is possible on the GUI panels and also there is this *scope* object we can obtain on GET .

I've tried adding the scope on the payload but it didn't work, is there any workaround I can do to add the scope? Thanks.


Answers:
author: Andy Heinzer
body: Hi Arsen,

I understand that when you make a REST call to the POST /rest/api/3/role endpoint you are not seeing a response that includes the role's id. I tested in this my own Cloud site using basic auth, but I did get back a self, name, id, and description here.

In my test I was using curl to make this call. I would be interested to learn what client you are using to make this REST call. In some cases some clients are not always setup to listen for a response for a POST or PUT call, so it might be something to do specifically with the client making this REST call.

It's not possible to add actors to a new role in the first call that creates that role. This is actually by design, and there is a note about this in the REST reference:
> *Note that although a new project role is available to all projects upon creation, any default actors that are associated with the project role are not added to projects that existed prior to the role being created.*\<

I hope that helps.

Andy

comments: author: arsen.davidson
body: Hi Andy,

actually I'm using postman for the REST call. But my question is there a possible way to update or insert scope into role created ?

I want the role only affect the some/ one project, not globally


author: Andy Heinzer
body: I guess I'm confused by the term scope here. Are you asking how to change that role within a single project?

The roles are only expected to contain either groups or individual user accounts. The endpoint [POST /rest/api/3/project/{projectIdOrKey}/role/{id}](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-role-actors/#api-rest-api-3-project-projectidorkey-role-id-post) will let you add users/groups to that role. But that endpoint is not a global change, it only applies to the specific project passed in the {projectIdOrKey} element of the URI.


author: arsen.davidson
body: ooh.. sorry for the confusion.

I mean [this API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-roles/#api-rest-api-3-role-post) to create role Andy,

It only contains name and description, and its the same for update role API which means the role created using that will have no scope of specific project ID on it.


author: arsen.davidson
body: I tried to change the payload like this, but it didn't work

![Screen Shot 2021-12-15 at 09.39.02.png](https://community.atlassian.com/t5/image/serverpage/image-id/173982i16CF8E82F68CF72B/image-size/large?v=v2&px=999 "Screen Shot 2021-12-15 at 09.39.02.png")


author: Andy Heinzer
body: Thanks for the additional explanation. When doing a GET to that endpoint, you can sometimes get back a scope that will show you which project is using that role. However the POST of that same endpoint doesn't accept a scope value as input at any time (during creation or later).

So far, the only time I have seen that scope value is when performing a GET to that endpoint and then it still only shows for roles created within a team-managed project. In my own testing, I created a new role in a team-managed project in the web UI, and then called the GET REST API endpoint /api/3/role to see this scope.

Since the REST API is expecting to create global roles when calling the create endpoint, it doesn't seem like this is something that can be set from this endpoint. The very nature of team-managed projects means that roles created there are not expected to be able to be global in nature and hence these scope help make it clear that these roles are specific to that project. More details on the differences between these projects types can be found in [What are team-managed and company-managed projects?](https://support.atlassian.com/jira-software-cloud/docs/what-are-team-managed-and-company-managed-projects/) .

Sorry if this doesn't provide the answer you are looking for, but I don't think it is possible to do this for a role created via the REST API.


Tags: cloud