# General Translation Platform: Upsert 自定义提示词
URL: https://generaltranslation.com/zh/docs/platform/openapi/reference/context-management/upsert-custom-prompts.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 在单个原子批次中创建或更新 1–100 个提示词（{ customPrompts: [...] }），每个提示词按名称和区域设置进行匹配。未提供的字段将保留其已存储的值。null 会清空可为空的字段或移除映射中的条目；其他字段不接受 null。在批量操作和导入中，各项按自然键与已存储的项匹配，未包含在批次中的已存储项保持不变，也不会删除任何其他内容。空白的 CSV 单元格视为未提供。若同一批次中出现重复的名称和区域设置组合，整个批次将被拒绝（400）。需要 org:context:write 权限。Upsert 自定义提示词的 API 参考。

{/* 此文件由 Fumadocs 生成。请勿直接编辑此文件。如需修改，请重新运行生成命令。 */}

## Endpoint

`POST https://api.gtx.dev/v2/context-groups/{groupId}/custom-prompts`

**Operation ID:** `upsertContextCustomPrompts`

**Tags:** `Context Management`

**Summary:** Upsert custom prompts

Creates or updates 1–100 prompts (`{ customPrompts: [...] }`), each matched by name and locale, in one atomic batch. An absent field keeps its stored value. `null` clears a nullable field or removes a map entry; other fields reject `null`. In batches and imports, items match stored items by natural key, stored items absent from the batch are untouched, and nothing else is deleted. A blank CSV cell counts as absent. Repeating a name and locale within one batch rejects the whole batch (400). Requires `org:context:write`.

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

### Parameters

- `groupId` (path, string, required): Context group ID.
- `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):
- `customPrompts` (object[], required): 1–100 prompts, matched by name and locale; a name and locale may appear once.
  - `name` (string, required)
  - `locale` (string | null, required): Locale the prompt applies to; null applies it to every locale.
  - `value` (string, required)
  - `description` (string | null): null clears the description.

### Responses

**200**: Custom prompts written
Response body (`application/json`, object):
- `committed` (true, required)
- `counts` (object, required)
  - `created` (integer, required)
  - `updated` (integer, required)
  - `unchanged` (integer, required)

**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.
