> ## 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.

# 归档凭证

> 归档一个 active 状态的 Vault 凭证。

`POST /api/v1/cloud/vaults/{vault_id}/credentials/{credential_id}/archive`

归档指定 Vault 下的 active 凭证。已归档凭证默认不会出现在凭证列表中，但可通过 `include_archived=true` 包含。

## 请求头

| 头部              | 必选 | 说明             |
| --------------- | -- | -------------- |
| `Authorization` | 是  | `Bearer <PAT>` |

## 路径参数

| 参数              | 类型     | 必选 | 说明                    |
| --------------- | ------ | -- | --------------------- |
| `vault_id`      | string | 是  | Vault ID（`vault_` 前缀） |
| `credential_id` | string | 是  | 凭证 ID（`vcred_` 前缀）    |

## 示例请求

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/vaults/vault_019e3bb940277f0db05ab74291acf6ef/credentials/vcred_019e3bb98877759e862750b495c1fce8/archive" \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

返回归档后的凭证对象。响应永远不会包含 `access_token`。

```json theme={null}
{
  "id": "vcred_019e3bb98877759e862750b495c1fce8",
  "type": "vault_credential",
  "vault_id": "vault_019e3bb940277f0db05ab74291acf6ef",
  "auth": {
    "type": "static_bearer",
    "mcp_server_url": "https://example.com/mcp-stream"
  },
  "display_name": null,
  "metadata": {
    "team": "docs"
  },
  "archived_at": "2026-05-18T15:45:35.387093Z",
  "created_at": "2026-05-18T15:34:35.387093Z",
  "updated_at": "2026-05-18T15:45:35.387093Z"
}
```

## 响应字段

| 字段             | 类型     | 说明                                   |
| -------------- | ------ | ------------------------------------ |
| `id`           | string | 凭证唯一标识符（`vcred_` 前缀）                 |
| `type`         | string | 固定为 `"vault_credential"`             |
| `vault_id`     | string | 所属 Vault 的 ID                        |
| `auth`         | object | 脱敏后的鉴权信息；不会返回密文                      |
| `display_name` | null   | 当前固定为 `null`                         |
| `metadata`     | object | 与 credential 一起存储的自定义元数据对象；省略时为 `{}` |
| `archived_at`  | string | 归档时间（ISO 8601）                       |
| `created_at`   | string | 创建时间（ISO 8601）                       |
| `updated_at`   | string | 最后更新时间（ISO 8601）                     |

## 错误码

| HTTP | type                   | 触发条件         |
| ---- | ---------------------- | ------------ |
| 401  | `authentication_error` | 缺少或无效的认证令牌   |
| 404  | `not_found_error`      | Vault 或凭证不存在 |
| 409  | `conflict_error`       | 凭证已经归档       |

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

## 相关

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