Try Roles v2
A new version of this API is now available that offers the ability to create, update and manage roles.
This call returns up to 50 roles per page. For details about using the pagination element to easily “page” through roles, see Query Parameters. To get roles assigned to a user, use the Get Roles for a User API. To assign one or more existing roles to user, use the Assign Role to User API. To remove one or more roles from a user, use the Remove Role from User API.
Resource URL
Before calling this API, consider using its version /2 equivalent.
https://<subdomain>.onelogin.com/api/1/rolesHeader Parameters
Authorization required string | Set to Set The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using either of the following scopes: |
Query Parameters
For details about how to search for roles using these query parameters, see Search.
idname
- Return the role whose `name` value equals `employee`
https://<subdomain>.onelogin.com/api/1/roles?name=employee - Include wildcards. For example, you can return all roles whose `name` values end with `-us`:
https://.onelogin.com/api/1/roles?name=*-us - Return a limited number of roles:
https://.onelogin.com/api/1/roles?limit=10 - Return roles sorted by `id`. Use `+` to sort in ascending order or `-` to sort in descending order:
https://<subdomain>.onelogin.com/api/1/roles?sort=+id- Return roles displaying only selected fields per role:
https://<subdomain>.onelogin.com/api/1/roles?fields=id- Combine use of multiple query parameters using an `&`:
For more details, see [Using Query Parameters](/api-docs/1/getting-started/using-query-parameters). ## Sample Responsehttps://<subdomain>.onelogin.com/api/1/roles?name=*-us&sort=+id&fields=id- 200 OK
- 400 Bad Request
- 401 Unauthorized
{ "status": { "error": false, "code": 200, "type": "success", "message": "Success" }, "pagination": { "before_cursor": null, "after_cursor": null, "previous_link": null, "next_link": null }, "data": [ { "id": 1111, "name": "C-Executive" }, { "id": 1112, "name": "Contractor" }, { "id": 1113, "name": "Default" }, { "id": 1114, "name": "Employee" } ] }Typically, this error means that your
Authorizationheader value is missing or incorrectly formatted. TheAuthorizationheader value should use this format:bearer <access_token>.{ "status": { "error": true, "code": 400, "type": "bad request", "message": "Authorization Information is incorrect" } }Typically, this error means that your access token value is invalid.
{ "status": { "error": true, "code": 401, "type": "Unauthorized", "message": "Authentication Failure" } }Response Elements
For more information about the
paginationelement, see Query Parameters.idRole's unique ID in OneLogin. nameRole name. Postman Collection
Sample Code
cURL
Replace sample values indicated by
< >with your actual values.Get Roles
curl 'https://<subdomain>.onelogin.com/api/1/roles' \ -X GET \ -H "Authorization: bearer <access_token>"Get Roles by Name
curl 'https://<subdomain>.onelogin.com/api/1/roles?name=<name>' \ -X GET \ -H "Authorization: bearer <access_token>"Python
See Work with OAuth 2.0 Tokens, Users, and Roles.
Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides? Check out our Knowledge Base.
Have a product idea or request? Share it in our Ideas Portal.
- Return a limited number of roles: