Skip to content
Directory & LifecycleMarkdown

Search and paging

Find users, groups and any other object by their attributes, sorted the way you want, a page at a time.

AvailableAPI

Every list in the directory takes the same search: free text across a type’s attributes, a filter built from conditions on any of them, a sort on one or more, and a page size. Find every inactive user, everyone whose access ends this month, or the groups whose name starts with eng, with one call.

  • Privilege: RealmViewer is enough; a search returns only what the caller may read. See Who may do what.
  • Where: the API, with your session in $CVYUH_SESSION (see Call the API).

A list is a GET on the type: /objects/v1/user for users, /objects/v1/group for groups, and the same for an agent or a type of your own. It takes these query parameters:

ParameterWhat it does
filterA JSON search document: text, a free-text match, and filter, a tree of conditions. Both are optional
sortOne or more attributes, comma-separated, each with - for descending: -accountExpiry,lastName
page, pageSizeWhich page, from 1, and how many on it: 20 unless you say, at most 100
cursorThe nextCursor the last page gave. Sending it always pages by cursor (below)
totalPolicynone to skip counting the matches, which makes a large list faster
expandLinks to include in each result, such as memberOf/*; at most 10,000 per link attribute

The answer is a page: data, the objects themselves, then pageSize and, as they apply, page, totalCount, totalPages, hasMore and nextCursor.

Pages or a cursor. A realm pages by number unless it’s set to page by cursor; either way, a request that sends cursor is paged by cursor. Paged by number, the answer counts the matches (totalCount, totalPages). Paged by cursor, it says only whether there’s more (hasMore) and where to go on from (nextCursor).

Free text (text) matches any part of a type’s text attributes, ignoring case: "text": "chen" finds Maya Chen by her last name or her email. Conditions match case exactly: = and like treat Eng% and eng% as different, so match the case you stored, or use free text.

A condition names an attribute, an operator and a value: { "field": "status", "op": "=", "value": "inactive" }. Combine conditions with { "type": "and", "rules": [ … ] }, "or", or "not" around a single one, nested as deep as you need.

OperatorsFor
=, !=Any attribute
in, not inText, with a list of values: ["london", "paris"]
like, not likeText, with % as the wildcard
>, >=, <, <=Numbers and times
betweenTimes, with [from, to]; either end may be null for open
is null, is not nullWhether an attribute is set

An attribute that isn’t set matches no condition but is null: a user without a department matches neither department = Finance nor department != Finance. | contains | A list of text holding the value |

curl -G --data-urlencode encodes the search document for the address.

Every inactive user, by last name:

Terminal window
curl -G https://foobar.cvyuh.com/api/v0/am/objects/v1/user \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
--data-urlencode 'sort=lastName' \
--data-urlencode 'filter={"filter":{"field":"status","op":"=","value":"inactive"}}'

Every user whose access ends before a date, soonest first:

Terminal window
curl -G https://foobar.cvyuh.com/api/v0/am/objects/v1/user \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
--data-urlencode 'sort=accountExpiry' \
--data-urlencode 'filter={"filter":{"type":"and","rules":[
{"field":"accountExpiry","op":"is not null"},
{"field":"accountExpiry","op":"<","value":"<RFC 3339 time>"}]}}'

Every group whose name starts with eng:

Terminal window
curl -G https://foobar.cvyuh.com/api/v0/am/objects/v1/group \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
--data-urlencode 'filter={"filter":{"field":"displayName","op":"like","value":"Eng%"}}'

To keep a long search out of the address, send the same parameters as a JSON body with the QUERY method in place of GET:

Terminal window
curl -X QUERY https://foobar.cvyuh.com/api/v0/am/objects/v1/user \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "sort": "lastName", "pageSize": 50,
"filter": { "text": "chen" } }'
WhatDefault or limit
pageSize20; at most 100, and a larger value is cut to 100
pageFrom 1; a lower value reads as 1
PagingBy number, unless the realm is set to page by cursor or the request sends cursor
Links per expandAt most 10,000 per link attribute; past that the read is refused 413
Nested expand4 levels
CaseFree text ignores case; =, in and like don’t
AnswerCodeWhat it meansWhat to do
400INVALID_REQUESTAn unknown field, an operator that doesn’t fit the field, a link used as a filter field, or a malformed search documentCheck the field against the type, and the operator against the table above
403FORBIDDENThe caller may not read the typeAsk for RealmViewer
413PAYLOAD_TOO_LARGEAn expand would return more than 10,000 linksLeave out expand, and page the links on /objects/v1/{type}/{id}/relationships/{link}
SymptomCauseFix
A search for eng% finds nothinglike and = match case exactlyWrite the case you stored (Eng%), or use text
A != condition leaves out users you expectedUsers without the attribute match no condition but is nullAdd or with is null on the same field
400 “unknown filter field” for an attribute you writeThe attribute isn’t on the type, or it’s a linkAdd the attribute to the type; for links, list them on the object
totalCount is missingThe realm pages by cursor, you sent cursor, or you set totalPolicy=nonePage by number to count
  • Secret values can’t be searched. Passwords, sealed attributes and values only a root administrator may read are left out of filters, sort and free text, so a search can’t be used to guess them.
  • Links aren’t filter fields. To find a group’s members, list them on the group: /objects/v1/group/engineering/relationships/member, which takes the same parameters.
  • An unknown field, or an operator that doesn’t fit it, is refused. The realm answers 400 rather than ignoring part of your search.
  • An attribute you add is searchable at once. Each new attribute joins the filter fields as soon as the type is saved. See Attributes and validation.