---
title: "Commit a prompt version"
description: "Commits the current draft as a read-only version. No new draft is created; create a version to keep editing."
---

<a id="playground-button:docs/apis/prompts/commit-prompt-version"></a>

**POST** `https://api.respan.ai/api/prompts/{prompt_id}/commits/`

Commits the current draft as a read-only version. No new draft is created; create a version to keep editing.

## Servers

`https://api.respan.ai`: Respan API Server

<a id="request.auth"></a>

## Authentication

<a id="request.auth.Authorization"></a>

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


**Or:**

### DashboardJwt

Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.

HTTP scheme: `bearer`; format: `Dashboard JWT`.


```http
Authorization: Bearer $RESPAN_DASHBOARD_JWT
```


<a id="request.path"></a>

## Path parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.path.prompt_id"></a>`prompt_id` | `string` | Required | The unique prompt identifier. |


<a id="request"></a>

## Request body

The request body is optional.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Optional body | - |
| <a id="request.body.description"></a>`description` | `string` | Optional | Optional commit message describing the changes.<br />Example: `"Improved tone and added error handling"` |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "Optional commit message describing the changes.",
      "example": "Improved tone and added error handling"
    }
  }
}
```

</details>

<a id="response"></a>

## Responses

### 201

Committed version created.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Example: `{"id":"pv_abc123","prompt_version_id":"pv_abc123","version":3,"description":"Improved system prompt for better context handling","messages":[{"role":"system","content":"You are a helpful assistant. Context: {{context}}"}],"model":"gpt-4o","readonly":true,"is_deployed":false,"edited_by":{"id":123,"email":"user@example.com","first_name":"John","last_name":"Doe"},"created_at":"2026-02-27T10:00:00Z","updated_at":"2026-02-27T10:00:00Z"}` |
| <a id="response.body.id"></a>`id` | `string` | Optional | - |
| <a id="response.body.prompt_version_id"></a>`prompt_version_id` | `string` | Optional | - |
| <a id="response.body.version"></a>`version` | `integer` | Optional | - |
| <a id="response.body.description"></a>`description` | `string or null` | Optional | - |
| <a id="response.body.messages"></a>`messages` | `array<object>` | Optional | - |
| `messages[]` | `object` | Array item | Additional properties are allowed |
| <a id="response.body.model"></a>`model` | `string` | Optional | - |
| <a id="response.body.readonly"></a>`readonly` | `boolean` | Optional | - |
| <a id="response.body.edited_by"></a>`edited_by` | `object` | Optional | - |
| `edited_by.id` | `integer` | Optional | - |
| `edited_by.email` | `string` | Optional | - |
| `edited_by.first_name` | `string` | Optional | - |
| `edited_by.last_name` | `string` | Optional | - |
| <a id="response.body.created_at"></a>`created_at` | `string` | Optional | Format: `date-time` |
| <a id="response.body.updated_at"></a>`updated_at` | `string` | Optional | Format: `date-time` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "prompt_version_id": {
      "type": "string"
    },
    "version": {
      "type": "integer"
    },
    "description": {
      "type": "string",
      "nullable": true
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "model": {
      "type": "string"
    },
    "readonly": {
      "type": "boolean"
    },
    "edited_by": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "email": {
          "type": "string"
        },
        "first_name": {
          "type": "string"
        },
        "last_name": {
          "type": "string"
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "example": {
    "id": "pv_abc123",
    "prompt_version_id": "pv_abc123",
    "version": 3,
    "description": "Improved system prompt for better context handling",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant. Context: {{context}}"
      }
    ],
    "model": "gpt-4o",
    "readonly": true,
    "is_deployed": false,
    "edited_by": {
      "id": 123,
      "email": "user@example.com",
      "first_name": "John",
      "last_name": "Doe"
    },
    "created_at": "2026-02-27T10:00:00Z",
    "updated_at": "2026-02-27T10:00:00Z"
  }
}
```

</details>

<a id="response.error"></a>

### 400

There is no draft to commit.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "No draft version found for prompt '<prompt_id>'."
}
```


### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 404

Prompt not found

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Prompt not found"
}
```


## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Commit a prompt version",
  "operationId": "commitPromptVersion",
  "tags": [
    "Prompts"
  ],
  "description": "Commits the current draft as a read-only version. No new draft is created; create a version to keep editing.",
  "parameters": [
    {
      "name": "prompt_id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      },
      "description": "The unique prompt identifier."
    }
  ],
  "requestBody": {
    "required": false,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "description": {
              "type": "string",
              "description": "Optional commit message describing the changes.",
              "example": "Improved tone and added error handling"
            }
          }
        }
      }
    }
  },
  "responses": {
    "201": {
      "description": "Committed version created.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "prompt_version_id": {
                "type": "string"
              },
              "version": {
                "type": "integer"
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "messages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "model": {
                "type": "string"
              },
              "readonly": {
                "type": "boolean"
              },
              "edited_by": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "email": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  }
                }
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            },
            "example": {
              "id": "pv_abc123",
              "prompt_version_id": "pv_abc123",
              "version": 3,
              "description": "Improved system prompt for better context handling",
              "messages": [
                {
                  "role": "system",
                  "content": "You are a helpful assistant. Context: {{context}}"
                }
              ],
              "model": "gpt-4o",
              "readonly": true,
              "is_deployed": false,
              "edited_by": {
                "id": 123,
                "email": "user@example.com",
                "first_name": "John",
                "last_name": "Doe"
              },
              "created_at": "2026-02-27T10:00:00Z",
              "updated_at": "2026-02-27T10:00:00Z"
            }
          }
        }
      }
    },
    "400": {
      "description": "There is no draft to commit.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "No draft version found for prompt '<prompt_id>'."
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "404": {
      "description": "Prompt not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Prompt not found"
          }
        }
      }
    }
  },
  "security": [
    {
      "RespanApiKey": []
    },
    {
      "DashboardJwt": []
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "DashboardJwt": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Dashboard JWT",
      "description": "Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.",
      "x-fern-bearer": {
        "name": "dashboardJwt",
        "env": "RESPAN_DASHBOARD_JWT"
      }
    },
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
