{
  "name": "Postifys \u2014 Google Sheets row \u2192 Facebook + Instagram",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "id": "cron-1",
      "name": "Every hour (disable until ready)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/REPLACE_SHEET_ID/edit",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Posts",
          "mode": "name"
        },
        "options": {
          "rangeDefinition": "specifyRangeA1",
          "range": "A2:E500"
        }
      },
      "id": "gs-1",
      "name": "Read sheet rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        240,
        0
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "REPLACE_WITH_GOOGLE_SHEETS_OAUTH",
          "name": "Google Sheets OAuth"
        }
      },
      "notes": "Header row (row 1): media_url, caption, page_id, instagram_account_id, status. Only rows with status=pending are processed \u2014 add a Filter node if you need that."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://postifys.com/api/facebook/post",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: $json.caption, type: \"IMAGE\", mediaUrls: [$json.media_url], pageId: $json.page_id }) }}",
        "options": {}
      },
      "id": "http-fb",
      "name": "Publish Facebook",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        -120
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_POSTIFYS_HEADER_AUTH",
          "name": "Postifys API Key (Authorization: Bearer \u2026)"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://postifys.com/api/instagram/post",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ type: \"IMAGE\", mediaUrls: [$json.media_url], text: $json.caption, instagramAccountId: $json.instagram_account_id }) }}",
        "options": {}
      },
      "id": "http-ig",
      "name": "Publish Instagram",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        120
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_POSTIFYS_HEADER_AUTH",
          "name": "Postifys API Key (Authorization: Bearer \u2026)"
        }
      },
      "notes": "Each platform can fail independently. Inspect both HTTP responses; do not assume fan-out success from one 200."
    }
  ],
  "connections": {
    "Every hour (disable until ready)": {
      "main": [
        [
          {
            "node": "Read sheet rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read sheet rows": {
      "main": [
        [
          {
            "node": "Publish Facebook",
            "type": "main",
            "index": 0
          },
          {
            "node": "Publish Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "postifys-public-template"
  },
  "pinData": {},
  "versionId": "1",
  "tags": [
    {
      "name": "postifys"
    }
  ]
}
