{
  "name": "Video Conversion API \u2013 ConvertFleet Media Pipeline",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "convert-video",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook: Receive File",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ],
      "webhookId": "cf-video-convert-trigger"
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "apiKey",
              "value": "YOUR_CONVERTFLEET_API_KEY"
            },
            {
              "name": "apiBase",
              "value": "https://api.convertfleet.com/v1"
            },
            {
              "name": "inputUrl",
              "value": "={{ $json.body.file_url }}"
            },
            {
              "name": "targetFormat",
              "value": "={{ $json.body.target_format || 'mp4' }}"
            },
            {
              "name": "videoResolution",
              "value": "={{ $json.body.resolution || '1080p' }}"
            },
            {
              "name": "audioBitrate",
              "value": "={{ $json.body.audio_bitrate || '192k' }}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set: Config & Params",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $json.apiBase }}/jobs",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.apiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyContentType": "json",
        "jsonBody": "={\n  \"input_url\": \"{{ $json.inputUrl }}\",\n  \"output_format\": \"{{ $json.targetFormat }}\",\n  \"options\": {\n    \"resolution\": \"{{ $json.videoResolution }}\",\n    \"audio_bitrate\": \"{{ $json.audioBitrate }}\"\n  }\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "name": "HTTP: Submit Conversion Job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "resume": "timeInterval",
        "amount": 20,
        "unit": "seconds"
      },
      "name": "Wait: Processing Delay",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        900,
        300
      ],
      "webhookId": "cf-wait-poll"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.convertfleet.com/v1/jobs/{{ $('HTTP: Submit Conversion Job').item.json.job_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer YOUR_CONVERTFLEET_API_KEY"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "name": "HTTP: Poll Job Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.status }}",
              "operation": "equals",
              "value2": "completed"
            }
          ]
        }
      },
      "name": "IF: Conversion Done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1340,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, output_url: $json.output_url, job_id: $json.job_id, output_format: $json.output_format, file_size_bytes: $json.output_size_bytes, processing_ms: $json.processing_time_ms }) }}",
        "options": {}
      },
      "name": "Respond: Success",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1560,
        180
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: false, status: $json.status, error: $json.error || 'Conversion still processing \u2014 poll again with job_id', job_id: $('HTTP: Submit Conversion Job').item.json.job_id }) }}",
        "options": {}
      },
      "name": "Respond: Pending or Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1560,
        420
      ]
    },
    {
      "parameters": {
        "content": "## ConvertFleet Video Conversion Pipeline\n\n**Setup (3 steps):**\n1. Paste your API key into **Set: Config & Params** \u2192 `apiKey` field (get it from your ConvertFleet dashboard).\n2. **Activate** this workflow and copy the Webhook URL.\n3. POST to the webhook from Pipedream, Zapier, or your app:\n```json\n{\n  \"file_url\": \"https://cdn.example.com/raw.mov\",\n  \"target_format\": \"mp4\",\n  \"resolution\": \"1080p\",\n  \"audio_bitrate\": \"192k\"\n}\n```\n\n**Supported formats:** MP4, MOV, AVI, MKV, WEBM, MP3, WAV, FLAC, GIF + more via ffmpeg.\n\n**Large files (>500 MB):** Increase the **Wait** node delay to 60\u2013120 s.\n\n**Webhook response:** Returns `output_url` on success, or `job_id` to poll manually on pending/error.",
        "height": 400,
        "width": 440
      },
      "name": "Sticky Note: Setup Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        240,
        540
      ]
    }
  ],
  "connections": {
    "Webhook: Receive File": {
      "main": [
        [
          {
            "node": "Set: Config & Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set: Config & Params": {
      "main": [
        [
          {
            "node": "HTTP: Submit Conversion Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP: Submit Conversion Job": {
      "main": [
        [
          {
            "node": "Wait: Processing Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait: Processing Delay": {
      "main": [
        [
          {
            "node": "HTTP: Poll Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP: Poll Job Status": {
      "main": [
        [
          {
            "node": "IF: Conversion Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: Conversion Done?": {
      "main": [
        [
          {
            "node": "Respond: Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond: Pending or Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}