# 创建授权 (/docs/api/native/application/createGrant)



`POST /application/v1/workers/{worker_id}/grants`

Let this Worker's platform token access one of your databases, folders or knowledge bases.

**支持状态: supported**

## 参数 [#参数]

| 名称         | 位置   | 类型     | 必填   | 说明                  |
| ---------- | ---- | ------ | ---- | ------------------- |
| worker\_id | path | string | true | Worker ID (wkr\_…). |

## 请求体 (application/json) [#请求体-applicationjson]

必填: true

| 名称            | 类型     | 说明                           |
| ------------- | ------ | ---------------------------- |
| resource      | object | Resource to grant.           |
| resource.type | string | Resource type.               |
| resource.id   | string | Resource ID in your account. |
| access        | string | Access level.                |

```json
{
  "type": "object",
  "required": [
    "resource",
    "access"
  ],
  "properties": {
    "resource": {
      "type": "object",
      "description": "Resource to grant.",
      "required": [
        "type",
        "id"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "Resource type.",
          "enum": [
            "database",
            "folder",
            "knowledge"
          ],
          "x-enum-descriptions": {
            "database": "A database.",
            "folder": "A file folder.",
            "knowledge": "A knowledge base."
          },
          "example": "database"
        },
        "id": {
          "type": "string",
          "description": "Resource ID in your account.",
          "example": "db_01example"
        }
      }
    },
    "access": {
      "type": "string",
      "description": "Access level.",
      "enum": [
        "read",
        "read_write"
      ],
      "x-enum-descriptions": {
        "read": "Read only.",
        "read_write": "Read and write."
      },
      "example": "read"
    }
  }
}
```

## 响应 [#响应]

### HTTP 200 [#http-200]

Success

**application/json**

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| id | string | Grant ID, prefixed grt_. |
| worker_id | string | Owning Worker. |
| resource | object | Granted resource. |
| resource.type | string | Resource type. |
| resource.id | string | Resource ID. |
| access | string | Access level. |
| created_on | string | When the grant was created. |
