Create a Warrant
Create a new warrant that associates an object (objectType
and objectId
) to a subject
via a relation
.
POST /v1/warrants
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
objectType | The type of object. Must be one of your system's existing object types. | JSON body | yes |
objectId | The id of the specific object. | JSON body | yes |
relation | The relation for this object to subject association. The relation must be valid as per the object type definition. | JSON body | yes |
subject | The specific subject (object, user etc.) to be associated with the object. A subject can either be a specific object (by id) or a group of objects defined by a set containing an objectType, objectId and relation. | JSON body | yes |
Request
- Curl
- Node.js
- Go
- Java
- Python
curl "https://api.warrant.dev/v1/warrants" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY" \
--data-raw \
'{
"objectType": "report",
"objectId": "23ft346",
"relation": "editor",
"subject": {
"objectType": "user",
"objectId": "15ads7823a9df7as433gk23dd"
}
}'
client
.createWarrant("report", "23ft346", "editor", { objectType: "user", objectId: "15ads7823a9df7as433gk23dd" })
.then((newWarrant) => console.log(newWarrant))
.catch((error) => console.log(error));
resp, err := client.CreateWarrant(warrant.Warrant{
ObjectType: "report",
ObjectId: "23ft346",
Relation: "editor",
Subject: warrant.Subject{
ObjectType: "role",
ObjectId: "15ads7823a9df7as433gk23dd",
},
})
if err != nil {
// handle error
}
try {
Warrant warrantToCreate = Warrant
.newWarrant("report", "23ft346", "editor", "user", "15ads7823a9df7as433gk23dd");
client.createWarrant(warrantToCreate);
} catch (WarrantException e) {
// Handle error
}
client.create_warrant(object_type="report", object_id="23ft346", relation="editor", subject_type="user", subject_id="15ads7823a9df7as433gk23dd")
Response
{
"objectType": "report",
"objectId": "23ft346",
"relation": "editor",
"subject": {
"objectType": "user",
"objectId": "15ads7823a9df7as433gk23dd"
}
}