AutomationFlowsSocial Media › Automate Instagram & Facebook Posting with Meta Graph API

Automate Instagram & Facebook Posting with Meta Graph API

Original n8n title: Automate Instagram & Facebook Posting with Meta Graph API & System User Tokens

ByBrian @typebconsulting on n8n.io

This template automates posting to Instagram Business and Facebook Pages using the Meta Graph API. It supports both short-lived and long-lived tokens, with a secure approach using System User tokens for reliable, ongoing automation. Includes detailed guidance for authentication,…

Event trigger★★★★☆ complexity22 nodesHTTP Request
Social Media Trigger: Event Nodes: 22 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #5457 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "4fccdc64-1eb2-43a6-82c5-5ebcea2b801b",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -560,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "738fabc1-5282-442b-a275-a3943bff890e",
      "name": "Post to Instagram",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "<YOUR IMAGE URL HERE>"
            },
            {
              "name": "caption",
              "value": "<YOUR CAPTION HERE>"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "da899479-cfaa-4771-bc31-bdb0d4e4a3b7",
      "name": "Publish instagram post",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/17841404935066235/media_publish",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "creation_id",
              "value": "={{ $json.id }}"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b6cd01bd-f98f-4092-81f2-1b8f6e6c4b27",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -300
      ],
      "parameters": {
        "width": 540,
        "height": 1900,
        "content": "**How to Generate a Facebook Short-Lived Access Token for Instagram + Facebook Page Posting**\n\n### What You Need\n\n* A **Facebook account**\n* A **Facebook Page** (must be linked to an Instagram Business account if you plan to post to IG)\n* Access to [Meta for Developers](https://developers.facebook.com/)\n\n---\nStep-by-Step: How to Generate Your Short-Lived Token\n\n#### 1. Go to Meta for Developers\n\n* Visit: [https://developers.facebook.com/apps](https://developers.facebook.com/apps)\n* Log in with your Facebook credentials\n\n#### 2. Create a New App\n\n* Click the blue **Create App** button\n* Choose **Other** as the app type\n* On the next screen, select **Business**\n* Enter an app name and contact email, then click **Create App**\n\n#### 3. Open the App Dashboard\n\n* After creation, you\u2019ll be redirected to the app\u2019s dashboard\n* This is where you\u2019ll manage products, permissions, and tokens\n\n#### 4. Add Products\n\n* In the left sidebar, scroll down to **Add Product**\n* Click **Set Up** on both:\n\n  * **Instagram Graph API**\n  * **Facebook Graph API** (If missing it is automatically setup when you create the app) \n\n>  If you do not see the \"Add Product\" section, your app may already be locked to a specific template or be in Live mode. You can still continue to the Graph API Explorer.\n\n#### 5. Go to the Graph API Explorer\n\n* Visit: [https://developers.facebook.com/tools/explorer/](https://developers.facebook.com/tools/explorer/)\n* In the top-right dropdown, select your app\n* Under \"User or Page\", keep **User Token** selected\n\n#### 6. Generate a User Access Token\n\n* Click **Get Token** > **Get User Access Token**\n* A permissions dialog will appear\n\n#### 7. Select the Required Permissions (Scopes)\n\nCheck the following boxes:\n\n* `pages_show_list`\n* `pages_read_engagement`\n* `pages_manage_posts`\n* `instagram_basic`\n* `instagram_content_publish`\n\n> These allow you to post to both Facebook Pages and Instagram accounts. Some may require approval for production use.\n\n#### 8. Authenticate and Authorize\n\n* A pop-up will prompt you to log into Facebook and approve the app\n* Be sure to authorize access to your Facebook Page and linked Instagram account\n\n#### 9. Copy the Short-Lived Token\n\n* After successful login, the Graph API Explorer will refresh\n* Your new **short-lived token** will appear in the top bar\n* **Copy it immediately** \u2014 this token is valid for 1\u20132 hours\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fe0a05a4-5e13-4109-86c1-1da8fc5e7a9a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -300
      ],
      "parameters": {
        "width": 1460,
        "height": 540,
        "content": "Facebook will only give you a \"Long Live Token\" if you are verified. If you are testing or not verified you can use the below method.\nThe initial token will only last a few hours, you can use the below to get the one that last for 2 months. Once you have the 2 month token you can put it in here and set the schedule to run every 30-60 days which will refresh and be saved in the static data.\n\n\n##Please note static Data does not run on a test, you can use a form submitted node to activate the flow.\n##Please note this is just a work around for testing and not practical for permanent use. "
      },
      "typeVersion": 1
    },
    {
      "id": "cce6d146-599e-439a-bff6-fc0870a8df02",
      "name": "Refresh token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        -120
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/oauth/access_token",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "grant_type",
              "value": "fb_exchange_token"
            },
            {
              "name": "client_id",
              "value": "<Your Client ID>"
            },
            {
              "name": "client_secret",
              "value": "<Your Secret Here>"
            },
            {
              "name": "fb_exchange_token",
              "value": "<your short token>"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e93d120b-ef7b-491c-bfcf-3d6a1ec62786",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -680,
        -120
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 30,
              "triggerAtHour": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "097bde34-8787-4e0d-9dec-90f2de9c0aa1",
      "name": "Get Current Token",
      "type": "n8n-nodes-base.code",
      "position": [
        -500,
        -120
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n  json: {\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "75f115f5-eee8-4e85-bd35-8c70ac4c13c5",
      "name": "Push to Static Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        -120
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nstaticData.fb_token = $json.access_token;\n\nreturn [{\n  json: {\n    status: 'Token saved to static data',\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "95439d8f-c568-497a-901f-69b2cfd7172f",
      "name": "Get Token from static Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -640,
        60
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n  json: {\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b13db71d-0620-46d4-a9f9-17b693930af4",
      "name": "Post to Instagram1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -420,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<Instagram Page ID>/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "<Your Image Url>"
            },
            {
              "name": "caption",
              "value": "<Your Caption>"
            },
            {
              "name": "access_token",
              "value": "={{ $json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "72bb812b-7ccf-4703-8d6d-35feb3576792",
      "name": "Publish instagram post1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -60,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<your instagram page id>/media_publish",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "creation_id",
              "value": "={{ $json.id }}"
            },
            {
              "name": "access_token",
              "value": "={{ $('Get Token from static Data').item.json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5a279b05-d40f-47b6-a7f1-56daa21ff773",
      "name": "Post to Facebook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        780,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/266271423823110/photos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "https://images.pexels.com/photos/5475816/pexels-photo-5475816.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"
            },
            {
              "name": "caption",
              "value": "This is the caption for the post"
            },
            {
              "name": "access_token",
              "value": "={{ $json.data[0].access_token }}"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "395e1149-cb03-45f3-97b1-1a5fe8e4ac06",
      "name": "Use System token to get page token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/me/accounts",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "926c9774-6e9b-427f-8916-3ccf4ce30012",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        340
      ],
      "parameters": {
        "color": 5,
        "width": 1760,
        "height": 360,
        "content": "Using the permanant never expire token"
      },
      "typeVersion": 1
    },
    {
      "id": "1ef57c3d-fc04-4107-82e3-3faf0dcfe2ce",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -80
      ],
      "parameters": {
        "width": 680,
        "height": 1220,
        "content": " How to Create a Permanent System User Token (Recommended)\n\nThis token doesn\u2019t expire and is best for automation use cases\n\n1. Verify Your Business\n\nGo to https://business.facebook.com/settings/info\n\nComplete business verification under Business Info tab\n\nSubmit your business documents and wait for approval (Sometimes you just have to submit an EIN/Tax-ID.\n\nApproval can take 1-5 Business days\n\nOnce Approved do the following.\n\n2. Create a System User\n\nIn Business Settings\n\nGo to System Users > Click Add\n\nAssign a name (e.g. n8n-bot) and select Admin access\n\n3. Assign Assets to System User\n\nIn the same System User view, assign:\n\nYour Facebook Page (with Full Control)\n\nYour Instagram Account (linked via Page)\n\nYour App\n\n4. Generate a Token\n\nClick Generate Token\n\nSelect your App\n\nSet expiration to Never\n\nGrant these permissions:\n\npages_show_list\n\npages_read_engagement\n\npages_manage_posts\n\ninstagram_basic\n\ninstagram_content_publish\n\n-If instagram_content_publish is not visible, you may need to request it via App Review under the App dashboard.\n\n5. Use This Token\n\nStore it in the Facebook Graph API\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4eaa4823-7601-49d1-9cec-da232ac7ee62",
      "name": "Get Correct Page Token",
      "type": "n8n-nodes-base.code",
      "position": [
        560,
        480
      ],
      "parameters": {
        "jsCode": "const page = $json.data.find(p => p.id === '266271423823110');\nreturn [{ json: { access_token: page.access_token } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "abb870c7-9241-4503-9fb1-348dcbf29dad",
      "name": "Wait 2 Second",
      "type": "n8n-nodes-base.wait",
      "position": [
        -120,
        480
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "70120c0d-d21a-4fa2-b8d5-81931c198c65",
      "name": "Wait 2 Second1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -240,
        60
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "4cde11f4-c12f-4827-94ce-9ee9d11d821d",
      "name": "Use System token to get page token1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/me/accounts",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('Get Token from static Data').item.json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f7581a1c-d095-4fe9-951c-cc6b6108156a",
      "name": "Get Correct Page Token1",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        60
      ],
      "parameters": {
        "jsCode": "const page = $json.data.find(p => p.id === '<YOUR PAGE ID HERE>');\nreturn [{ json: { access_token: page.access_token } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "306bb9bb-5ba0-4ecd-96a8-33e3ec292526",
      "name": "Post to Facebook1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        580,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/photos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "<YOUR IMAGE URL HERE>"
            },
            {
              "name": "caption",
              "value": "<YOUR CAPTION  HERE>"
            },
            {
              "name": "access_token",
              "value": "={{ $json.data[0].access_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    }
  ],
  "connections": {
    "Refresh token": {
      "main": [
        [
          {
            "node": "Push to Static Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 Second": {
      "main": [
        [
          {
            "node": "Publish instagram post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 Second1": {
      "main": [
        [
          {
            "node": "Publish instagram post1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Current Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Current Token": {
      "main": [
        [
          {
            "node": "Refresh token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Instagram": {
      "main": [
        [
          {
            "node": "Wait 2 Second",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Instagram1": {
      "main": [
        [
          {
            "node": "Wait 2 Second1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Correct Page Token": {
      "main": [
        [
          {
            "node": "Post to Facebook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish instagram post": {
      "main": [
        [
          {
            "node": "Use System token to get page token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Correct Page Token1": {
      "main": [
        [
          {
            "node": "Post to Facebook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish instagram post1": {
      "main": [
        [
          {
            "node": "Use System token to get page token1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Token from static Data": {
      "main": [
        [
          {
            "node": "Post to Instagram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use System token to get page token": {
      "main": [
        [
          {
            "node": "Get Correct Page Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use System token to get page token1": {
      "main": [
        [
          {
            "node": "Get Correct Page Token1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Post to Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template automates posting to Instagram Business and Facebook Pages using the Meta Graph API. It supports both short-lived and long-lived tokens, with a secure approach using System User tokens for reliable, ongoing automation. Includes detailed guidance for authentication,…

Source: https://n8n.io/workflows/5457/ — original creator credit. Request a take-down →

More Social Media workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Social Media

Notion__DriveDropbox_Sync. Uses notionTrigger, googleDrive, dropbox, notion. Event-driven trigger; 47 nodes.

Notion Trigger, Google Drive, Dropbox +3
Social Media

This n8n workflow automates the process of uploading video and image advertisements to Meta Ads Manager via the Meta Graph API (Facebook Ads) directly from Google Sheets and Google Drive. The workflow

Facebook Graph Api, Google Sheets, HTTP Request +2
Social Media

This workflow provides an end-to-end automation for discovering, evaluating, and optionally downloading high-quality educational YouTube videos.

HTTP Request, Google Sheets
Social Media

Template Description WDF Top Keywords: This workflow is designed to streamline keyword research by automating the process of generating, filtering, and analyzing Google and YouTube keyword data. Ensur

Noco Db, HTTP Request
Social Media

Youtube-Metric-Colletor. Uses httpRequest, nocoDb, baserow. Event-driven trigger; 33 nodes.

HTTP Request, Noco Db, Baserow