---
title: "Get the latest version"
method: GET
path: "/v1/template-versions/latest"
tags: ["Templates"]
---

# Get the latest version

`GET /v1/template-versions/latest`

## Request

- Base URL: `https://api.lunary.ai`
- URL: `https://api.lunary.ai/v1/template-versions/latest`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/lunary/apis/lunary-api/docs/v1/template-versions/latest/get.ts> (a function with typed inputs; its response is checked against the schema)

This is the most common endpoint you'll use when working with prompt templates.

This route is used by the Lunary SDKs to fetch the latest version of a template before making an LLM call.

This route differs from all the next ones in that:
- it requires only the `slug` parameter to reference a template
- it doesn't require using a Private Key to authenticate the request (Public Key is enough)

## Query parameters

- `slug` string, required

## Response `200`

Latest version of the template

- TemplateVersion
  - `id` string
  - `templateId` string
  - `content` object[]
    - `role` string
    - `content` string
  - `metadata` PromptMetadata: Versioned key/value text, separate from model parameters and prompt variables. Keys are preserved exactly, must not be blank, and are limited to 256 characters. The reserved key __proto__ is not allowed. Values must be strings. Numbers, booleans, null, arrays, and objects are rejected. The serialized object must be no larger than 64 KiB. Returned by prompt retrieval endpoints, including public-key retrieval; do not store secrets here. Omitted metadata defaults to an empty object on creation and is preserved on PATCH.
  - `extra` object
  - `testValues` object
  - `isDraft` boolean
  - `notes` string
  - `createdAt` string, date-time
  - `version` number

## Other responses

- `404`: Template not found

---

[API](https://skmtc.dev/lunary/apis/lunary-api.md) - [All operations](https://skmtc.dev/lunary/apis/lunary-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lunary/apis/lunary-api/revisions/a38233713bdc?raw)
