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

# 创建 AceDataCloud 平台 API 凭证

> Platform 集成指南 - Ace Data Cloud

为一个 Application 创建业务 API 凭证。创建响应可能包含可直接调用 `https://api.acedata.cloud/**` 的 Token，或 Proxy 类型凭证的用户名/密码；必须按秘密处理。

## 准备工作

1. 创建 [Account Token](https://platform.acedata.cloud/documents/platform-token)。
2. 从[Application 列表](https://platform.acedata.cloud/documents/platform-application-list)取得本人拥有的 `application_id`。

```shell theme={null}
export PLATFORM_TOKEN='你的账户令牌'
export APPLICATION_ID='你的 Application ID'
```

## 接口概览

| 项 | 内容 |
| - | - |
| 方法 | `POST` |
| URL | `https://platform.acedata.cloud/api/v1/credentials/` |
| 鉴权 | Account Token，OAuth token 需 `credentials:write` |
| Body | JSON |

## 请求体

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `application_id` | UUID | 是 | 目标 Application |
| `name` | string | 否 | 凭证显示名 |
| `limited_amount` | number / null | 否 | 单凭证用量上限；`null` 表示不设独立上限 |
| `expired_at` | datetime / null | 否 | ISO 8601 过期时间 |
| `allowed_api_ids` | UUID\[] / null | 否 | 仅允许调用这些 API；空数组会规范化为不限制 |
| `host` | string | 否 | 凭证 host 信息 |
| `for_user_id` | string | 否 | Application 所有者为其他用户签发授权凭证时使用 |
| `tags` / `metadata` | array / object | 否 | 自定义扩展数据 |

```shell theme={null}
curl -X POST 'https://platform.acedata.cloud/api/v1/credentials/' \
  -H "Authorization: Bearer ${PLATFORM_TOKEN}" \
  -H 'Content-Type: application/json' \
  -d "{\"application_id\":\"${APPLICATION_ID}\",\"name\":\"production\",\"limited_amount\":50}"
```

## 响应说明

成功返回 `201` 和 Credential 对象：

* API/Agent 类型服务通常返回 `type=Token` 和 `token`；
* Proxy 类型服务通常返回 `type=Identity` 和 `username` / `password`，且一个 Proxy Application 只允许一枚凭证；
* `id`、`user_id`、`creator_id`、`used_amount` 和时间字段由服务端生成。

当前列表和详情接口也会返回凭证明文，但客户端不应依赖这个历史行为。创建后立即保存，避免把响应写进日志；未来接口可能改为脱敏返回。

## 错误处理

* `400`：字段格式错误、未知 `allowed_api_ids`、Proxy Application 已有凭证或其他创建约束。
* `401`：Account Token 无效。
* `403/404`：无权访问目标 Application，或 Application/授权用户不存在。

## 下一步

* [获取 API 凭证列表](https://platform.acedata.cloud/documents/platform-credential-list)
* [轮换 API 凭证](https://platform.acedata.cloud/documents/platform-credential-rotate)
* [删除 API 凭证](https://platform.acedata.cloud/documents/platform-credential-delete)
* [查看调用记录](https://platform.acedata.cloud/documents/platform-usage-list)


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