{
  "name": "Resize video with KinoPipe",
  "nodes": [
    {
      "parameters": {},
      "id": "7cd9b1bd-c9b9-4db4-8885-00d6c3f7f613",
      "name": "When clicking Execute workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-720, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "770c4770-d506-4fc5-95ea-993060bfa0e3",
              "name": "sourceUrl",
              "value": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "87d98da7-6097-4148-954c-0d166e2d18b8",
      "name": "Set source URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-500, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://kinopipe.com/api/v1/tools/resize-video",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer REPLACE_WITH_KINOPIPE_API_KEY" },
            { "name": "Idempotency-Key", "value": "=n8n-resize-{{$execution.id}}" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { inputs: [{ id: 'main', url: $json.sourceUrl }], options: { aspect_ratio: '9:16', fit: 'cover' } } }}",
        "options": {}
      },
      "id": "58d072fe-745b-488a-b1b7-8feb4793c0f2",
      "name": "Run resize tool",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-260, 0]
    },
    {
      "parameters": { "amount": 5 },
      "id": "03a5e4e7-0643-4035-a453-cc985cd4b4e5",
      "name": "Wait 5 seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [-20, 0],
      "webhookId": "ae394f10-c721-429f-979b-d67c6476c17e"
    },
    {
      "parameters": {
        "url": "=https://kinopipe.com{{$node['Run resize tool'].json.statusUrl}}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer REPLACE_WITH_KINOPIPE_API_KEY" }
          ]
        },
        "options": {}
      },
      "id": "f7e8f752-7d52-43c7-90fc-905878ec9af4",
      "name": "Get job status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [
            {
              "id": "1a09e3a5-1847-4247-a416-1d8516243176",
              "leftValue": "={{ ['succeeded', 'failed'].includes($json.job.status) }}",
              "rightValue": true,
              "operator": { "type": "boolean", "operation": "true", "singleValue": true }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "d49fc00a-c3e0-411b-b5dc-2ff96aa5d48e",
      "name": "Job finished?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [460, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "711805bf-0310-46aa-872b-27130c760c05", "name": "status", "value": "={{ $json.job.status }}", "type": "string" },
            { "id": "8a0a1f3c-555f-4cf9-8097-18dbef2b80f7", "name": "downloadUrl", "value": "={{ $json.result?.output?.downloadUrl || '' }}", "type": "string" },
            { "id": "bbf1aa57-b96b-4399-806c-717ac4325450", "name": "error", "value": "={{ $json.job.error?.message || '' }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "cb61d595-f666-4b45-99af-d16b8d6408d3",
      "name": "Finished output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [700, -100]
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking Execute workflow": { "main": [[{ "node": "Set source URL", "type": "main", "index": 0 }]] },
    "Set source URL": { "main": [[{ "node": "Run resize tool", "type": "main", "index": 0 }]] },
    "Run resize tool": { "main": [[{ "node": "Wait 5 seconds", "type": "main", "index": 0 }]] },
    "Wait 5 seconds": { "main": [[{ "node": "Get job status", "type": "main", "index": 0 }]] },
    "Get job status": { "main": [[{ "node": "Job finished?", "type": "main", "index": 0 }]] },
    "Job finished?": { "main": [[{ "node": "Finished output", "type": "main", "index": 0 }], [{ "node": "Wait 5 seconds", "type": "main", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "versionId": "dbbe4a35-6ce6-43db-a962-57245785fc55",
  "meta": { "templateCredsSetupCompleted": false },
  "tags": []
}
