Using Query Parameters
You can use the following query parameters when calling the Get Users, Get Roles, Get Events, and Get Groups resource APIs.
Fields
When you call a resource API, include the fields query parameter to return only the attributes you want to return.
For example, to return only user email, username, and status values, use the field parameter with this criteria:
https://<subdomain>.onelogin.com/api/1/users?
fields=email, username, status
The response will return user objects that look like this:
{ "id": 1, "email": "test@onelogin.com", "username": "test_user", "status": 1 }
Note: The id
attribute will always be returned, even if it is not explicitly included as a fields criteria.
Search
When you call a resource API, include a search parameter to return only the results that meet your criteria.
For example, you can search for a specific attribute value:
https://<subdomain>.onelogin.com/api/1/users?email=test@onelogin.com
You can search for attribute values using wildcards. For example:
https://<subdomain>.onelogin.com/api/1/users?email=*@onelog.in
https://<subdomain>.onelogin.com/api/1/users?email=!@onelogin.com
For more information about the search parameters that are available for resources, see the documentation for the specific API call.
Since and Until
When you make a Get Users or Get Events call, include the until
and/or since
query parameters to return results that meet criteria based on created_at
atrribute values.
For example, to return resources created after a specific created_at
value, use the since
parameter:
https://<subdomain>.onelogin.com/api/1/users?since=2015-11-01T19:44:55.681Z
This will return users created after 2015-11-01T19:44:55.681Z
.
To return resources created before a specific created_at
value, use the until
parameter:
https://<subdomain>.onelogin.com/api/1/users?until=2010-11-01T19:44:55.681Z
This will return users created before 2010-11-01T19:44:55.681Z
.
To return resources created within a window of time bounded by specific created_at
values, use the since
and until
parameters together:
https://<subdomain>.onelogin.com/api/1/users?since=2010-11-01T19:44:55.681Z&until=2011-11-
01T19:44:55.681Z
This will return users created after 2010-11-01T19:44:55.681Z
, but before 2011-11-01T19:44:55.681Z
.
Pagination
When you call a resource API, the response message will include a pagination
element like the one shown here:
"pagination": {
"before_cursor": null,
"after_cursor": "bmFtZTo6Ok9mZmljZS0tIyNpZDo6OjQyMTUy",
"previous_link": null,
"next_link": "https://<subdomain>.onelogin.com/api/1/roles?
after_cursor=bmFtZTo6Ok9mZmljZS0tIyNpZDo6OjQyMTUy"
}
You can use the after_cursor
value as a query parameter to make a call to retrieve the next page, or set, of results. The next_link
value provides a premade endpoint URL using the after_cursor
value, for your convenience.
The before_cursor
and previous_link
values are returned once you’ve made a call for a subsequent page of results. For example:
"pagination": {
"before_cursor": "YWNjb3VudF9pZDo6Oi0tIyNpZDo6OjY3NzgxMjY",
"after_cursor": "YWNjb3VudF9pZDo6Oi0tIyNpZDo6OjEyMzQzODMx",
"previous_link": "https://<subdomain>.onelogin.com/api/1/users?before_cursor=
YWNjb3VudF9pZDo6Oi0tIyNpZDo6OjY3NzgxMjY",
"next_link": "https://<subdomain>.onelogin.com/api/1/users?after_cursor=
YWNjb3VudF9pZDo6Oi0tIyNpZDo6OjEyMzQzODMx"
}
You can use the before_cursor
value as a query parameter to retrieve the previous page of results. The previous_link
value provides a premade request URL for your convenience.
Limit
When you call a resource API, include the limit
query parameter to limit the number of resources returned.
For example, this call will return a set of 10 users:
https://<subdomain>.onelogin.com/api/1/users?limit=10
Note: The maximum number of resources that can be returned is 1000, regardless of the value you set limit to. For example, even if you set limit=5000
, only 1000 resources will be returned.
Sort
When you call a resource API, include the sort
query parameter to sort results by
id
attribute value.
Use the sort
parameter with criteria of id
and -
to return resources sorted by id
attribute value in descending order. For example:
https://<subdomain>.onelogin.com/api/1/users?sort=-id
Use a +
instead of -
to sort in ascending order. For example:
https://<subdomain>.onelogin.com/api/1/roles?sort=+id
Combining Parameters
You can combine use of any of the parameters discussed on this page to create very specific queries. Here are some examples:
To return type 5 events and display account ID and user ID for each event:
https://<subdomain>.onelogin.com/api/1/events?event_type_id=5&fields=account_id, user_id
To return users originating from directory_id
123456, display only their email
and username
, in descending order by id
:
https://<subdomain>.onelogin.com/api/1/users?directory_id=24689&sort=-id&fields=email, username
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.