Home » n8n» Can n8n connect to Instagram? Docker + Graph API guide

Can n8n connect to Instagram?

Yes, n8n can connect to Instagram by using the Instagram Graph API and n8n’s HTTP Request node. This guide shows a clear, beginner-friendly path to run n8n in Docker, get an Instagram Business account token, and publish media with example curl commands.

What You Need

  • A Facebook Developer App (App ID and App Secret).
  • An Instagram Business or Creator account linked to a Facebook Page.
  • n8n running in Docker on a reachable host.
  • A short-lived user access token and then a long-lived token from the Graph API.

How Can n8n connect to Instagram using Docker and Graph API

High level logic:

  1. Run n8n in Docker.
  2. Obtain a long-lived Instagram Graph API token.
  3. Use the HTTP Request node in n8n to call Graph API endpoints for media creation and publish.

Step 1: Start n8n in Docker

Run n8n quickly for testing. Use basic auth and map the port 5678. Adjust volumes for persistence in production.

docker run -it --rm -p 5678:5678 \
  -e N8N_BASIC_AUTH_ACTIVE=true \
  -e N8N_BASIC_AUTH_USER=admin \
  -e N8N_BASIC_AUTH_PASSWORD=changeme \
  n8nio/n8n

Step 2: Get an Instagram Graph API access token

Use your Facebook App to get a short-lived user token via OAuth. Then exchange it for a long-lived token.

Exchange short-lived token for long-lived token:

curl -X GET "https://graph.facebook.com/v17.0/oauth/access_token?grant_type=fb_exchange_token&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&fb_exchange_token=SHORT_LIVED_TOKEN"
# Response contains access_token

Find your Instagram Business user id from the connected page:

curl -X GET "https://graph.facebook.com/v17.0/PAGE_ID?fields=instagram_business_account&access_token=LONG_LIVED_TOKEN"
# Response: {"instagram_business_account": {"id": "IG_USER_ID"}}

Step 3: Build the n8n workflow

Use the HTTP Request node. Set method, URL, and send form data exactly like the curl examples. Store the long-lived token in n8n credentials or environment variables.

Example logic to publish an image in two API calls:

  1. Create a media object with image URL and caption.
  2. Publish the creation id returned by the first call.

Create the media object (curl):

curl -X POST "https://graph.facebook.com/v17.0/IG_USER_ID/media" \
  -F 'image_url=https://example.com/photo.jpg' \
  -F 'caption=Hello from n8n' \
  -F 'access_token=LONG_LIVED_TOKEN'
# Response: {"id":"CREATION_ID"}

Publish the media (curl):

curl -X POST "https://graph.facebook.com/v17.0/IG_USER_ID/media_publish" \
  -F 'creation_id=CREATION_ID' \
  -F 'access_token=LONG_LIVED_TOKEN'
# Response: {"id":"PUBLISHED_MEDIA_ID"}

Step 4: Test the workflow

In n8n use an HTTP Request node for each API call. Map the creation id from the first node to the publish node. Trigger the workflow and check the published media id.

Update

API versions change. If endpoints or parameters change update the Graph API version in your URLs. Revoke and reissue tokens if responses stop working. Monitor Facebook Developer release notes.

Security

  • Store access tokens in n8n credentials or environment variables, not in plain nodes.
  • Use HTTPS for any publicly exposed n8n instance and enable basic auth or OAuth to protect the editor.
  • Grant the app only the permissions it needs (instagram_content_publish, pages_read_engagement).
  • Rotate tokens and limit app roles in Facebook Developer settings.

Done

You now have a working path to connect n8n to Instagram using Docker and the Instagram Graph API. Use the example curl commands inside n8n HTTP Request nodes and keep tokens secure. Iterate and test with a staging account before production.


Neil
Written by Neil

Neil is a true n8n geek who lives and breathes workflow automation. He dives deep into nodes, triggers, webhooks, custom logic, and self-hosting setups, sharing everything he learns about n8n on AutomationCompare.com. As part of a broader team of automation specialists, Neil focuses purely on mastering n8n and helping others unlock its full potential.

Keep Reading

Scroll to Top