Prerequisites
- A Twexapi API key
- n8n Cloud or self-hosted n8n
- A webhook URL for MCP handoff recipes
- Optional Slack, Google Sheets, Airtable, or database credentials
API key credential
Create a reusable n8n credential for Twexapi REST calls:| Field | Value |
|---|---|
| Authentication | Header Auth |
| Header name | Authorization |
| Header value | Bearer YOUR_API_KEY |
| Base URL | https://api.twexapi.io |
https://api.twexapi.io/mcp and header x-api-key: YOUR_API_KEY.
Pattern
- Create an n8n Webhook trigger.
- Ask an MCP-capable agent to return strict Twexapi handoff JSON.
- POST the JSON to the n8n webhook.
- Use Set, IF, Split Out, and HTTP Request nodes to process rows.
Webhook payload
Suggested n8n nodes
| Step | Node | Purpose |
|---|---|---|
| 1 | Webhook | Receive MCP handoff JSON. |
| 2 | IF | Stop if tweets is empty. |
| 3 | Split Out | Process each tweet row. |
| 4 | Database or Sheets | Upsert by tweet_id. |
| 5 | HTTP Request | Continue through Twexapi REST if the workflow owns the next API call. |
Result handoff
Use an Edit Fields node after each MCP or HTTP Request step when the next node only needs stable fields.| Source | Store as |
|---|---|
| Tweet ID | tweet_id |
| Text | text |
| Author username | author_username |
| Created time | created_at |
| Pagination cursor | next_cursor |
| MCP route | route_used |
Recipe 1: AI agent X research with MCP
Suggested prompt:
Recipe 2: Monitor-style Slack alert
Use this when the workflow should alert a Slack channel after receiving a row from an MCP agent or a scheduled REST job.| Node | Purpose |
|---|---|
| Webhook Trigger | Receive Twexapi handoff JSON. |
| Split Out | Iterate over tweets. |
| Set | Format author_username, text, and public_url. |
| Slack | Post the alert. |
Recipe 3: Extraction to Google Sheets
For larger follower or reply exports, let the agent choose the endpoint with MCP, then run the repeated pages through REST.| Sheet column | Twexapi field |
|---|---|
| Tweet ID | tweet_id |
| Author | author_username |
| Text | text |
| Created At | created_at |
| URL | public_url or https://x.com/i/web/status/{tweet_id} |
Direct REST continuation
Testing checklist
- Use n8n Test Step on every HTTP Request node.
- Confirm every REST request includes
Authorization: Bearer YOUR_API_KEY. - Confirm every MCP Client Tool request includes
x-api-key. - Confirm webhooks receive JSON, not prose.
- On
429, pause before retrying and preservenext_cursor.