> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tela.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Prompt Version

> Creates a new version of a prompt

## Create a Prompt Version

This endpoint creates a new version of a prompt with the specified configuration, variables, and content.

### Request Body

The request body must include the following fields:

| Parameter       | Type          | Description                                          |
| --------------- | ------------- | ---------------------------------------------------- |
| `promptId`      | string (UUID) | The ID of the prompt to create a version for         |
| `title`         | string        | The title of the prompt version (max 256 characters) |
| `configuration` | object        | Configuration settings for the prompt version        |
| `variables`     | array         | An array of variable objects used in the prompt      |

#### Optional Fields

| Parameter         | Type         | Description                      |
| ----------------- | ------------ | -------------------------------- |
| `content`         | string       | Plain text content of the prompt |
| `markdownContent` | string       | Markdown content of the prompt   |
| `promoted`        | boolean      | Whether this version is promoted |
| `draft`           | boolean      | Whether this version is a draft  |
| `messages`        | array/object | Messages for chat-type prompts   |

### Examples

<CodeGroup>
  ```typescript typescript theme={null}

  const promptVersion = {
    promptId: 'prompt_uuid',
    title: 'Document Analysis v2',
    configuration: {
      model: 'claude-3-opus-20240229',
      temperature: 0.7,
      type: 'chat'
    },
    variables: [
      {
        name: 'document',
        type: 'file',
        required: true,
        description: 'The document to analyze'
      },
      {
        name: 'query',
        type: 'text',
        required: true,
        description: 'The specific question about the document'
      }
    ],
    markdownContent: '# Document Analysis\n\nAnalyze the document and answer questions about it.',
    draft: true
  }

  const response = await fetch('https://api.tela.ai/prompt-version', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(promptVersion)
  })

  const result = await response.json()
  console.log(result)
  ```

  ```javascript javascript theme={null}
  const promptVersion = {
    promptId: 'prompt_uuid',
    title: 'Document Analysis v2',
    configuration: {
      model: 'claude-3-opus-20240229',
      temperature: 0.7,
      type: 'chat'
    },
    variables: [
      {
        name: 'document',
        type: 'file',
        required: true,
        description: 'The document to analyze'
      },
      {
        name: 'query',
        type: 'text',
        required: true,
        description: 'The specific question about the document'
      }
    ],
    markdownContent: '# Document Analysis\n\nAnalyze the document and answer questions about it.',
    draft: true
  }

  const response = await fetch('https://api.tela.ai/prompt-version', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(promptVersion)
  })

  const result = await response.json()
  console.log(result)
  ```

  ```python python theme={null}
  import requests
  import os

  api_key = os.getenv("TELA_API_KEY")

  prompt_version = {
    "promptId": "prompt_uuid",
    "title": "Document Analysis v2",
    "configuration": {
      "model": "claude-3-opus-20240229",
      "temperature": 0.7,
      "type": "chat"
    },
    "variables": [
      {
        "name": "document",
        "type": "file",
        "required": True,
        "description": "The document to analyze"
      },
      {
        "name": "query",
        "type": "text",
        "required": True,
        "description": "The specific question about the document"
      }
    ],
    "markdownContent": "# Document Analysis\n\nAnalyze the document and answer questions about it.",
    "draft": True
  }

  headers = {
      "Authorization": f"Bearer {api_key}",
      "Content-Type": "application/json"
  }

  response = requests.post("https://api.tela.ai/prompt-version", json=prompt_version, headers=headers)
  result = response.json()
  print(result)
  ```
</CodeGroup>

### Response

The response includes the created prompt version object with its assigned ID and other details.

```json theme={null}
{
  "id": "version_uuid",
  "promptId": "prompt_uuid",
  "title": "Document Analysis v2",
  "markdownContent": "# Document Analysis\n\nAnalyze the document and answer questions about it.",
  "configuration": {
    "model": "claude-3-opus-20240229",
    "temperature": 0.7,
    "type": "chat"
  },
  "variables": [
    {
      "name": "document",
      "type": "file",
      "required": true,
      "description": "The document to analyze"
    },
    {
      "name": "query",
      "type": "text",
      "required": true,
      "description": "The specific question about the document"
    }
  ],
  "draft": true,
  "promoted": false,
  "createdAt": "2024-04-15T12:00:00.000Z",
  "updatedAt": "2024-04-15T12:00:00.000Z"
}
```

### Structured Output Example

<CodeGroup>
  ```typescript typescript theme={null}
  const promptVersionWithStructuredOutput = {
    promptId: 'prompt_uuid',
    title: 'Document Analysis with Structured Output',
    configuration: {
      model: 'claude-3-opus-20240229',
      temperature: 0.7,
      type: 'chat',
      structuredOutput: {
        enabled: true,
        schema: {
          type: "object",
          title: "DocumentAnalysis",
          description: "Analysis of a document",
          properties: {
            summary: {
              type: "string",
              description: "Brief summary of the document"
            },
            keyInsights: {
              type: "array",
              items: {
                type: "string"
              },
              description: "Key insights from the document"
            },
            sentiment: {
              type: "string",
              enum: ["positive", "neutral", "negative"],
              description: "Overall sentiment of the document"
            }
          },
          required: ["summary", "keyInsights", "sentiment"]
        }
      }
    },
    variables: [
      {
        name: 'document',
        type: 'file',
        required: true,
        description: 'The document to analyze'
      }
    ]
  }

  const response = await fetch('https://api.tela.ai/prompt-version', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(promptVersionWithStructuredOutput)
  })

  const result = await response.json()
  console.log(result)
  ```

  ```javascript javascript theme={null}
  const promptVersionWithStructuredOutput = {
    promptId: 'prompt_uuid',
    title: 'Document Analysis with Structured Output',
    configuration: {
      model: 'claude-3-opus-20240229',
      temperature: 0.7,
      type: 'chat',
      structuredOutput: {
        enabled: true,
        schema: {
          type: "object",
          title: "DocumentAnalysis",
          description: "Analysis of a document",
          properties: {
            summary: {
              type: "string",
              description: "Brief summary of the document"
            },
            keyInsights: {
              type: "array",
              items: {
                type: "string"
              },
              description: "Key insights from the document"
            },
            sentiment: {
              type: "string",
              enum: ["positive", "neutral", "negative"],
              description: "Overall sentiment of the document"
            }
          },
          required: ["summary", "keyInsights", "sentiment"]
        }
      }
    },
    variables: [
      {
        name: 'document',
        type: 'file',
        required: true,
        description: 'The document to analyze'
      }
    ]
  }

  const response = await fetch('https://api.tela.ai/prompt-version', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(promptVersionWithStructuredOutput)
  })

  const result = await response.json()
  console.log(result)
  ```

  ```python python theme={null}
  import requests
  import os

  api_key = os.getenv("TELA_API_KEY")

  prompt_version_with_structured_output = {
    "promptId": "prompt_uuid",
    "title": "Document Analysis with Structured Output",
    "configuration": {
      "model": "claude-3-opus-20240229",
      "temperature": 0.7,
      "type": "chat",
      "structuredOutput": {
        "enabled": True,
        "schema": {
          "type": "object",
          "title": "DocumentAnalysis",
          "description": "Analysis of a document",
          "properties": {
            "summary": {
              "type": "string",
              "description": "Brief summary of the document"
            },
            "keyInsights": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Key insights from the document"
            },
            "sentiment": {
              "type": "string",
              "enum": ["positive", "neutral", "negative"],
              "description": "Overall sentiment of the document"
            }
          },
          "required": ["summary", "keyInsights", "sentiment"]
        }
      }
    },
    "variables": [
      {
        "name": "document",
        "type": "file",
        "required": True,
        "description": "The document to analyze"
      }
    ]
  }

  headers = {
      "Authorization": f"Bearer {api_key}",
      "Content-Type": "application/json"
  }

  response = requests.post("https://api.tela.ai/prompt-version", json=prompt_version_with_structured_output, headers=headers)
  result = response.json()
  print(result)
  ```
</CodeGroup>


## OpenAPI

````yaml POST /prompt-version
openapi: 3.0.1
info:
  title: Tela API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tela.com
security: []
paths:
  /prompt-version:
    post:
      description: Create a new prompt version
      operationId: createPromptVersion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PromptVersionCreateRequest'
      responses:
        '200':
          description: Prompt version created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromptVersionResponse'
components:
  schemas:
    PromptVersionCreateRequest:
      type: object
      properties:
        promptId:
          type: string
          format: uuid
          description: UUID of the prompt to create a version for
        title:
          type: string
          maxLength: 256
          description: Title of the prompt version
        content:
          type: string
          nullable: true
          description: Plain text content of the prompt version
        markdownContent:
          type: string
          nullable: true
          description: Markdown content of the prompt version
        configuration:
          type: object
          description: Configuration settings for the prompt version
          properties:
            model:
              type: string
              description: The model to use for this prompt version
            temperature:
              type: number
              description: Temperature setting for model generation
            type:
              type: string
              enum:
                - chat
                - completion
              description: Type of prompt (chat or completion)
            structuredOutput:
              type: object
              description: Settings for structured output
              properties:
                enabled:
                  type: boolean
                  description: Whether structured output is enabled
                schema:
                  type: object
                  description: JSON schema for structured output
          required:
            - model
            - type
        variables:
          type: array
          description: Array of variables used in the prompt
          items:
            type: object
            properties:
              name:
                type: string
                description: Name of the variable
              type:
                type: string
                enum:
                  - file
                  - text
                description: Type of the variable
              required:
                type: boolean
                description: Whether this variable is required
              description:
                type: string
                description: Description of the variable
              processingOptions:
                type: object
                description: Processing options for the variable
                properties:
                  allowMultimodal:
                    type: boolean
                    description: Whether multimodal processing is allowed
            required:
              - name
              - type
              - required
        promoted:
          type: boolean
          nullable: true
          description: Whether this version is promoted
        draft:
          type: boolean
          nullable: true
          description: Whether this version is a draft
        messages:
          description: Messages for chat-type prompts
          oneOf:
            - type: object
              properties:
                role:
                  type: string
                  enum:
                    - user
                    - assistant
                    - system
                    - function
                content:
                  type: string
                  nullable: true
                index:
                  type: integer
              required:
                - role
            - type: array
              items:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - user
                      - assistant
                      - system
                      - function
                  content:
                    type: string
                    nullable: true
                  index:
                    type: integer
                required:
                  - role
      required:
        - promptId
        - title
        - configuration
        - variables
    PromptVersionResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the prompt version
        promptId:
          type: string
          format: uuid
          description: UUID of the prompt this version belongs to
        title:
          type: string
          maxLength: 256
          description: Title of the prompt version
        content:
          type: string
          nullable: true
          description: Plain text content of the prompt version
        markdownContent:
          type: string
          nullable: true
          description: Markdown content of the prompt version
        configuration:
          type: object
          description: Configuration settings for the prompt version
          properties:
            model:
              type: string
              description: The model to use for this prompt version
            temperature:
              type: number
              description: Temperature setting for model generation
            type:
              type: string
              enum:
                - chat
                - completion
              description: Type of prompt (chat or completion)
            structuredOutput:
              type: object
              description: Settings for structured output
              properties:
                enabled:
                  type: boolean
                  description: Whether structured output is enabled
                schema:
                  type: object
                  description: JSON schema for structured output
          required:
            - model
            - type
        variables:
          type: array
          description: Array of variables used in the prompt
          items:
            type: object
            properties:
              name:
                type: string
                description: Name of the variable
              type:
                type: string
                enum:
                  - file
                  - text
                description: Type of the variable
              required:
                type: boolean
                description: Whether this variable is required
              description:
                type: string
                description: Description of the variable
              processingOptions:
                type: object
                description: Processing options for the variable
                properties:
                  allowMultimodal:
                    type: boolean
                    description: Whether multimodal processing is allowed
            required:
              - name
              - type
              - required
        promoted:
          type: boolean
          nullable: true
          description: Whether this version is promoted
        draft:
          type: boolean
          nullable: true
          description: Whether this version is a draft
        messages:
          description: Messages for chat-type prompts
          oneOf:
            - type: object
              properties:
                role:
                  type: string
                  enum:
                    - user
                    - assistant
                    - system
                    - function
                content:
                  type: string
                  nullable: true
                index:
                  type: integer
              required:
                - role
            - type: array
              items:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - user
                      - assistant
                      - system
                      - function
                  content:
                    type: string
                    nullable: true
                  index:
                    type: integer
                required:
                  - role
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
      required:
        - id
        - promptId
        - title
        - configuration
        - variables

````