GET

Template parameters

The values a render can change in a template, with their type, page and current value.

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

{id} is the template's tpl_… id or its key. Use the keys as modifications when you create a render. A single-page template's keys are bare (headline). On a multi-page template every key carries its page, page 1 included (page1@headline, page2@headline); send them that way.

Each parameter is a layer your team marked as a field. type is what the value changes: text, image and video take new content, and color parameters (fill, color, stroke, backgroundColor) take a color. default is the layer's value in the template now, layer its name in the editor, and hidden is true when the layer is hidden in the design. A text with {{name}} in it adds a key of its own, headline:name, for that word alone.

Examples

Check your data against a template before rendering

Your app sends values under its own field names. Read the keys once and compare, so a renamed field shows up as a clear error in your app instead of a render that ignored a value.

# Print each key with its type
curl -s https://api.muzekit.com/v1/templates/product-card/parameters \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq -r '.data[] | "\(.key)\t\(.type)"'

A render with an unknown key still renders and lists the key in warnings.

Build a form from a template's fields

Show one input per parameter in your own app, filled with the template's current values, and send what the user typed as modifications.

# The template's values as a modifications object
curl -s https://api.muzekit.com/v1/templates/product-card/parameters \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '[.data[] | {(.key): .default}] | add'

Read the keys of a multi-page template

Every key on a multi-page template names its page. Here a two-page flyer has a headline on each page and a {{name}} word in page 1's greeting.

JSON
{
  "object": "list",
  "template": "tpl_Vk1t4l9xvQv",
  "data": [
    {
      "object": "parameter",
      "key": "page1@greeting",
      "type": "text",
      "page": 1,
      "default": "Hello {{name}}",
      "layer": "Greeting",
      "hidden": false
    },
    {
      "object": "parameter",
      "key": "page1@greeting:name",
      "type": "text",
      "page": 1,
      "default": "",
      "layer": null,
      "hidden": false
    },
    {
      "object": "parameter",
      "key": "page2@headline",
      "type": "text",
      "page": 2,
      "default": "See you there",
      "layer": "Headline",
      "hidden": false
    }
  ]
}

Render it with the keys as they are:

JSON
{
  "template": "tpl_Vk1t4l9xvQv",
  "format": "pdf",
  "modifications": {
    "page1@greeting:name": "Maya",
    "page2@headline": "Doors open at 7"
  }
}

Response

JSON
{
  "object": "list",
  "template": "tpl_Vk1t4l9xvQv",
  "data": [
    {
      "object": "parameter",
      "key": "headline",
      "type": "text",
      "page": 1,
      "default": "Summer sale",
      "layer": "Headline",
      "hidden": false
    },
    {
      "object": "parameter",
      "key": "hero",
      "type": "image",
      "page": 1,
      "default": "https://…/hero.jpg",
      "layer": "Photo",
      "hidden": false
    }
  ]
}