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

# 删除密钥

> 删除一个密钥；引用它的 App 之后的运行会因缺少环境项而失败。

## 端点

```
DELETE https://api-datahub.bazhuayu.com/v1/secrets/{name}
```

认证：需要 API Key（`Authorization: Bearer <API Key>`）。

删除后，引用该名称的 App 在下发环境项时会以 `upstream-env-missing` 失败。删除前请先确认没有 App 仍在引用它。

## 请求

### 路径参数

<ParamField path="name" type="string" required>
  密钥名称。
</ParamField>

### 示例请求

```bash theme={null}
curl -X DELETE \
  -H "Authorization: Bearer $BAZHUAYU_API_KEY" \
  "https://api-datahub.bazhuayu.com/v1/secrets/EXAMPLE_API_KEY"
```

## 响应

### 200 成功

```json theme={null}
{
  "data": {
    "name": "EXAMPLE_API_KEY",
    "status": "deleted"
  }
}
```

响应包在 `data` 字段中，其内容如下。

<ResponseField name="name" type="string">
  已删除的名称。
</ResponseField>

<ResponseField name="status" type="string">
  固定为 `deleted`。
</ResponseField>

### 错误

| HTTP | `code` | `category` | 说明 |
| - | - | - | - |
| 401 | `unauthorized` | `forbidden` | 缺少或无效的 API Key。 |
| 404 | `secret-not-found` | `not_found` | 该名称的密钥不存在。 |

错误响应统一为 `{"error": {code, category, message, retryable}}`，见<a href="/docs/zh/datahub/api/reference/introduction#错误" target="_blank" rel="noopener noreferrer">错误</a>。

## 客户端库

Python 与 JavaScript SDK 暂未封装此端点，请直接调用 REST。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.