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

# 创建 Vault

> 创建一个新的 Vault 资源，用于安全存储 MCP 服务器的访问凭证。

`POST /api/v1/cloud/vaults`

创建一个新的 Vault 资源。Vault 用于安全存储 MCP 服务器的访问凭证。创建 Vault 后，通过[创建凭证](/zh/cloud-agents/api/vaults/create-credential)接口添加凭证。

## 请求头

| 头部              | 必选 | 说明                 |
| --------------- | -- | ------------------ |
| `Authorization` | 是  | `Bearer <PAT>`     |
| `Content-Type`  | 是  | `application/json` |

## 请求体

| 字段             | 类型     | 必选 | 说明                   |
| -------------- | ------ | -- | -------------------- |
| `display_name` | string | 是  | Vault 显示名称，最长 255 字符 |
| `metadata`     | object | 否  | 自定义元数据               |

## 示例请求

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/vaults" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "my-mcp-vault",
    "metadata": {"team": "docs"}
  }'
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "id": "vault_019e3bb940277f0db05ab74291acf6ef",
  "type": "vault",
  "display_name": "my-mcp-vault",
  "metadata": {
    "team": "docs"
  },
  "credentials": [],
  "archived_at": null,
  "created_at": "2026-05-18T15:34:16.874877Z",
  "updated_at": "2026-05-18T15:34:16.874877Z"
}
```

## 响应字段

| 字段             | 类型             | 说明                       |
| -------------- | -------------- | ------------------------ |
| `id`           | string         | Vault 唯一标识符（`vault_` 前缀） |
| `type`         | string         | 资源类型，固定为 `"vault"`       |
| `display_name` | string         | Vault 显示名称               |
| `metadata`     | object         | 自定义元数据                   |
| `credentials`  | array          | 普通创建请求返回空数组              |
| `archived_at`  | string \| null | 归档时间；active 时为 `null`    |
| `created_at`   | string         | 创建时间（ISO 8601）           |
| `updated_at`   | string         | 最后更新时间（ISO 8601）         |

## 错误码

| HTTP | type                    | 触发条件                                                           |
| ---- | ----------------------- | -------------------------------------------------------------- |
| 400  | `invalid_request_error` | 缺少或非法 `display_name`、`metadata` 非法，或 inline credentials 超过数量限制 |
| 401  | `authentication_error`  | 缺少或无效的认证令牌                                                     |

完整错误信封说明详见 [错误参考](/zh/cloud-agents/api/conventions/errors)。

## 相关

<CardGroup cols={2}>
  <Card title="Vaults" icon="key" href="/zh/cloud-agents/vaults">
    安全地存储凭据并注入到 Agent Session。
  </Card>
</CardGroup>
