# Bulk create access grants Create multiple access grants for the same entity in a single request. Creates multiple access grants at once for the same entity. Each grant in the `grants` array specifies a different grantee and access level. This is more efficient than creating grants one at a time. #### 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. **`grants`** array required An array of grant entries (at least one). Each entry contains: - `grantee_type` (string, required) — The type of grantee. Allowed values: `user`, `department`, `role`. - `grantee_id` (string, required) — The unique identifier of the grantee. - `access_level` (string, required) — The level of access. Allowed values: `read`, `write`, `admin`. ## Returns An array of the newly created access grant objects (HTTP 201). Request ```bash cURL curl -X POST https://api.aitronos.com/v1/organizations/org_xyz789/access/grants/bulk \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grants": [ { "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read" }, { "grantee_type": "department", "grantee_id": "dept_ghi789", "access_level": "write" } ] }' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") result = client.access_control.bulk_create_grants( organization_id="org_xyz789", entity_type="knowledge_slice", entity_id="kslice_abc123", grants=[ { "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read", }, { "grantee_type": "department", "grantee_id": "dept_ghi789", "access_level": "write", }, ], ) print(result) ``` ```python Python import requests org_id = "org_xyz789" url = f"https://api.aitronos.com/v1/organizations/{org_id}/access/grants/bulk" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", } data = { "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grants": [ { "grantee_type": "user", "grantee_id": "usr_def456", "access_level": "read", }, { "grantee_type": "department", "grantee_id": "dept_ghi789", "access_level": "write", }, ], } 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/bulk`, { method: "POST", headers: { "Authorization": `Bearer ${accessToken}`, "Content-Type": "application/json", }, body: JSON.stringify({ entity_type: "knowledge_slice", entity_id: "kslice_abc123", grants: [ { grantee_type: "user", grantee_id: "usr_def456", access_level: "read", }, { grantee_type: "department", grantee_id: "dept_ghi789", access_level: "write", }, ], }), } ); 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" }, { "id": "agrant_ghi789jkl012", "entity_type": "knowledge_slice", "entity_id": "kslice_abc123", "grantee_type": "department", "grantee_id": "dept_ghi789", "access_level": "write", "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": "grants", "message": "At least one grant entry is required" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ## Related Resources - [List Grants](/docs/api-reference/access-control/list-grants) - [Create Grant](/docs/api-reference/access-control/create-grant) - [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)