Skip to main content

Creating Object Types

Now that your account is set up and you have an API key, you can start creating object types.

Creating an Object Type

Here's an example of an object type for a store object in an e-commerce application:

{
"type": "store",
"relations": {
"owner": {},
"creator": {},
"editor": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "owner"
}
]
},
"viewer": {
"type": "anyOf",
"rules": [
{
"type": "userset",
"relation": "editor"
}
]
}
}
}

The json above defines an object type called store with the following direct and inherited relations:

  • A store can have an owner (direct)
  • A store can have a creator (direct)
  • A store can have an editor (direct)
  • An owner of a store is also an editor of that store (inherited)
  • A store can have a viewer (direct)
  • An editor of a store is also a viewer of that store (inherited)

Object types can be created directly in the dashboard or via a POST /v1/object-types request:

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