Create an Object Type
Create a new object type.
Endpoint
POST /v2/object-types
Request
Body
type string
A string identifier for this object type. The type
can only be composed of lower-case alphanumeric chars and/or '-' and '_'.
relations object
The set of relationships that subjects can have on objects of this type. See Key Concepts > Object Types to learn more.
- cURL
- Go
POST /v2/object-types
curl "https://api.warrant.dev/v2/object-types" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY" \
--data-raw \
'{
"type": "report",
"relations": {
"parent": {},
"owner": {},
"editor": {
"inheritIf": "owner"
},
"viewer": {
"inheritIf": "anyOf",
"rules": [
{
"inheritIf": "editor"
},
{
"inheritIf": "viewer",
"ofType": "report",
"withRelation": "parent"
}
]
}
}
}'
POST /v2/object-types
newType, err := objecttype.Create(&warrant.ObjectTypeParams{
Type: "new-type",
Relations: map[string]interface{}{
"relation-1": struct{}{},
"relation-2": struct{}{},
},
})
if err != nil {
// handle error
}
Response
Headers
Warrant-Token string
A unique transaction identifier for this write operation. Can be cached and passed on subsequent read requests.
Body
type string
A string identifier for this new object type. The type
can only be composed of lower-case alphanumeric chars and/or '-' and '_'.
relations object
The set of relationships that subjects can have on objects of this type. See Key Concepts > Object Types to learn more.
200 OK
{
"type": "report",
"relations": {
"parent": {},
"owner": {},
"editor": {
"inheritIf": "owner"
},
"viewer": {
"inheritIf": "anyOf",
"rules": [
{
"inheritIf": "editor"
},
{
"inheritIf": "viewer",
"ofType": "report",
"withRelation": "parent"
}
]
}
}
}