Canvas Templates

Templates are blueprints for canvases. They define the nodes (poses), edges (transitions), conditions, and prompts - but no generated assets. When you apply a template, Masko creates items and kicks off image generation for every node.

What Templates Provide

A template contains the full graph structure: node positions, names, image prompts, edge connections, conditions, durations, and input definitions. It does not contain any generated assets. When applied, the template creates new items in the collection, generates images for each node, and saves the graph to the canvas. You then use generate-all to create all the transition animations.

Built-in Templates

Two templates are available out of the box. Use the template ID when calling the from-template endpoint.

List Templates

Fetch all available templates - both built-in and your own saved templates. Use the source query parameter to filter.

GET/v1/canvas-templates
# All templates (built-in + yours)
curl https://api.masko.ai/v1/canvas-templates \
  -H "Authorization: Bearer masko_YOUR_API_KEY"

# Only built-in templates
curl "https://api.masko.ai/v1/canvas-templates?source=builtin" \
  -H "Authorization: Bearer masko_YOUR_API_KEY"

# Only your saved templates
curl "https://api.masko.ai/v1/canvas-templates?source=mine" \
  -H "Authorization: Bearer masko_YOUR_API_KEY"

Apply a Template

Apply a template to an existing canvas. This creates items for each node, generates images, and saves the graph. The response includes a node_mapping that maps template node keys to the created item and asset IDs, plus a list of generation jobs.

POST/v1/collections/:id/canvases/:canvasId/from-template
curl -X POST https://api.masko.ai/v1/collections/COLLECTION_ID/canvases/CANVAS_ID/from-template \
  -H "Authorization: Bearer masko_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "claude-code-4state"
  }'
Tip

The total_cost from applying a template only covers image generation (1 credit per node). Animation generation is a separate step via generate-all which costs 5 credits/sec per transition.

Customize with Overrides

Pass node_overrides and edge_overrides to customize template prompts and names without modifying the template itself. Node overrides are keyed by the template's node key. Edge overrides are keyed by source->target format.

curl -X POST https://api.masko.ai/v1/collections/COLLECTION_ID/canvases/CANVAS_ID/from-template \
  -H "Authorization: Bearer masko_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "claude-code-4state",
    "node_overrides": {
      "idle": {
        "name": "Resting",
        "imagePrompt": "sitting peacefully on a rock, eyes half-closed"
      },
      "celebrating": {
        "imagePrompt": "doing a backflip with sparkles"
      }
    },
    "edge_overrides": {
      "idle->thinking": {
        "description": "slowly standing up and scratching head"
      }
    }
  }'

Save Your Own

Save a template from an existing canvas or from a raw JSON graph definition. Set public: true to make it available to other users.

POST/v1/canvas-templates
curl -X POST https://api.masko.ai/v1/canvas-templates \
  -H "Authorization: Bearer masko_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Widget Template",
    "description": "3-state sidebar widget with hover and click",
    "canvas_id": "CANVAS_ID",
    "collection_id": "COLLECTION_ID",
    "public": false
  }'