Skip to main content

Check

Check if a specific relation exists between a particular subject and object. Use this endpoint to enforce access to the resources and actions available to users (or other types of subjects) in your application.

For example, you may want to check if user:5djfs6 (subject) is viewer (relation) of report:avk2837 (object). A Check for this relation will yield an Authorized response if user:5djfs6 is explicitly a viewer of report:avk2837 via a warrant or implicitly via the inheritance rules specified by its object type. Otherwise, the Check will yield a Not Authorized response.

This endpoint also supports checking for a logical combination (e.g. && and ||) of multiple warrants (returning a single result) and checking for multiple warrants separately (returning one result per warrant).

Endpoint
POST /v2/check

Request

Headers


Warrant-Token string, optional

A valid Warrant-Token from a previous write operation or latest. Used to specify desired consistency for this read operation.


Body


op string, required if warrants contains more than one warrant

The operator to use when warrants contains a list of more than one warrant. Supported values are allOf, anyOf, and batch. See the table below for a description of the check endpoint's behavior given each value of op.

ValueDescription
allOfIf op is allOf, the check endpoint returns a single check result. The result is Authorized if all of the specified warrants are matched. Otherwise, the result is Not Authorized.
anyOfIf op is anyOf, the check endpoint returns a single check result. The result is Authorized if any of the specified warrants are matched. Otherwise, the result is Not Authorized.
batchIf op is batch, the check endpoint returns a list of check results (one for each warrant provided in warrants). The order of this list will match the order of warrants. This operation is only available in Warrant Cloud.

warrants array

A list of relations (between a subject and an object) to check for. Each element should contain the parameters specified in the table below.

ParameterTypeDescriptionRequired
objectTypestringThe type of object. Must be one of your system's existing object types.yes
objectIdstringThe id of the specific object.yes
relationstringThe relation to check for. Must be a valid relation in objectType's object type.yes
subjectobjectThe specific subject that must have the relation. Can be a specific subject (objectType + objectId) or a group of subjects (objectType + objectId + relation).yes
contextobjectContextual data to use for resolving the access check. This data will be used when evaluating warrant policies.no

POST /v2/check
curl "https://api.warrant.dev/v2/check" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY" \
--data-raw \
'{
"warrants": [
{
"objectType": "report",
"objectId": "avk2837",
"relation": "viewer",
"subject": {
"objectType": "user",
"objectId": "5djfs6"
}
}
]
}'

Response

Body


code number

The HTTP response code that can be used to represent the result of the check request. 200 if the check request resulted in a match and 403 otherwise.


result string

The result of the check request. Authorized if the check request matched a warrant and Not Authorized otherwise.


200 OK
{
"code": 200,
"result": "Authorized"
}