POST

Bulk Logout Users

Use this API to log out a set of users in bulk by invalidating their existing sessions. This forces the affected users to re-authenticate the next time they access OneLogin or a connected app; it does not delete, disable, or suspend the user accounts themselves.

You select which users are affected by combining one or more of the request parameters below. If you supply role_id, group_id, and/or status together, they are combined with AND logic (a user must match all of the supplied filters to be logged out). Set all=true to log out every user on the account, in which case role_id, group_id, and status are ignored for selection purposes.

At least one of all, role_id, group_id, or status is required. Calling this API with no parameters returns a 422 error.

Resource URL

https://<subdomain>.onelogin.com/api/2/users/bulk_logout

Header Parameters

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 any one of the following scopes: Manage Users or Manage All.

Content-Type

required

string

Set to application/json.

Request Parameters

At least one of the parameters below is required.

allbooleanSet to true to log out every user on the account. When present and true, this takes priority and role_id/group_id/status are not applied as filters.
role_idintegerLog out only users assigned this OneLogin Role ID.
group_idintegerLog out only users assigned this OneLogin Group ID.
statusintegerLog out only users with this status.

0: Unactivated
1: Active
2: Suspended
3: Locked
4: Password expired
5: Awaiting password reset
7: Pending Password

Any other value returns a 422 error listing the allowed values.

Sample Request Body

Log out all users on the account.

{
  "all": true
}

Log out only Suspended users in a specific Group.

{
  "group_id": 461331,
  "status": 2
}

Log out only users who have a specific Role.

{
  "role_id": 272445
}

Sample Response

Returns the count of users whose sessions were invalidated. The message is singular or plural depending on the count.

{
    "message": "3 users logged out"
}
{
    "message": "1 user logged out"
}

Typically, this error means that your access token value is invalid.

{
    "message": "Unauthorized",
    "name": "UnauthorizedError",
    "statusCode": 401
}

Returned when no users match the supplied filters.

{
    "message": "No matching users found"
}

Returned when none of all, role_id, group_id, or status were supplied.

{
    "message": "Must include params. To logout all users include `?all=true`",
    "name": "UnprocessableEntityError",
    "statusCode": 422
}

Returned when status is supplied but is not one of the allowed values.

{
    "message": "Invalid status '9'. Allowed values: 0, 1, 2, 3, 4, 5, 7",
    "name": "UnprocessableEntityError",
    "statusCode": 422
}

Postman Collection

Replace sample variables indicated by < > in the sample request body with your actual values. Also, be sure to set Postman-specific environment variables indicated by {{ }}.

Run in Postman

    Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.

Sample Code

cURL

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

curl 'https://<subdomain>.onelogin.com/api/2/users/bulk_logout' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
  "all": true
}'