# Restore a prompt to a previous version

Restore a prompt to a previous version. Creates a new version with the same config data as the specified version.

> Page: https://langwatch.ai/docs/api-reference/prompts/action-restore
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/prompts/action-restore.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`POST https://app.langwatch.ai/api/v1/prompts/{id}/versions/{versionId}/restore`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Parameters

### id (path, required)

```json
{"type":"string"}
```

### versionId (path, required)

```json
{"type":"string"}
```

## Request example

```bash
curl --request POST \
  --url 'https://app.langwatch.ai/api/v1/prompts/<id>/versions/<versionId>/restore' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY"
```

## Responses

### 200

Success

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "id": {"type":"string"},
    "handle": {"type":["string","null"]},
    "scope": {"type":"string","enum":["PROJECT","ORGANIZATION"]},
    "name": {"type":"string"},
    "updatedAt": {"type":"string","format":"date-time"},
    "projectId": {"type":"string"},
    "organizationId": {"type":"string"},
    "versionId": {"type":"string"},
    "authorId": {"type":["string","null"]},
    "version": {"type":"number"},
    "createdAt": {"type":"string","format":"date-time"},
    "commitMessage": {"type":["string","null"]},
    "prompt": {"type":"string"},
    "messages": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "role": {"type":"string","enum":["user","assistant","system"]},
          "content": {"type":"string"}
        },
        "required": ["role","content"],
        "additionalProperties": false
      }
    },
    "inputs": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "identifier": {"type":"string","minLength":1},
          "type": {
            "type": "string",
            "enum": [
              "str",
              "float",
              "bool",
              "image",
              "file",
              "list",
              "list[str]",
              "list[float]",
              "list[int]",
              "list[bool]",
              "dict",
              "chat_messages"
            ]
          }
        },
        "required": ["identifier","type"],
        "additionalProperties": false
      }
    },
    "outputs": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "identifier": {"type":"string","minLength":1},
          "type": {"type":"string","enum":["str","float","bool","json_schema"]},
          "json_schema": {
            "type": "object",
            "required": ["type"],
            "additionalProperties": {},
            "properties": {"type":{"type":"string","minLength":1}}
          }
        },
        "required": ["identifier","type"],
        "additionalProperties": false
      }
    },
    "model": {"type":"string","minLength":1},
    "temperature": {"type":"number"},
    "maxTokens": {"type":"number"},
    "demonstrations": {
      "type": "object",
      "properties": {
        "id": {"type":"string"},
        "name": {"type":"string"},
        "inline": {
          "type": "object",
          "properties": {
            "records": {
              "type": "object",
              "propertyNames": {"type":"string"},
              "additionalProperties": {"type":"array","items":{}}
            },
            "columnTypes": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {"type":"string"},
                  "name": {"type":"string"},
                  "type": {
                    "type": "string",
                    "enum": [
                      "string",
                      "boolean",
                      "number",
                      "date",
                      "list",
                      "json",
                      "spans",
                      "rag_contexts",
                      "chat_messages",
                      "annotations",
                      "evaluations",
                      "image",
                      "file"
                    ]
                  }
                },
                "required": ["name","type"],
                "additionalProperties": false
              }
            }
          },
          "required": ["records","columnTypes"],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "promptingTechnique": {
      "type": "object",
      "properties": {
        "type": {"type":"string","enum":["few_shot","in_context","chain_of_thought"]},
        "demonstrations": {
          "type": "object",
          "properties": {
            "id": {"type":"string"},
            "name": {"type":"string"},
            "inline": {
              "type": "object",
              "properties": {
                "records": {
                  "type": "object",
                  "propertyNames": {"type":"string"},
                  "additionalProperties": {"type":"array","items":{}}
                },
                "columnTypes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {"type":"string"},
                      "name": {"type":"string"},
                      "type": {
                        "type": "string",
                        "enum": [
                          "string",
                          "boolean",
                          "number",
                          "date",
                          "list",
                          "json",
                          "spans",
                          "rag_contexts",
                          "chat_messages",
                          "annotations",
                          "evaluations",
                          "image",
                          "file"
                        ]
                      }
                    },
                    "required": ["name","type"],
                    "additionalProperties": false
                  }
                }
              },
              "required": ["records","columnTypes"],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        }
      },
      "required": ["type"],
      "additionalProperties": false
    },
    "responseFormat": {
      "type": "object",
      "properties": {
        "type": {"type":"string","enum":["json_schema"]},
        "json_schema": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "name": {"type":"string"},
                "schema": {"type":"object","additionalProperties":{}}
              },
              "required": ["name","schema"],
              "additionalProperties": false
            },
            {"type":"null"}
          ]
        }
      },
      "required": ["type","json_schema"],
      "additionalProperties": false
    },
    "tags": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {"name":{"type":"string"},"versionId":{"type":"string"}},
        "required": ["name","versionId"],
        "additionalProperties": false
      }
    },
    "parameters": {
      "default": {},
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {
        "anyOf": [
          {"type":"string"},
          {"type":"number"},
          {"type":"boolean"},
          {"type":"null"},
          {"type":"array","items":{"$recursive":"JsonValue"}},
          {
            "type": "object",
            "propertyNames": {"type":"string"},
            "additionalProperties": {"$recursive":"JsonValue"}
          }
        ]
      }
    },
    "platformUrl": {"type":"string"}
  },
  "required": [
    "id",
    "handle",
    "scope",
    "name",
    "updatedAt",
    "projectId",
    "organizationId",
    "versionId",
    "version",
    "createdAt",
    "prompt",
    "messages",
    "inputs",
    "outputs",
    "model",
    "tags",
    "parameters",
    "platformUrl"
  ],
  "additionalProperties": false
}
```

### 400

Bad Request

#### application/json

Schema:

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

### 401

Unauthorized

#### application/json

Schema:

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

### 404

Prompt or version not found

#### application/json

Schema:

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

### 422

Unprocessable Entity

#### application/json

Schema:

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

### 500

Internal Server Error

#### application/json

Schema:

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

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
