See api-docs Menu

Get Role by ID

Try Roles v2

A new version of this API is now available that offers the ability to create, update and manage roles.

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://<subdomain>/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://<subdomain>/api/1/roles/<id>' \
-X GET \
-H "Authorization: bearer:<access_token>"

Have a Question?

Found a problem or a bug? Submit a support ticket.

Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.

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