# General Translation Platform: 创建项目 API 密钥
URL: https://generaltranslation.com/zh/docs/platform/openapi/reference/project/create-api-key.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 为所选项目创建 API 密钥。需要 project:api_keys:write 权限，且只能委派请求身份已拥有的项目权限。创建项目 API 密钥的 API 参考。

{/* 此文件由 Fumadocs 生成。请勿直接编辑。任何更改都应通过再次运行生成命令完成。 */}

## Endpoint

`POST https://api.gtx.dev/v2/projects/{projectId}/api-keys`

**Operation ID:** `createProjectApiKey`

**Tags:** `Project`

**Summary:** Create a Project API Key

Create a project API key. Requires `project:api_keys:write`; project keys cannot create other keys. If you cannot grant a selected permission, the request returns `403` without creating a key. Each successful request creates a new key. Store the returned secret securely.

Authentication: required. Send an API key in the `Authorization: Bearer <key>` header when authenticating.

### Parameters

- `projectId` (path, string, required)
- `gt-api-version` (header, "2025-01-01.v0" | "2025-11-03.v1" | "2026-02-18.v1" | "2026-03-06.v1", optional): API contract version. Defaults to the oldest supported version.

### Request body (required)

Body (`application/json`, object):
- `name` (string, required): Key name, 1–255 characters after trimming.
- `permissions` ("project:write" | "project:context:read" | "project:context:write" | "project:files:read" | "project:files:write" | "project:translations:generate" | "project:translations:enqueue"[]): Project permissions to grant. Select at least one, or omit to grant all project permissions you can delegate. You must hold every selected permission. Duplicates are ignored. Write permissions do not include Read.
- `type` ("production" | "development"): Ignored. All new keys are project-scoped API keys for any environment.

### Responses

**201**: Project API key created
Response body (`application/json`, object):
- `apiKey` (object, required)
  - `id` (string, required)
  - `name` (string, required)
  - `key` (string, required)
  - `projectId` (string, required)
  - `type` ("production", required): Compatibility field. All project API keys work in any environment.

**400**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**401**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**403**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**404**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**413**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**429**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

**500**: Request error
Response body (`application/json`, object):
- `error` (string, required)

Response body (`text/html`, string):

Complete OpenAPI 3.1 specification: https://generaltranslation.com/openapi.yaml

OpenAPI schema: [openapi.json](https://generaltranslation.com/openapi.json)

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
