Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Role Assignment API reference


The Role Assignment API lets you manage which roles are assigned to users within your organization. A role assignment connects a user to a role within a specific scope, such as your organization or an individual account.

Base URL: https://iam.twilio.com/v2/Organizations


Authentication and authorization

authentication-and-authorization page anchor

The Role Assignment API is an organization-level API. You can only access it using OAuth credentials. Account Auth Tokens and API Keys aren't supported.

To create an OAuth app and generate an access token, follow the steps in Set up OAuth.

In subsequent requests, use the returned access_token as a Bearer token:

Authorization: Bearer {access_token}

Required OAuth app permissions

required-oauth-app-permissions page anchor

To call these endpoints, grant your OAuth app the following permissions. Configure these permissions on your OAuth app in the Twilio Console.

EndpointRequired permission
List role assignmentstwilio/iam/role-assignments/list
Create a role assignmenttwilio/iam/role-assignments/create
Delete a role assignmenttwilio/iam/role-assignments/delete
(information)

Info

The Role Assignment API doesn't support updating an existing role assignment. To change a user's role, delete the existing role assignment and create a new one.

Bulk role assignment isn't supported. You can only create or delete one role assignment per request.


PropertyTypeDescription
sidstringThe unique identifier for the role assignment. Starts with IY.
role_sidstringThe SID of the assigned role. Starts with IX.
scopestringThe SID that defines where the role applies. Can be an Organization SID (OR), Account SID (AC), or Subaccount SID (AC).
identitystringThe SID of the user the role is assigned to. Starts with US.
resource_typestring or nullThe resource type for resource-level role assignments.
resource_idstring or nullThe resource ID for resource-level role assignments.

Retrieve a paginated list of role assignments. You can filter by user identity, scope, resource type, and resource ID.

GET /v2/Organizations/RoleAssignments
ParameterTypeNecessityDescription
IdentitystringOptionalFilter by user SID.
ScopestringOptionalFilter by scope SID.
ResourceTypestringOptionalFilter by resource type for resource-level role assignments.
ResourceIdstringOptionalFilter by resource ID for resource-level role assignments.
PageSizeintegerOptionalNumber of results per page. Default: 50, maximum: 100.
PageTokenstringOptionalToken for fetching the next page of results.

List role assignments example

list-role-assignments-example page anchor
1
curl -X GET 'https://iam.twilio.com/v2/Organizations/RoleAssignments?Identity=USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
2
-H 'Authorization: Bearer {access_token}' \
3
-H 'Accept: application/json'

200 OK

1
{
2
"content": [
3
{
4
"sid": "IYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"role_sid": "IXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"scope": "ORaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"resource_type": null,
9
"resource_id": null
10
},
11
{
12
"sid": "IYbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
13
"role_sid": "IXbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
14
"scope": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"resource_type": null,
17
"resource_id": null
18
},
19
{
20
"sid": "IYcccccccccccccccccccccccccccccccc",
21
"role_sid": "IXcccccccccccccccccccccccccccccccc",
22
"scope": "ORaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
24
"resource_type": "billing_group",
25
"resource_id": "billing_group_1a2b3c4d5e6f7g8h9i0j1k2l3m"
26
}
27
],
28
"meta": {
29
"page_size": 50,
30
"page": 0,
31
"key": "content",
32
"first_page_url": "https://iam.twilio.com/v2/Organizations/RoleAssignments?PageSize=50&Page=0&Identity=USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
33
"previous_page_url": null,
34
"next_page_url": null,
35
"url": "https://iam.twilio.com/v2/Organizations/RoleAssignments?PageSize=50&Page=0&Identity=USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
36
}
37
}

Create a role assignment

create-a-role-assignment page anchor

Assign a role to a user within a specific scope.

POST /v2/Organizations/RoleAssignments
ParameterTypeNecessityDescription
role_sidstringRequiredThe SID of the role to assign. Starts with IX.
scopestringRequiredThe SID that defines where the role applies. Can be an Organization SID (OR) or Account SID (AC).
identitystringRequiredThe SID of the user to assign the role to. Starts with US.
resource_typestringOptionalThe resource type for resource-level role assignments.
resource_idstringOptionalThe resource ID for resource-level role assignments.

Organization scope request example

organization-scope-request-example page anchor
1
curl -X POST 'https://iam.twilio.com/v2/Organizations/RoleAssignments' \
2
-H 'Authorization: Bearer {access_token}' \
3
-H 'Content-Type: application/json' \
4
-d '{
5
"role_sid": "IXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"scope": "ORaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
8
}'

Account scope request example

account-scope-request-example page anchor
1
curl -X POST 'https://iam.twilio.com/v2/Organizations/RoleAssignments' \
2
-H 'Authorization: Bearer {access_token}' \
3
-H 'Content-Type: application/json' \
4
-d '{
5
"role_sid": "IXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"scope": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
8
}'

Resource-level request example

resource-level-request-example page anchor
1
curl -X POST 'https://iam.twilio.com/v2/Organizations/RoleAssignments' \
2
-H 'Authorization: Bearer {access_token}' \
3
-H 'Content-Type: application/json' \
4
-d '{
5
"role_sid": "IXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"scope": "ORaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"resource_type": "billing_group",
9
"resource_id": "billing_group_1a2b3c4d5e6f7g8h9i0j1k2l3m"
10
}'

201 Created

1
{
2
"sid": "IYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"role_sid": "IXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"scope": "ORaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"identity": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"resource_type": "billing_group",
7
"resource_id": "billing_group_1a2b3c4d5e6f7g8h9i0j1k2l3m"
8
}

400 Bad Request - Invalid parameters:

1
{
2
"code": 20001,
3
"message": "Invalid request",
4
"more_info": "https://www.twilio.com/docs/errors/20001",
5
"status": 400
6
}

403 Forbidden - Insufficient permissions:

1
{
2
"code": 20003,
3
"message": "Authorization denied",
4
"more_info": "https://www.twilio.com/docs/errors/20003",
5
"status": 403
6
}

Delete a role assignment

delete-a-role-assignment page anchor

Remove a role assignment from a user.

DELETE /v2/Organizations/RoleAssignments/{RoleAssignmentSid}
ParameterTypeNecessityDescription
RoleAssignmentSidstringRequiredThe SID of the role assignment to delete. Starts with IY.

Delete a role assignment example

delete-a-role-assignment-example page anchor
1
curl -X DELETE 'https://iam.twilio.com/v2/Organizations/RoleAssignments/IYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
2
-H 'Authorization: Bearer {access_token}'

204 No Content - Role assignment successfully deleted.

403 Forbidden - Insufficient permissions:

1
{
2
"code": 20003,
3
"message": "Authorization denied",
4
"more_info": "https://www.twilio.com/docs/errors/20003",
5
"status": 403
6
}