---
title: "Create prompt version"
method: POST
path: "/v1/private/prompts/versions"
tags: ["Prompts"]
---

# Create prompt version

`POST /v1/private/prompts/versions`

Create prompt version

## Request body

- CreatePromptVersionDetail
  - `name` string, required
  - `version` PromptVersionDetail, required
    - `id` string, uuid — version unique identifier, generated if absent
    - `prompt_id` string, uuid
    - `commit` string — version short unique identifier, generated if absent. it must be 8 characters long
    - `version_number` string — sequential version number in the format v<N>; null for masks
    - `template` string, required
    - `metadata` JsonNodeDetail
    - `type` 'mustache' | 'jinja2' | 'python'
    - `version_type` 'prompt_version' | 'mask' — version type discriminator; defaults to prompt_version
    - `environment` string — Deprecated: use 'environments' instead
    - `environments` string[]
    - `change_description` string
    - `tags` string[]
    - `variables` string[]
    - `template_structure` 'text' | 'chat'
    - `created_at` string, date-time
    - `created_by` string
  - `template_structure` 'text' | 'chat' — Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation.
  - `project_id` string, uuid — Project ID. Takes precedence over project_name when both are provided.
  - `project_name` string — If provided, scopes the prompt to the specified project. Ignored when project_id is provided.

## Response `200`

OK

- PromptVersionDetail
  - `id` string, uuid — version unique identifier, generated if absent
  - `prompt_id` string, uuid
  - `commit` string — version short unique identifier, generated if absent. it must be 8 characters long
  - `version_number` string — sequential version number in the format v<N>; null for masks
  - `template` string, required
  - `metadata` JsonNodeDetail
  - `type` 'mustache' | 'jinja2' | 'python'
  - `version_type` 'prompt_version' | 'mask' — version type discriminator; defaults to prompt_version
  - `environment` string — Deprecated: use 'environments' instead
  - `environments` string[]
  - `change_description` string
  - `tags` string[]
  - `variables` string[]
  - `template_structure` 'text' | 'chat'
  - `created_at` string, date-time
  - `created_by` string

## Other responses

- `400` — Bad Request
- `409` — Conflict
- `422` — Unprocessable Content

## Changes

- **2026-05-28** `f59fc1819c0c` — 2 info
  - added the new optional request property `version/environment`
  - added the optional property `environment` to the response with the `200` status
- **2026-05-27** `3953a50a6a0e` — 2 warning, 2 info
  - removed the request property `version/environment`
  - removed the optional property `environment` from the response with the `200` status
  - added the new optional request property `version/environments`
  - added the optional property `environments` to the response with the `200` status
- **2026-05-20** `a98bd55ddc1e` — 1 info
  - added the optional property `version_number` to the response with the `200` status
- **2026-05-19** `415a5d0ad31f` — 2 info
  - added the new optional request property `version/environment`
  - added the optional property `environment` to the response with the `200` status
- **2026-05-19** `f93aac27fb6e` — 9 warning, 5 info
  - removed the optional property `code` from the response with the `400` status
  - removed the optional property `code` from the response with the `409` status
  - removed the optional property `code` from the response with the `422` status
  - removed the optional property `details` from the response with the `400` status
  - …10 more

[Full history](https://skmtc.dev/comet-ml/apis/opik-rest-api/changes/v1/private/prompts/versions/post.md)

---

[API](https://skmtc.dev/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.dev/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/revisions/a835604ec403/schema)
