> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ariacompute.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建 ROUTER API 密钥接口

> 为咏唱引擎 ROUTER 创建一个新的 API 密钥。一次性返回完整密钥值，请妥善保管。可选的作用域用于限制权限。

使用创建密钥接口为访问咏唱引擎 ROUTER 生成一个新的 API 密钥。你可以指定一个便于识别的名称与一组可选的作用域。响应包含完整密钥值，且只返回这一次。你必须妥善保管；之后无法再次获取。

任何已认证调用者都可以创建密钥，但所生成密钥的权限受调用者自身作用域的约束。

## 接口

```http theme={null}
POST /v1/router/keys
```

## 认证

使用会话 Cookie 认证，或携带 `Authorization: Bearer <api-key>`。

## 请求体

<ParamField body="name" type="string" required>
  新密钥的便于识别的标签。
</ParamField>

<ParamField body="scopes" type="array">
  要授予的权限作用域列表。省略则继承默认。
</ParamField>

## 响应

<ResponseField name="id" type="string">
  唯一的密钥标识符。
</ResponseField>

<ResponseField name="name" type="string">
  分配给密钥的名称。
</ResponseField>

<ResponseField name="key" type="string">
  完整的密钥值。仅显示一次。
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://router.example.com/v1/router/keys" \
    -H "Authorization: Bearer <api-key>" \
    -H "Content-Type: application/json" \
    -d '{"name":"Production pipeline","scopes":["read","write"]}'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "key_01hv8",
    "name": "Production pipeline",
    "key": "aria_9f3a4e...full-secret"
  }
  ```
</ResponseExample>
