searchRules), an API key UID, and an optional expiration date.
Example payload
Search rules
Tenant token search rules (the
searchRules field) are not related to the Search Rules feature. Tenant token search rules restrict which documents a user can access. Search Rules pin, boost, deboost, or hide documents in results.Search rules object
searchRules must be a JSON object. Each key must correspond to one or more indexes:
filter key. This filter’s value must be a filter expression:
searchRules object.
A token may contain rules for any number of indexes. Specific rulesets take precedence and overwrite * rules.
The search rule may also be an empty object. In this case, the tenant token will have access to all documents in an index:
Examples
Single filter
In this example, the user will only receivemedical_records documents whose user_id equals 1:
Multiple filters
In this example, the user will only receivemedical_records documents whose user_id equals 1 and whose published field equals true:
Give access to all documents in an index
In this example, the user has access to all documents inmedical_records:
Target multiple indexes with a partial wildcard
In this example, the user will receive documents from any index starting withmedical. This includes indexes such as medical_records and medical_patents:
Target all indexes with a wildcard
In this example, the user will receive documents from any index in the whole instance:Target multiple indexes manually
In this example, the user has access to documents withuser_id = 1 for all indexes, except one. When querying medical_records, the user will only have access to published documents:
API key UID
Tenant token payloads must include an API key UID to validate requests. The UID is an alphanumeric string identifying an API key:Expiry date
The expiry date must be a UNIX timestamp ornull: