API ReferencePermissions
Grant Permission
Create a new permission tuple to grant a subject a specific relation on a resource.
Endpoint
POST /v1/permissionsBase URL: https://api-id.avnology.net
Authentication: API Key or OAuth token with admin:permissions:write scope
Request
curl -X POST https://api-id.avnology.net/v1/permissions \
-H
| Field | Type | Required | Description |
|---|---|---|---|
namespace | string | Yes | Resource type |
object | string | Yes | Resource ID |
relation | string | Yes | Relation to grant |
subject | string | Yes | Subject to grant to |
Response
Success (201 Created)
{
"namespace": "organizations",
"object": "org_7a2b3c4d",
"relation": "admin",
"subject": "identities:usr_7b2c3d4e"
}Errors
| Status | Code | Description |
|---|---|---|
| 400 | AVNOLOGY_AUTH_902 | Invalid tuple format |
| 409 | AVNOLOGY_AUTH_903 | Tuple already exists |
Code Examples
JavaScript (fetch)
async function grantPermission(apiKey, namespace, object, relation, subject) {
return fetch('https://api-id.avnology.net/v1/permissions', {
method: 'POST',
headers: { 'Authorization': `Bearer ${apiKey}`,
Python (httpx)
import httpx
def grant_permission(api_key: str, namespace: str, object_id: str, relation: str, subject: str) -> dict:
return httpx.post("https://api-id.avnology.net/v1/permissions",
Go (net/http)
func grantPermission(ctx context.Context, apiKey, ns, obj, rel, sub string) error {
Related
- Check Permission -- verify the granted permission
- Revoke Permission -- remove a permission
- SDK:
client.permissions.grant({ namespace, object, relation, subject })(TypeScript)