Create grant
POST /application/v1/workers/{worker_id}/grants
Record access to an organization-owned database, knowledge base, file, media library, workflow, script, agent or another Worker, to models (id *, read only), or to a whole service (search, browser, ticket, crm, canvas, cut, studio, ontology, workspace: id *, read_write; feedback: read), or to full authority (organization: id *, read_write), which excludes every other grant. The types are the ones a service agent can bind. The retired files type is refused; grant one file by its file-… id. A Worker’s platform calls reach only what its grants name, and nothing with no grant; an agent grant at read_write is what lets it issue that agent’s customer grant codes. Each resource and optional alias must be unique within this Worker. Foreign and missing resources both return RESOURCE_NOT_FOUND (404); an unavailable resource service returns PROVIDER_CAPACITY (503, retryable).
Support: supported
Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| worker_id | path | string | true | Worker ID (wkr_…). |
Request body (application/json)
Required: true
| Name | Type | Description |
|---|---|---|
| resource | object | Resource to grant. Each (type, id) may be granted once per Worker; duplicates return GRANT_CONFLICT (409). |
| resource.type | string | Resource type. |
| resource.id | string | ID of the granted resource in your organization; * for models and whole-service types. |
| alias | string | Optional name, unique within this Worker. Available for reuse after the grant is deleted. |
| access | string | Access level; models accepts read only. |
{ "type": "object", "required": [ "resource", "access" ], "properties": { "resource": { "type": "object", "description": "Resource to grant. Each (type, id) may be granted once per Worker; duplicates return GRANT_CONFLICT (409).", "required": [ "type", "id" ], "properties": { "type": { "type": "string", "description": "Resource type.", "enum": [ "database", "knowledge", "models", "file", "media_library", "workflow", "script", "agent", "application", "search", "browser", "ticket", "crm", "canvas", "cut", "studio", "ontology", "workspace", "feedback", "organization" ], "x-enum-descriptions": { "database": "A database.", "knowledge": "A knowledge base.", "models": "Model access; id must be * and access must be read.", "file": "One file of your organization, by its file-… id; read only; takes no alias.", "media_library": "One media library; read or read_write; takes no alias.", "workflow": "One workflow, by <namespace>/<name>; access must be read, which lets the Worker invoke it; takes no alias.", "script": "One script, by <namespace>/<name>; access must be read (invoke); takes no alias.", "agent": "One agent of your organization, by its agent_… id; takes no alias. read_write lets the Worker let people use it: issue its customer grant codes (POST /customer/v1/grant_codes with resources agent:<id>:…) and manage its customers (revoke_tokens, block); it never changes the agent or reaches its sessions.", "application": "Another Worker of the same organization, by its wkr_… id; read or read_write; never itself; takes no alias.", "search": "The whole search service; id must be *, access read_write.", "browser": "The whole browser service; id *, read_write.", "ticket": "The whole ticket service; id *, read_write.", "crm": "The whole CRM service; id *, read_write.", "canvas": "The whole canvas service; id *, read_write.", "cut": "The whole cut service; id *, read_write.", "studio": "The whole studio service; id *, read_write.", "ontology": "The whole ontology service; id *, read_write.", "workspace": "Development units; id *, read_write.", "feedback": "Organization feedback, read only; id *, access read.", "organization": "Full authority: the whole of your organization's access, as an explicit grant; id must be *, access read_write, takes no alias. Exclusive: it cannot be created while the Worker holds any other grant, and no other grant can be created beside it (GRANT_CONFLICT, 409)." }, "example": "database" }, "id": { "type": "string", "description": "ID of the granted resource in your organization; * for models and whole-service types.", "minLength": 1, "example": "db_01example" } } }, "alias": { "type": "string", "description": "Optional name, unique within this Worker. Available for reuse after the grant is deleted.", "pattern": "^[a-z][a-z0-9_]{0,31}$", "example": "content" }, "access": { "type": "string", "description": "Access level; models accepts read only.", "enum": [ "read", "read_write" ], "x-enum-descriptions": { "read": "Read only.", "read_write": "Read and write." }, "example": "read" } }}Response
HTTP 200
Success
application/json
| Name | Type | Description |
|---|---|---|
| id | string | Grant ID, prefixed grt_. |
| worker_id | string | Owning Worker. |
| resource | object | Granted resource. |
| resource.type | string | Resource type. |
| resource.id | string | ID of the granted resource; * for models and whole-service types. |
| alias | string | Optional name, unique within this Worker. Conflicts return GRANT_ALIAS_CONFLICT (409). |
| access | string | Access level; models accepts read only. |
| created_on | string | When the grant was created. |