> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.lumenia.net/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.lumenia.net/_mcp/server.

# Create template version

POST https://app.lumenia.net/api/v1/prompt-templates/{templateId}/versions
Content-Type: application/json

Create a draft version by copying an existing version.

Reference: https://docs.lumenia.net/api-reference/prompt-template-versions/create-template-version

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <API_KEY>`, where `API_KEY` is your API key.

## Request

### Path parameters

- `templateId` (string, required) — Template to version.

### Body (application/json)

This endpoint expects an object.

- `sourceVersionId` (string, optional) — The version to duplicate. May reference a published or an archived version of this template. Omit to duplicate the latest published version; required while the template has nothing published yet.

## Response

### 201

The new draft version.

- `version` (V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersion, required) — The new draft, in full detail. Its content is a copy of the source version.

## Errors

### 400 Bad Request Error

sourceVersionId references a draft, or the template has no published version and no sourceVersionId was sent

- `any`

### 403 Forbidden Error

The API key is missing or invalid.

- `message` (string, optional)

### 404 Not Found Error

Template or source version not found

- `any`

### 409 Conflict Error

The template already has a draft version. The response carries its id.

- `error` (string, optional) — What went wrong.
- `draftVersionId` (string, optional) — The id of the existing draft — edit or publish it instead of creating another.

### 500 Internal Server Error

Internal Server Error

- `any`

## Types

### V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersion

The new draft, in full detail. Its content is a copy of the source version.

- `id` (string, optional) — The sole identifier for the version.
- `templateId` (string, optional) — The owning template id.
- `version` (integer, optional) — The version number, assigned automatically.
- `status` (enum, optional) — The lifecycle status. Always draft on creation.
  - Allowed values: `draft`, `published`, `archived`
- `publishedAt` (string, optional, nullable) — When the version was published, null while a draft.
- `archivedAt` (string, optional, nullable) — When the version was archived, null before that.
- `createdAt` (string, optional) — ISO 8601 timestamp of when the version was created.
- `prompt` (string, optional) — The system prompt, copied from the source version.
- `firstMessage` (string, optional, nullable) — The call greeting (voice templates only, null otherwise).
- `variables` (list of V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItems, optional) — The variable definitions, copied from the source version.
- `tools` (list of V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionToolsItems, optional) — The partner tools this version references, copied from the source version.

### V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItems

- `key` (string, optional) — The placeholder name as it appears in the prompt.
- `description` (string, optional, nullable) — What the variable holds.
- `type` (string, optional) — The value type: string, number, or boolean.
- `required` (boolean, optional) — Whether a value must be supplied at assignment time.
- `defaultValue` (V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItemsDefaultValue, optional, nullable) — The value used when none is supplied.
- `validation` (V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItemsValidation, optional, nullable) — Validation rules for supplied values (enum, pattern, min, max), or null.

### V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionToolsItems

- `id` (string, optional) — The tool id.
- `name` (string, optional) — The tool name.

### V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItemsDefaultValue

The value used when none is supplied.

### V1PromptTemplatesTemplateIdVersionsPostResponsesContentApplicationJsonSchemaVersionVariablesItemsValidation

Validation rules for supplied values (enum, pattern, min, max), or null.

## Examples

### Duplicate the latest published version

**Request**

```json
{}
```

**Response**

```json
{
  "version": {
    "id": "e5f6a7b8-9102-4d4e-bf50-6b7c8d9e0f1a",
    "templateId": "a1b2c3d4-5e6f-4a0b-8c1d-2e3f4a5b6c7d",
    "version": 3,
    "status": "draft",
    "publishedAt": null,
    "archivedAt": null,
    "createdAt": "2026-07-10T09:00:00.000Z",
    "prompt": "You are the receptionist of {{company}}.",
    "firstMessage": "Thank you for calling {{company}}!",
    "variables": [
      {
        "key": "company",
        "description": "The clinic name",
        "type": "string",
        "required": true,
        "defaultValue": null,
        "validation": null
      }
    ],
    "tools": [
      {
        "id": "b2c3d4e5-6f70-4a1b-8c2d-3e4f5a6b7c8d",
        "name": "get_order_status"
      }
    ]
  }
}
```

**SDK Code**

```python Duplicate the latest published version
import requests

url = "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions"

payload = {}
headers = {
    "Authorization": "Bearer <API_KEY>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Duplicate the latest published version
const url = 'https://app.lumenia.net/api/v1/prompt-templates/templateId/versions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <API_KEY>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go Duplicate the latest published version
package main

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

func main() {

	url := "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions"

	payload := strings.NewReader("{}")

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

	req.Header.Add("Authorization", "Bearer <API_KEY>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

```ruby Duplicate the latest published version
require 'uri'
require 'net/http'

url = URI("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <API_KEY>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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

```java Duplicate the latest published version
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")
  .header("Authorization", "Bearer <API_KEY>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php Duplicate the latest published version
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.lumenia.net/api/v1/prompt-templates/templateId/versions', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <API_KEY>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Duplicate the latest published version
using RestSharp;

var client = new RestClient("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <API_KEY>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Duplicate the latest published version
import Foundation

let headers = [
  "Authorization": "Bearer <API_KEY>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```

### Duplicate a specific published or archived version

**Request**

```json
{
  "sourceVersionId": "c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e"
}
```

**Response**

```json
{
  "version": {
    "id": "e5f6a7b8-9102-4d4e-bf50-6b7c8d9e0f1a",
    "templateId": "a1b2c3d4-5e6f-4a0b-8c1d-2e3f4a5b6c7d",
    "version": 3,
    "status": "draft",
    "publishedAt": null,
    "archivedAt": null,
    "createdAt": "2026-07-10T09:00:00.000Z",
    "prompt": "You are the receptionist of {{company}}.",
    "firstMessage": "Thank you for calling {{company}}!",
    "variables": [
      {
        "key": "company",
        "description": "The clinic name",
        "type": "string",
        "required": true,
        "defaultValue": null,
        "validation": null
      }
    ],
    "tools": [
      {
        "id": "b2c3d4e5-6f70-4a1b-8c2d-3e4f5a6b7c8d",
        "name": "get_order_status"
      }
    ]
  }
}
```

**SDK Code**

```python Duplicate a specific published or archived version
import requests

url = "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions"

payload = { "sourceVersionId": "c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e" }
headers = {
    "Authorization": "Bearer <API_KEY>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Duplicate a specific published or archived version
const url = 'https://app.lumenia.net/api/v1/prompt-templates/templateId/versions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <API_KEY>', 'Content-Type': 'application/json'},
  body: '{"sourceVersionId":"c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e"}'
};

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

```go Duplicate a specific published or archived version
package main

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

func main() {

	url := "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions"

	payload := strings.NewReader("{\n  \"sourceVersionId\": \"c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e\"\n}")

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

	req.Header.Add("Authorization", "Bearer <API_KEY>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

```ruby Duplicate a specific published or archived version
require 'uri'
require 'net/http'

url = URI("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <API_KEY>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"sourceVersionId\": \"c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e\"\n}"

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

```java Duplicate a specific published or archived version
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")
  .header("Authorization", "Bearer <API_KEY>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sourceVersionId\": \"c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e\"\n}")
  .asString();
```

```php Duplicate a specific published or archived version
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.lumenia.net/api/v1/prompt-templates/templateId/versions', [
  'body' => '{
  "sourceVersionId": "c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e"
}',
  'headers' => [
    'Authorization' => 'Bearer <API_KEY>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Duplicate a specific published or archived version
using RestSharp;

var client = new RestClient("https://app.lumenia.net/api/v1/prompt-templates/templateId/versions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <API_KEY>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sourceVersionId\": \"c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Duplicate a specific published or archived version
import Foundation

let headers = [
  "Authorization": "Bearer <API_KEY>",
  "Content-Type": "application/json"
]
let parameters = ["sourceVersionId": "c3d4e5f6-7081-4b2c-9d3e-4f5a6b7c8d9e"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.lumenia.net/api/v1/prompt-templates/templateId/versions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```