GET

Get a document

A template’s current content and its revision.

View as Markdown
GEThttps://api.muzekit.com/v1/templates/{id}/document
curl -i https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv/document \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY"

{id} is the template's tpl_… id or its key. The answer is always the current version; the document format is the same one you send to create a template or update a document.

The ETag header carries the revision too. Send it back as If-Match when you save.

Examples

Export a template to a file

Keep a design in your own storage or in version control. The file is a complete document: you can create a template from it later.

curl -s https://api.muzekit.com/v1/templates/product-card/document \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '.document' > product-card.json

Copy a template into another environment

Read the document with one environment's key and create a template from it with the other's. Give it the same key, so your code names it the same way in both. Copy to Live in the dashboard does this for many templates at once.

curl -s https://api.muzekit.com/v1/templates/product-card/document \
  -H "Authorization: Bearer $MUZEKIT_TEST_SECRET_KEY" \
  | jq '{ name: "Product card", external_id: "product-card", document }' \
  | curl https://api.muzekit.com/v1/templates \
      -H "Authorization: Bearer $MUZEKIT_LIVE_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d @-

The key must be free in the target environment, or the create returns 409 external_id_taken. To replace a template that's already there, update its document instead.

Find a layer in the document

Layers are the elements of each page. A field has parameterizable: true and its parameterId, the key you see in parameters.

curl -s https://api.muzekit.com/v1/templates/product-card/document \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '.document.pages[].elements[] | select(.parameterId == "headline")'

Response

JSON
{
  "object": "document",
  "template": "tpl_Vk1t4l9xvQv",
  "version": "ver_Lp0sQ7dXk2m",
  "revision": 3,
  "document": {
    "schema": { "core": 1 },
    "pages": [
      {
        "id": "page-1",
        "name": "Page 1",
        "canvas": { "width": 1080, "height": 1080 },
        "elements": [
          {
            "id": "el-1",
            "type": "text",
            "content": "Summer sale",
            "parameterizable": true,
            "parameterId": "headline",
            "position": { "x": 80, "y": 120 },
            "dimensions": { "width": 920, "height": 140 },
            "style": { "fontSize": 96, "color": "#111111" }
          }
        ]
      }
    ],
    "meta": {},
    "ext": {}
  }
}

Layers carry more fields than shown here. Keep the ones you don't change as they are when you save.