# Create access grant Create a new access grant to give a user, department, or role access to an entity. Creates a new access grant that gives the specified grantee access to the specified entity at the given access level. The grant is scoped to the organization. #### Path Parameters **`organization_id`** string required The unique identifier of the organization (format: `org_*`). #### Request Body **`entity_type`** string required The type of entity to grant access to. Allowed values: `knowledge_slice`, `vector_store`, `assistant`. **`entity_id`** string required The unique identifier of the entity. **`grantee_type`** string required The type of grantee receiving access. Allowed values: `user`, `department`, `role`. **`grantee_id`** string required The unique identifier of the grantee. **`access_level`** string required The level of access to grant. Allowed values: `read`, `write`, `admin`. ## Returns The newly created access grant object (HTTP 201). Request ```bash cURL curl -X POST https://api.aitronos.com/v1/organizations/org_xyz789/access/grants \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read" }' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") result = client.access_control.create_grant( organization_id="org_xyz789", entity_type="knowledge_slice", entity_id="kslice_abc123", grantee_type="user", grantee_id="usr_def456", access_level="read", ) print(result) ``` ```python Python import requests org_id = "org_xyz789" url = f"https://api.aitronos.com/v1/organizations/{org_id}/access/grants" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", } data = { "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read", } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` ```javascript JavaScript const orgId = "org_xyz789"; const response = await fetch( `https://api.aitronos.com/v1/organizations/${orgId}/access/grants`, { method: "POST", headers: { "Authorization": `Bearer ${accessToken}`, "Content-Type": "application/json", }, body: JSON.stringify({ entity_type: "knowledge_slice", entity_id: "kslice_abc123", grantee_type: "user", grantee_id: "usr_def456", access_level: "read", }), } ); const data = await response.json(); console.log(data); ``` Response ```json 201 Created { "id": "agrant_abc123def456", "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read", "granted_by": "usr_owner1", "organization_id": "org_xyz789", "created_at": "2025-06-15T10:00:00Z", "updated_at": "2025-06-15T10:00:00Z" } ``` ```json 422 Error { "success": false, "error": { "code": "VALIDATION_ERROR", "message": "The request contains invalid data.", "system_message": "Validation error", "type": "client_error", "status": 422, "details": { "field": "entity_type", "message": "entity_type must be one of {'knowledge_slice', 'vector_store', 'assistant'}" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ## Related Resources - [List Grants](/docs/api-reference/access-control/list-grants) - [Bulk Create Grants](/docs/api-reference/access-control/bulk-create-grants) - [Update Grant](/docs/api-reference/access-control/update-grant) - [Revoke Grant](/docs/api-reference/access-control/revoke-grant) - [Slice Grants](/docs/api-reference/access-control/slice-grants) - [Store Grants](/docs/api-reference/access-control/store-grants) - [Assistant Grants](/docs/api-reference/access-control/assistant-grants) - [Resolved Access](/docs/api-reference/access-control/resolved-access) - [Users with Access](/docs/api-reference/access-control/users-with-access)