Templates

The Prompt Templates API allows you to manage templates and their associated versions.

Data Format

Content Object

FieldTypeDescription
rolestringThe role of the content. Can be system, user, assistant or tool.
contentstringThe content of the prompt.

List Templates

GET https://api.lunary.ai/v1/templates

Retrieves a list of templates for the project corresponding to the private API key used.

Response Format

[
{
"id": string,
"name": string,
"slug": string,
"mode": string,
"createdAt": string,
"group": string,
"projectId": string,
"versions": [
{
"id": string,
"templateId": string,
"content": Content[],
"extra": object,
"testValues": object,
"isDraft": boolean,
"createdAt": string,
"version": number
}
]
}
]

Create Template

POST https://api.lunary.ai/v1/templates

Creates a new template with an initial version.

Request Format

{
"slug": string,
"mode": string,
"content": Content[],
"extra": object,
"testValues": object,
"isDraft": boolean
}

Response Format

{
"id": string,
"projectId": string,
"ownerId": string,
"slug": string,
"mode": string,
"versions": [
{
"id": string,
"templateId": string,
"content": Content[],
"extra": object,
"testValues": object,
"isDraft": boolean,
"createdAt": string,
"version": number
}
]
}

Get Template

GET https://api.lunary.ai/v1/templates/:id

Retrieves a specific template by its ID.

Response Format

{
"id": string,
"projectId": string,
"ownerId": string,
"slug": string,
"mode": string,
"createdAt": string
}

Delete Template

DELETE https://api.lunary.ai/v1/templates/:id

Deletes a specific template by its ID.

Response Format

Status: 204 No Content

Update Template

PATCH https://api.lunary.ai/v1/templates/:id

Updates a specific template by its ID.

Request Format

{
"slug": string,
"mode": string
}

Response Format

{
"id": string,
"projectId": string,
"ownerId": string,
"slug": string,
"mode": string,
"createdAt": string,
"versions": [
{
"id": string,
"templateId": string,
"content": Content,
"extra": object,
"testValues": object,
"isDraft": boolean,
"createdAt": string,
"version": number
}
]
}

Create Template Version

POST https://api.lunary.ai/v1/templates/:id/versions

Creates a new version for a specific template.

Request Format

{
"content": array,
"extra": object,
"testValues": object,
"isDraft": boolean
}

Response Format

{
"id": string,
"templateId": string,
"content": Content,
"extra": object,
"testValues": object,
"isDraft": boolean,
"createdAt": string,
"version": number
}

Questions? We're here to help.