{
  "name": "Convert Fleet - File Conversion API Pipeline",
  "nodes": [
    {
      "name": "Webhook - New File to Convert",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "path": "convert-file",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "name": "Set - Build Conversion Request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "sourceFileUrl",
              "type": "string",
              "value": "={{ $json.body.fileUrl }}"
            },
            {
              "id": "2",
              "name": "targetFormat",
              "type": "string",
              "value": "={{ $json.body.targetFormat }}"
            },
            {
              "id": "3",
              "name": "apiKey",
              "type": "string",
              "value": "YOUR_API_KEY"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "HTTP Request - Convert Fleet Convert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ],
      "parameters": {
        "url": "https://api.convertfleet.com/v1/convert",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"file_url\": $json.sourceFileUrl, \"target_format\": $json.targetFormat } }}",
        "options": {}
      }
    },
    {
      "name": "IF - Conversion Completed",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "name": "Google Drive - Upload Converted File",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1120,
        180
      ],
      "parameters": {
        "operation": "upload",
        "name": "={{ $json.output_filename }}",
        "driveId": {
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "mode": "list",
          "value": "root"
        },
        "options": {
          "sourceUrl": "={{ $json.output_url }}"
        }
      }
    },
    {
      "name": "Airtable - Log Conversion Result",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        1340,
        300
      ],
      "parameters": {
        "operation": "create",
        "base": {
          "mode": "id",
          "value": "YOUR_AIRTABLE_BASE_ID"
        },
        "table": {
          "mode": "id",
          "value": "YOUR_AIRTABLE_TABLE_ID"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "SourceFileUrl": "={{ $('Set - Build Conversion Request').item.json.sourceFileUrl }}",
            "TargetFormat": "={{ $('Set - Build Conversion Request').item.json.targetFormat }}",
            "Status": "={{ $json.status }}",
            "OutputUrl": "={{ $json.output_url }}"
          }
        }
      }
    },
    {
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.2,
      "position": [
        1560,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": $json.status, \"output_url\": $json.output_url } }}"
      }
    },
    {
      "name": "Sticky Note - Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        240,
        60
      ],
      "parameters": {
        "width": 460,
        "height": 200,
        "content": "## Setup\n1. Set an HTTP Header Auth credential on the 'HTTP Request - Convert Fleet Convert' node using header `Authorization: Bearer YOUR_API_KEY` (get key from convertfleet.com dashboard).\n2. Add Google Drive and Airtable credentials on those nodes; replace YOUR_AIRTABLE_BASE_ID / YOUR_AIRTABLE_TABLE_ID.\n3. POST to this Webhook URL with JSON body `{ fileUrl, targetFormat }` to trigger a conversion.\n4. Activate the workflow."
      }
    }
  ],
  "connections": {
    "Webhook - New File to Convert": {
      "main": [
        [
          {
            "node": "Set - Build Conversion Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set - Build Conversion Request": {
      "main": [
        [
          {
            "node": "HTTP Request - Convert Fleet Convert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Convert Fleet Convert": {
      "main": [
        [
          {
            "node": "IF - Conversion Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Conversion Completed": {
      "main": [
        [
          {
            "node": "Google Drive - Upload Converted File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Airtable - Log Conversion Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive - Upload Converted File": {
      "main": [
        [
          {
            "node": "Airtable - Log Conversion Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Log Conversion Result": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}