Skip to main content

Create an Object Type

Create a new object type.

POST /v1/object-types

Parameters

ParameterDescriptionTypeRequired
typeA string identifier for this new object type. The type can only be composed of lower-case alphanumeric chars and/or '-' and '_'.JSON bodyyes
relationsThe set of all supported relationships that objects of this type can have with other objects (established via warrants). By default, each provided relation can be explicitly assigned to objects via warrants. This default case is represented by the empty relation definition {}. You can also specify more complex relation inheritance rules.JSON bodyyes

Sample Request

POST /v1/object-types
curl "https://api.warrant.dev/v1/object-types" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY" \
--data-raw \
'{
"type": "report",
"relations": {
"parent": {},
"owner": {},
"editor": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "owner"
}
]
},
"viewer": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "editor"
},
{
"type": "objectUserset",
"relation": "parent",
"userset": {
"type": "userset",
"relation": "viewer"
}
}
]
}
}
}'

Sample Response

{
"type": "report",
"relations": {
"parent": {},
"owner": {},
"editor": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "owner"
}
]
},
"viewer": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "editor"
},
{
"type": "objectUserset",
"relation": "parent",
"userset": {
"type": "userset",
"relation": "viewer"
}
}
]
}
}
}