# 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 Key。需要 project:api_keys:write 权限；项目密钥不能用于创建其他密钥。如果你无法授予所选权限，该请求将返回 403，且不会创建密钥。每次成功请求都会创建一个新密钥。请妥善保存返回的密钥值。创建项目 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**: The request is malformed or failed validation.
Response body (`application/json`, object):
- `error` (string, required)

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

**401**: Authentication is missing or invalid.
Response body (`application/json`, object):
- `error` (string, required)

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

**403**: The caller is authenticated but not allowed to perform this operation or access the requested resource.
Response body (`application/json`, object):
- `error` (string, required)

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

**404**: The requested resource was not found.
Response body (`application/json`, object):
- `error` (string, required)

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

**413**: The request, or the data it would return, exceeds a size or item limit.
Response body (`application/json`, object):
- `error` (string, required)

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

**415**: The request body's Content-Type is missing or not supported. Send the body as application/json.
Response body (`application/json`, object):
- `error` (string, required)

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

**429**: Too many requests. The rate limit was exceeded.
Response body (`application/json`, object):
- `error` (string, required)

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

**500**: An unexpected server error occurred.
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.
