Templates

Update a template

This endpoint allows you to update the slug and mode of an existing template. The mode can be either "text" or "openai" (array of chat messages).

PATCH
/v1/templates/
id
curl --request PATCH \
  --url https://api.lunary.ai/v1/templates/{id} \
  --header 'Authorization: Bearer <api_key>' \
  --header 'Content-Type: application/json' \
  --data '{"slug":"updated-customer-support-chat","mode":"openai"}'

Accepted Keys:

slug
mode

Example response:

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "slug": "updated-customer-support-chat",
  "mode": "openai",
  "projectId": "456e7890-e12b-34d5-a678-426614174111",
  "createdAt": "2023-01-01T00:00:00Z",
  "versions": [
    {
      "id": "789e0123-e45b-67d8-a901-426614174222",
      "templateId": "123e4567-e89b-12d3-a456-426614174000",
      "content": [
        {
          "role": "system",
          "content": "You are a helpful customer support agent."
        },
        {
          "role": "user",
          "content": "I have a question about my order."
        }
      ],
      "extra": {
        "temperature": 0.7,
        "max_tokens": 150
      },
      "testValues": {
        "orderNumber": "ORD-12345"
      },
      "isDraft": false,
      "notes": "Updated version for improved customer support",
      "createdAt": "2023-01-02T12:00:00Z",
      "version": 1
    }
  ]
}

Parameters

NameLocated InRequiredSchema
idpathYesstring

Request Body

PropertyTypeDescription
slugstring
modestring

Responses

200

Successful response

PropertyTypeDescription
idstring
namestring
slugstring
modestring
createdAtstring
groupstring
projectIdstring
versionsarray

400

Invalid input

404

Template not found

Questions? We're here to help.

Email