SYNERGY
Chapters

8.5Saved filters in the REST API

Last updated

Saved filters are available on the machine surface under /api/saved-ldap-filters.

Method and pathPermissionPurpose
GET /api/saved-ldap-filterssavedfilters:listList filters (pageNumber, pageSize, optional objectType)
GET /api/saved-ldap-filters/{id}savedfilters:readRead one filter
POST /api/saved-ldap-filterssavedfilters:createCreate a filter; answers 201
PUT /api/saved-ldap-filters/{id}savedfilters:updateReplace a filter's definition
DELETE /api/saved-ldap-filters/{id}savedfilters:deleteDelete a filter you created; answers 204
GET /api/saved-ldap-filters/{id}/resultssavedfilters:executeRun the filter

In requests and responses the object type is a number:

ValueObject type
0All (Generic)
1User
2Group
3Computer
4Organizational unit

A creation request looks like this:

json
{
  "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:

http
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.

ResponseMeaning
200Results returned
204The filter matched nothing
400Invalid page size or continuation token, or the filter could not be parsed
403Missing permission, no active licence (License.NotActivated), or the filter names a protected attribute (AD.Attributes.ReadForbidden)
404No 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

Did this page help you?