See api-docs Menu

Get Role by ID

Use this call to get a role by ID.

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

https://api.<us_or_eu>.onelogin.com/api/1/roles/:id

Header Parameter

Authorization

required

string

Set to bearer:<access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

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: Read Users, Manage users, Read All, or Manage All.

Resource Parameter

id

required

integer

Set to the id of the role that you want to return. If you don’t know the role’s id, use the Get Roles API call to return all roles and their id values.

Sample Response

{
    "status": {
        "error": false,
        "code": 200,
        "type": "success",
        "message": "Success"
    },
    "data": [
        {
            "id": 123456,
            "name": "Employee"
        }
    ]
}
{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": {
            "attribute": "id",
            "description": "ID is incorrect"
        }
    }
}

Typically, the following error means that your Authorization header value is missing or incorrectly formatted. The Authorization header 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"
    }
}
{
    "status": {
        "error": true,
        "code": 403,
        "type": "forbidden",
        "message": "user is not authorized to access this Role"
    }
}
{
    "status": {
        "error": true,
        "code": 404,
        "type": "not found",
        "message": "Role for id 9999999999 was not found"
    }
}

Response Elements

id Role’s unique ID in OneLogin.
name Role name.

Postman Collection

Be sure to set Postman-specific environment variables indicated by {{ }}.

Download for the Roles API

Sample cURL Request

Replace sample values indicated by < > with your actual values.

curl 'https://api.<us_or_eu>.onelogin.com/api/1/roles/<id>' \
-X GET \
-H "Authorization: bearer:<access_token>"

Have a Question?

Have a how-to question? Seeing a weird error? Ask us about it on StackOverflow.

Found a bug? Submit a support ticket.

Have a product idea or request? Share it with us in our Ideas Portal.