# 获取临时 API Key

> 全部文档的索引见 [llms.txt](https://ark.volcengine.com/llms.txt)；在任一文档页面地址后追加 `.md` 可获取该页的 Markdown 版本。

`POST https://ark.cn-beijing.volcengineapi.com/?Action=GetApiKey&Version=2024-01-01`

获取临时 API Key，用于在有效期内指定推理接入点、智能体等资源的调用的鉴权

## 鉴权

本接口支持鉴权方式如下，详情请参见 [Base URL 及鉴权](/docs/base-url-and-authentication)。

* Access Key 鉴权，请在 [Access Key 管理](https://console.volcengine.com/iam/keymanage) 页面，获取 Access Key。本接口仅支持 Access Key 鉴权。

---

<span id="request-parameters"></span>
## 请求参数

### Body 参数

**DurationSeconds** `integer` `必选` | 有效期

临时 API Key 的有效期，单位为秒。

**取值范围**：`[0, 2592000]`

**ResourceIds** `string[]` `必选` | 资源 ID 列表

*ResourceType* 字段指定的资源 ID 列表。
- 当 *ResourceType* 为 `endpoint` 时，可在方舟控制台 > 推理模块获取 endpoint ID。
- 当 *ResourceType* 为 `bot` 时，可在方舟控制台 > 我的应用获取 bot ID。

**ResourceType** `string` `必选` | 资源类型

资源类型。可选值：
- `endpoint`：模型推理接入点
- `bot`：智能体
- `presetendpoint`：预置推理接入点

**ProjectName** `string` | 项目名称

项目名称。当 *ResourceType* 为 `presetendpoint` 时，本参数必填。

## 响应参数

**ApiKey** `string` | 临时 API Key

生成的临时 API Key 字符串，可在 *DurationSeconds* 指定的有效期内用于调用方舟相关资源。

**ExpiredTime** `integer` | 过期时间

临时 API Key 的过期时间，Unix 时间戳，单位为秒。


## 代码示例

## 默认

### cURL

#### Request

```bash
curl 'https://ark.cn-beijing.volcengineapi.com/?Action=GetApiKey&Version=2024-01-01' \
  -H 'Content-Type: application/json' \
  -H 'X-Date: <X-Date>' \
  -H 'X-Content-Sha256: <X-Content-Sha256>' \
  -H 'Authorization: HMAC-SHA256 Credential=<AK>/<X-Date>/cn-beijing/ark/request, SignedHeaders=content-type;host;x-content-sha256;x-date, Signature=<Signature>' \
  -d '{
  "DurationSeconds": 86400,
  "ResourceType": "endpoint",
  "ResourceIds": [
    "[\"ep-***\", \"ep-***\"]"
  ]
}
'
```

#### Response

```
{
  "ResponseMetadata": {
    "RequestId": "20250108152350029189016106C67393",
    "Action": "GetApiKey",
    "Version": "2024-01-01",
    "Service": "ark",
    "Region": "cn-beijing"
  },
  "Result": {
    "ExpiredTime": 0,
    "ApiKey": "***"
  }
}
```
