Skip to main content

Create a Warrant

Create a new warrant that associates a subject (e.g. user:john-doe) to an object (e.g. report:balance-sheet) via a relation (e.g. editor).

Endpoint
POST /v2/warrants

Request

Body


objectType string

The type of object. Must be one of your system's existing object types.


objectId string

The id of the specific object.


relation string

The relation for this object to subject association. The relation must be valid as per the object type definition.


subject object

The subject for which this warrant applies. Subject can be a specific object (by id) or a set of objects matching the given objectType, objectId and relation.


policy string, optional

A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables that are provided in the context attribute of access check requests. See Key Concepts > Warrants > Policies & Context to learn more about writing policies.


POST /v2/warrants
curl "https://api.warrant.dev/v2/warrants" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY" \
--data-raw \
'{
"objectType": "report",
"objectId": "23ft346",
"relation": "editor",
"subject": {
"objectType": "user",
"objectId": "15ads7823a9df7as433gk23dd"
}
}'

Response

Headers


Warrant-Token string

A unique transaction identifier for this write operation. Can be cached and passed on subsequent read requests.


Body


objectType string

The type of object. Must be one of your system's existing object types.


objectId string

The id of the specific object.


relation string

The relation for this object to subject association. The relation must be valid as per the object type definition.


subject object

The subject for which this warrant applies. Subject can be a specific object (by id) or a set of objects matching the given objectType, objectId and relation.


policy string

A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables that are provided in the context attribute of access check requests. See Key Concepts > Warrants > Policies & Context to learn more about writing policies.


200 OK
{
"objectType": "report",
"objectId": "23ft346",
"relation": "editor",
"subject": {
"objectType": "user",
"objectId": "15ads7823a9df7as433gk23dd"
}
}