> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> Integrate the Ayrshare social media API into your n8n workflows to publish, schedule, and analyze your users' social media accounts.

export const XByoNotice = () => <Info>
  <strong>Targeting X/Twitter?</strong> Starting March 31, 2026, all X operations require your own API credentials. After linking X via OAuth, include these 2 headers in your request:
  <br /><br />
  <code>X-Twitter-OAuth1-Api-Key</code> — Your API Key (Consumer Key)<br />
  <code>X-Twitter-OAuth1-Api-Secret</code> — Your API Key Secret (Consumer Secret)
  <br /><br />
  <strong>One-time setup per Ayrshare account.</strong> You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do <em>not</em> create a new app per customer.
  <br /><br />
  Not linked yet? See the <a href="/dashboard/connect-social-accounts/x-twitter-byo-keys">full setup guide</a> to connect your X account.
  <br /><br />
  Your keys are never logged or stored by Ayrshare.
</Info>;

## Overview

[n8n](https://n8n.io) is a workflow automation platform that lets you connect apps and orchestrate processes, including AI agents, on Cloud or self-hosted.

The Ayrshare social media API can be integrated into your n8n workflows to manage your users' social media accounts. One API call publishes to Facebook, Instagram, LinkedIn, YouTube, TikTok, Pinterest, Reddit, Threads, Bluesky, Telegram, Google Business Profile, Snapchat, and X, so you do not write or maintain per-platform API code.

There are two ways to connect:

<ul class="custom-bullets">
  <li>**MCP Server (agent-driven).** Attach the [Ayrshare MCP Server](/additional/mcp-action-server) to n8n's built-in MCP Client Tool node, and your AI Agent can run the whole loop on its own: draft a post, validate it against each network's rules, publish or schedule it, then read the analytics back. There is nothing to host and no community node to install.</li>
  <li>**REST API (fixed workflow).** For deterministic, non-agent workflows, call the [Ayrshare REST API](/apis/overview) directly from an HTTP Request node.</li>
</ul>

Managing your users' social accounts requires the [Business plan](/multiple-users/business-plan-overview), but you can similarly manage your own social accounts with the Premium plan using just the [API Key](/apis/overview#authorization) in the request header.

## How it connects

With the MCP path, the **AI Agent** node is the brain. The **MCP Client Tool** sub-node attaches to it, connects to the Ayrshare MCP Server, discovers the available tools, and exposes them to the agent. When the agent acts, the node dispatches the call to Ayrshare, which publishes to the networks.

```
Trigger  ->  AI Agent (+ Chat Model)  ->  MCP Client Tool  ->  Ayrshare MCP Server  ->  social networks
```

<Note>
  Use the **HTTP Streamable** transport, not SSE. The [n8n guide](/additional/mcp-n8n) covers transport, authentication, and setup in detail.
</Note>

## Guide

The full n8n guide covers the MCP-first path end to end: prerequisites, setting up the MCP Client Tool node, the validate-first system prompt, worked examples (draft and publish from a chat message, auto-publish new content, a weekly analytics digest), acting on behalf of clients with sub-profiles, keeping a human in the loop, the REST fallback, and troubleshooting.

<Card title="n8n + Ayrshare MCP Guide" icon="book-open" href="/additional/mcp-n8n" horizontal>
  Connect n8n's AI Agent to the Ayrshare MCP Server to publish, schedule, and analyze across your social networks, with no per-platform API code.
</Card>

<Card title="Download the n8n starter workflow" icon="download" href="/files/ayrshare-n8n-mcp-workflow.json" horizontal>
  A ready-to-import workflow: Chat Trigger, AI Agent, an Anthropic chat model, and the Ayrshare MCP node pre-wired with the validate-first system prompt.
</Card>

## Posting to X (formerly Twitter)

<XByoNotice />

In n8n, switch the MCP Client Tool node's **Authentication** to **Multiple Headers** and add the two `X-Twitter-OAuth1-*` headers alongside `Authorization`. See [Connect & Setup → X/Twitter BYO credentials](/additional/mcp-action-connect#xtwitter-byo-credentials).

## Learn more

<ul class="custom-bullets">
  <li>Learn more about [n8n](https://n8n.io) and its [AI Agent](https://docs.n8n.io/advanced-ai/) and [MCP Client Tool](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/) nodes.</li>
  <li>See the [MCP Server overview](/additional/mcp-action-server) for what the server is and how it maps to the Ayrshare API.</li>
  <li>Browse the [Tool Catalog](/additional/mcp-action-tools) for the tools your agent can call, grouped by domain.</li>
  <li>Read [Connect & Setup](/additional/mcp-action-connect) for endpoint, transport, authentication, and profile targeting details.</li>
</ul>
