Skip to main content
POST
/
rest
/
prompt-templates
Publish Prompt Template
curl --request POST \
  --url https://api.promptlayer.com/rest/prompt-templates \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <x-api-key>' \
  --data '
{
  "prompt_template": {
    "prompt_name": "<string>",
    "tags": [],
    "folder_id": 1
  },
  "prompt_version": {
    "prompt_template": {
      "content": [
        {
          "text": "<string>",
          "type": "text",
          "id": "<string>",
          "annotations": [
            {
              "type": "<string>",
              "title": "<string>",
              "url": "<string>",
              "start_index": 123,
              "end_index": 123,
              "cited_text": "<string>",
              "encrypted_index": "<string>"
            }
          ],
          "thought_signature": "<string>"
        }
      ],
      "input_variables": [],
      "template_format": "f-string",
      "type": "completion"
    },
    "commit_message": "<string>",
    "metadata": {
      "model": {
        "provider": "<string>",
        "name": "<string>",
        "model_config_display_name": "<string>",
        "base_model": "<string>",
        "parameters": {},
        "display_params": {},
        "api_type": "<string>"
      }
    }
  },
  "release_labels": [
    "<string>"
  ]
}
'
{
  "id": 123,
  "prompt_name": "<string>",
  "prompt_version_id": 123,
  "version_number": 123,
  "tags": [
    "<string>"
  ],
  "prompt_template": {
    "content": [
      {
        "text": "<string>",
        "type": "text",
        "id": "<string>",
        "annotations": [
          {
            "type": "<string>",
            "title": "<string>",
            "url": "<string>",
            "start_index": 123,
            "end_index": 123,
            "cited_text": "<string>",
            "encrypted_index": "<string>"
          }
        ],
        "thought_signature": "<string>"
      }
    ],
    "input_variables": [],
    "template_format": "f-string",
    "type": "completion"
  },
  "release_labels": [
    "<string>"
  ],
  "metadata": {
    "model": {
      "provider": "<string>",
      "name": "<string>",
      "model_config_display_name": "<string>",
      "base_model": "<string>",
      "parameters": {},
      "display_params": {},
      "api_type": "<string>"
    }
  },
  "commit_message": "<string>"
}
Publish Prompt Template allows you to programmatically create a new version of a prompt template and make it available for use in the application.

Request Body

The request body has two top-level objects: prompt_template (template metadata) and prompt_version (the version content).

prompt_template

FieldTypeRequiredDescription
prompt_namestringYesThe unique prompt name within the workspace. 1–512 characters.
tagsstring[]NoTags to attach to the prompt registry entry.
folder_idintegerNoThe ID of the folder to publish the prompt template into. If omitted, the prompt is created at the workspace root. Use Resolve Folder ID by Path to look up an ID from a path, or Create Folder to make one.
workspace_idintegerNoOptional workspace override; defaults to the workspace associated with the API key.

prompt_version

The version body (prompt_template, commit_message, metadata, provider_id, etc.) is documented in the schema below.

Example: publish into a folder

import requests

response = requests.post(
    "https://api.promptlayer.com/rest/prompt-templates",
    headers={"X-API-KEY": "your-api-key"},
    json={
        "prompt_template": {
            "prompt_name": "summarizer",
            "tags": ["production", "summarization"],
            "folder_id": 42,
        },
        "prompt_version": {
            "prompt_template": {
                "type": "chat",
                "messages": [
                    {"role": "system", "content": [{"type": "text", "text": "You are a summarizer."}]},
                    {"role": "user", "content": [{"type": "text", "text": "{input}"}]},
                ],
            },
            "commit_message": "Initial release",
        },
    },
)

Headers

X-API-KEY
string
required

Body

application/json
prompt_template
BasePromptTemplate · object
required
prompt_version
PromptVersion · object
required
release_labels
string[] | null

Response

Successful Response

id
integer
required

The ID of the prompt template.

prompt_name
string
required

The name of the prompt template.

prompt_version_id
integer
required

The ID of the created prompt version.

version_number
integer
required

The version number of the prompt template.

tags
string[]
required
prompt_template
Completion Template · object
required
release_labels
string[] | null
metadata
Metadata · object

Metadata associated with the prompt blueprint. Supports additional custom fields beyond the model field.

commit_message
string | null