# Get a version's document

> The document of any version of a template, the current one or an older one.

<Endpoint method="GET" path="/v1/templates/{id}/versions/{version}/document" />

<CodeTabs>

```bash tab="cURL"
curl https://api.muzekit.com/v1/templates/product-card/versions/2/document \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY"
```

```javascript tab="Node"
const res = await fetch(
  "https://api.muzekit.com/v1/templates/product-card/versions/2/document",
  { headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` } },
);
const { document, current } = await res.json();
```

```python tab="Python"
import os
import requests

version = requests.get(
    "https://api.muzekit.com/v1/templates/product-card/versions/2/document",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()
```

</CodeTabs>

`{id}` is the template's `tpl_…` id or its key. `{version}` is a version's `ver_…` id or its `number`, both from [List versions](/docs/api-reference/templates-versions-list). A version of another template, or a number the template doesn't have, answers `404 version_not_found`.

Reading a version changes nothing. `current` says whether it is the version saves update; for that one, [Get a document](/docs/api-reference/templates-document-get) gives the same document with the `ETag` to save against.

## Examples

### Put an older design back

Read the older version's document, then save it over the current one with the current revision. The version you replaced stays in the history only if it was named; [duplicate the template](/docs/api-reference/templates-duplicate#keep-a-copy-before-you-change-a-document) first to keep it.

<CodeTabs>

```bash tab="cURL"
API=https://api.muzekit.com/v1/templates/product-card
AUTH="Authorization: Bearer $MUZEKIT_SECRET_KEY"

REV=$(curl -s "$API/document" -H "$AUTH" | jq '.revision')
curl -s "$API/versions/2/document" -H "$AUTH" \
  | jq --argjson rev "$REV" '{ revision: $rev, document }' \
  | curl -X PUT "$API/document" -H "$AUTH" \
      -H "Content-Type: application/json" -d @-
```

```javascript tab="Node"
const API = "https://api.muzekit.com/v1/templates/product-card";
const auth = { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` };
const get = async (path) => (await fetch(`${API}${path}`, { headers: auth })).json();

const older = await get("/versions/2/document");
const { revision } = await get("/document");

await fetch(`${API}/document`, {
  method: "PUT",
  headers: { ...auth, "Content-Type": "application/json" },
  body: JSON.stringify({ revision, document: older.document }),
});
```

```python tab="Python"
import os
import requests

API = "https://api.muzekit.com/v1/templates/product-card"
auth = {"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"}

older = requests.get(f"{API}/versions/2/document", headers=auth).json()
revision = requests.get(f"{API}/document", headers=auth).json()["revision"]

requests.put(
    f"{API}/document",
    headers=auth,
    json={"revision": revision, "document": older["document"]},
)
```

</CodeTabs>

### Compare a named version with the current one

Find a named version in the list by its `label`, then read both documents, for example to show what changed before a launch.

<CodeTabs>

```bash tab="cURL"
API=https://api.muzekit.com/v1/templates/product-card
AUTH="Authorization: Bearer $MUZEKIT_SECRET_KEY"

VER=$(curl -s "$API/versions" -H "$AUTH" \
  | jq -r '.data[] | select(.label == "Launch") | .id')
diff <(curl -s "$API/versions/$VER/document" -H "$AUTH" | jq .document) \
     <(curl -s "$API/document" -H "$AUTH" | jq .document)
```

```javascript tab="Node"
const API = "https://api.muzekit.com/v1/templates/product-card";
const auth = { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` };
const get = async (path) => (await fetch(`${API}${path}`, { headers: auth })).json();

const { data: versions } = await get("/versions");
const launch = versions.find((v) => v.label === "Launch");
const [before, now] = await Promise.all([
  get(`/versions/${launch.id}/document`),
  get("/document"),
]);
```

```python tab="Python"
import os
import requests

API = "https://api.muzekit.com/v1/templates/product-card"
auth = {"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"}

versions = requests.get(f"{API}/versions", headers=auth).json()["data"]
launch = next(v for v in versions if v["label"] == "Launch")
before = requests.get(f"{API}/versions/{launch['id']}/document", headers=auth).json()
now = requests.get(f"{API}/document", headers=auth).json()
```

</CodeTabs>

## Response

```json
{
  "object": "document",
  "template": "tpl_Vk1t4l9xvQv",
  "version": "ver_Lp0sQ7dXk2m",
  "number": 2,
  "label": "Launch",
  "current": false,
  "revision": 4,
  "created_at": "2026-11-12T10:02:11.000Z",
  "updated_at": "2026-11-12T10:02:11.000Z",
  "document": {
    "pages": [
      {
        "canvas": { "width": 1080, "height": 1080 },
        "elements": []
      }
    ]
  }
}
```
