{
  "name": "Mathify Quickstart (Docs Example)",
  "nodes": [
    {
      "parameters": {
        "content": "## Mathify Quickstart — Docs Example\n\nThis workflow is a 1:1 illustration of https://mathify.dev/docs/quickstart — the same three requests, in the same order, with the same example values.\n\n**Workflow variables to set (Settings → Variables):**\n- `MATHIFY_API_KEY` – your key from mathify.dev/settings/api-keys\n- `MATHIFY_BASE_URL` – `https://mathify.dev` (no trailing slash)\n\nClick \"Execute workflow\" to run it. It polls every 30s until the animation is ready — usually a couple of minutes.\n\nSee n8n/workflows/ for the fuller, production version of this same pattern (with evals + music).",
        "height": 260,
        "width": 1200,
        "color": 5
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000001",
      "name": "Setup Notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-880, -420]
    },
    {
      "parameters": {},
      "id": "b1a2c3d4-0001-4a11-8f01-000000000002",
      "name": "When clicking \"Execute workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-880, 16]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $vars.MATHIFY_BASE_URL + '/api/v1/projects' }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $vars.MATHIFY_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{ \"name\": \"pythagorean-theorem\" }",
        "options": {}
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000003",
      "name": "1. Create Project",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-656, 16],
      "notes": "https://mathify.dev/docs/quickstart step 1 — POST /api/v1/projects"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $vars.MATHIFY_BASE_URL + '/api/v1/projects/' + $('1. Create Project').item.json.project.id + '/messages' }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $vars.MATHIFY_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{ \"content\": \"Animate the Pythagorean theorem\" }",
        "options": {}
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000004",
      "name": "2. Send Message",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-432, 16],
      "notes": "https://mathify.dev/docs/quickstart step 2 — POST /api/v1/projects/:id/messages"
    },
    {
      "parameters": {
        "amount": 30
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000005",
      "name": "Wait 30s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [-208, 16],
      "webhookId": "b1a2c3d4-0002-4a11-8f01-000000000001"
    },
    {
      "parameters": {
        "url": "={{ $vars.MATHIFY_BASE_URL + '/api/v1/fragments/' + $('2. Send Message').item.json.fragmentId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $vars.MATHIFY_API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000006",
      "name": "3. Poll Fragment",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [16, 16],
      "notes": "https://mathify.dev/docs/quickstart step 3 — GET /api/v1/fragments/:id"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "b1a2c3d4-0003-4a11-8f01-000000000001",
              "leftValue": "={{ $json.fragment.animationUrl }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b1a2c3d4-0001-4a11-8f01-000000000007",
      "name": "Animation Ready?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [240, 16],
      "notes": "fragment.animationUrl is null while generating, per https://mathify.dev/docs/quickstart"
    },
    {
      "parameters": {},
      "id": "b1a2c3d4-0001-4a11-8f01-000000000008",
      "name": "Done — Video Ready",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [464, -80]
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking \"Execute workflow\"": {
      "main": [
        [
          {
            "node": "1. Create Project",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Create Project": {
      "main": [
        [
          {
            "node": "2. Send Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Send Message": {
      "main": [
        [
          {
            "node": "Wait 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30s": {
      "main": [
        [
          {
            "node": "3. Poll Fragment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Poll Fragment": {
      "main": [
        [
          {
            "node": "Animation Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Animation Ready?": {
      "main": [
        [
          {
            "node": "Done — Video Ready",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
