# Restore prompt version

POST http://localhost:5173/api/v1/private/prompts/{promptId}/versions/{versionId}/restore

Restore a prompt version by creating a new version with the content from the specified version

Reference: https://www.comet.com/docs/opik/reference/rest-api/prompts/restore-prompt-version

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Restore prompt version
  version: endpoint_prompts.restorePromptVersion
paths:
  /v1/private/prompts/{promptId}/versions/{versionId}/restore:
    post:
      operationId: restore-prompt-version
      summary: Restore prompt version
      description: >-
        Restore a prompt version by creating a new version with the content from
        the specified version
      tags:
        - - subpackage_prompts
      parameters:
        - name: promptId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: versionId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromptVersion_Detail'
        '400':
          description: Bad Request
          content: {}
        '404':
          description: Not Found
          content: {}
components:
  schemas:
    JsonNode_Detail:
      type: object
      properties: {}
    PromptVersionDetailType:
      type: string
      enum:
        - value: mustache
        - value: jinja2
    PromptVersionDetailTemplateStructure:
      type: string
      enum:
        - value: text
        - value: chat
    PromptVersion_Detail:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: version unique identifier, generated if absent
        prompt_id:
          type: string
          format: uuid
        commit:
          type: string
          description: >-
            version short unique identifier, generated if absent. it must be 8
            characters long
        template:
          type: string
        metadata:
          $ref: '#/components/schemas/JsonNode_Detail'
        type:
          $ref: '#/components/schemas/PromptVersionDetailType'
        change_description:
          type: string
        tags:
          type: array
          items:
            type: string
        variables:
          type: array
          items:
            type: string
        template_structure:
          $ref: '#/components/schemas/PromptVersionDetailTemplateStructure'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
      required:
        - template

```

## SDK Code Examples

```python
import requests

url = "http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore"

response = requests.post(url)

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore';
const options = {method: 'POST'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
```

```java
HttpResponse<String> response = Unirest.post("http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore")
  .asString();
```

```php
<?php

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore');

echo $response->getBody();
```

```csharp
var client = new RestClient("http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/prompts/promptId/versions/versionId/restore")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```