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

# Prompt Versioning

> You can version your prompts in Athina's Prompt Playground, or via API.

When you create a `prompt_template` in Athina, it is automatically assigned a `version` (an auto-incremented integer) to help you track of changes over time.

This allows you to revert to previous versions if needed, and collaborate with others on the same prompt.

### Commit a new version

You can commit a new version of a `prompt_slug` in the prompt playground, or via the API.

<Tabs>
  <Tab title="Platform">
    1. Press the `Commit` button in the editor
    2. Enter a commit message (optional), and check that the prompt, default model, and parameters are correct.
  </Tab>

  <Tab title="API">
    Committing a new version of a `prompt_slug` is easy.

    Just call the [Create Prompt Template](/prompts/create-prompt) API endpoint using the same `prompt_slug` in the URL, along with an optional `commit_message` to describe the changes.

    If the `prompt_slug` already exists, a new version will be created.

    Otherwise a new `prompt_slug` will be created with version `1`.
  </Tab>
</Tabs>

***

### Set Default Version

One version of your `prompt_slug` can be considered the "default" version.

This is the version that will be used by default when you run the prompt via API.

To set a version as the default version, you can do so in the prompt playground, or via the API.

<Tabs>
  <Tab title="python">
    ```python
    from athina_client.prompt import Prompt

    Prompt.set_default(slug="test-staging", version=2)

    ```
  </Tab>

  <Tab title="curl">
    ```bash
    curl
    --location
    --request PATCH 'https://api.athina.ai/api/v1/prompt/[PROMPT_SLUG]/[VERSION]/set-default' \
    --header 'athina-api-key: ATHINA_API_KEY'
    ```
  </Tab>
</Tabs>

* `VERSION`: The version number you want to set as the default version. (ex: `11`)

***

### Get Default Version

You can also get the default version of the prompt programmatically.

<Tabs>
  <Tab title="python">
    ```python
    from athina_client.prompt import Prompt

    Prompt.get_default(slug="test-staging") # returns a Prompt Template

    ```
  </Tab>
</Tabs>

***

### View all versions

You can view all versions of a `prompt_slug` in the prompt playground, or via the API.

<Tabs>
  <Tab title="Platform">
    1. Click the version identifier in the top bar of the editor.
    2. A panel will open showing all versions of the prompt.
    3. Hover over a version to see it in the editor.
    4. Click on a version to replace the editor content with that version.
  </Tab>

  <Tab title="API">
    To view all versions of a `prompt_slug`, you can call the following `GET` API.

    ```bash
    curl
    --location 'https://api.athina.ai/api/v1/prompt/[PROMPT_SLUG]/version' \
    --header 'athina-api-key: ATHINA_API_KEY'

    ```
  </Tab>
</Tabs>
