8.5Saved filters in the REST API
Last updated
Saved filters are available on the machine surface under /api/saved-ldap-filters.
| Method and path | Permission | Purpose |
|---|---|---|
GET /api/saved-ldap-filters | savedfilters:list | List filters (pageNumber, pageSize, optional objectType) |
GET /api/saved-ldap-filters/{id} | savedfilters:read | Read one filter |
POST /api/saved-ldap-filters | savedfilters:create | Create a filter; answers 201 |
PUT /api/saved-ldap-filters/{id} | savedfilters:update | Replace a filter's definition |
DELETE /api/saved-ldap-filters/{id} | savedfilters:delete | Delete a filter you created; answers 204 |
GET /api/saved-ldap-filters/{id}/results | savedfilters:execute | Run the filter |
In requests and responses the object type is a number:
| Value | Object type |
|---|---|
| 0 | All (Generic) |
| 1 | User |
| 2 | Group |
| 3 | Computer |
| 4 | Organizational unit |
A creation request looks like this:
{
"name": "Disabled accounts in Finance",
"description": "Accounts in Finance with the disabled flag set",
"objectType": 1,
"ldapFilter": "(&(department=Finance)(userAccountControl:1.2.840.113556.1.4.803:=2))",
"baseDn": "OU=Finance,DC=example,DC=com",
"propertiesToLoad": ["displayName", "sAMAccountName", "whenChanged"],
"sortBy": null
}The API also accepts an optional sortBy attribute name, which is stored with the filter and used when it runs; the console form does not show it.
To run a filter, call the results route. The caller supplies only paging; everything else comes from the stored filter:
GET /api/saved-ldap-filters/5d0c…/results?pageSize=100
X-API-Key: <your key>The response has the same shape as other directory searches: the matching objects under data, and meta.nextContinuationToken and links.next when there is another page. Pass the token as continuationToken to fetch the next page. pageSize defaults to 50 and may not exceed 1000. When nothing matches, the route answers 204 No Content with no body. Runs are rate-limited like other directory searches.
| Response | Meaning |
|---|---|
| 200 | Results returned |
| 204 | The filter matched nothing |
| 400 | Invalid page size or continuation token, or the filter could not be parsed |
| 403 | Missing permission, no active licence (License.NotActivated), or the filter names a protected attribute (AD.Attributes.ReadForbidden) |
| 404 | No filter with that identifier, or the base DN does not exist in this directory |
See Chapter 15, REST API for integrators, for authentication and the general response format.
Good practice
- Give filters names that describe the result ("Disabled accounts in Finance"), not the syntax.
- Fill in the description for any filter used by a workflow or agent, saying who depends on it.
- Leave Base DN empty for filters meant to run in several directories.
- Request only the attributes you need.
- Test a new filter in the Directory Browser with a manual search, then save it from the results.
- Before editing a widely used filter, consider creating a new one instead, so existing workflows keep their current behaviour.
Last updated
Thank you for your feedback.