# n8n integration

Import a manual workflow that inspects an endpoint, checks its price and performs one bounded profile retrieval through MCP.

## Import and configure

- [Download the n8n workflow](https://www.monocrawl.com/examples/n8n-profile-workflow.json)

- Import the JSON into n8n. It contains a Manual Trigger and no schedule.

- Create a Header Auth credential named x-api-key, with your Monocrawl API key as its value. Select it on the paid retrieval HTTP Request node; never paste a key into the workflow JSON.

- Use a dedicated key with a cumulative cap. The workflow permits one TikTok profile request up to one credit; edit the subject in Prepare retrieval only after reviewing the endpoint.

- Run Inspect endpoint first. Review parameters, current cost and availability. The preparation node refuses unavailable or more expensive operations. Execute the full workflow when you want that retrieval.

## Read the MCP and HTTP outcomes

The HTTP Request nodes POST JSON-RPC to /mcp. The final Code node reads result.structuredContent and checks both isError and success. It returns the full envelope so you can preserve data, request_id, credits_used and warnings in the destination of your choice.

The nodes include response headers and status, so the JSON-RPC response is under $json.body. Never Error allows an HTTP error body to reach the explicit result check; connection failures still stop the workflow. Adding an IF node later should branch on the parsed envelope, not merely the HTTP 200 status.

- [Official HTTP Request node options](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/)

- [MCP response reference](https://www.monocrawl.com/docs/mcp#responses)

## Control retries and larger runs

Automatic retry is disabled. Prepare retrieval assigns an idempotency key from the n8n execution ID. A new execution has a new key: do not start a replacement execution after an uncertain result. Recover the original key and arguments from execution history first. Ensure n8n’s execution-history access and retention match your data policy.

For many inputs, add an explicit item limit and sequential loop. Track confirmed charges and stop on pending accounting. Each page is another retrieval with its own quote and key. Do not enable automatic pagination until the chosen endpoint’s continuation contract has been checked.

- [Pagination](https://www.monocrawl.com/docs/pagination-caching)

- [Credit controls](https://www.monocrawl.com/docs/credits)

- [Production guide](https://www.monocrawl.com/docs/production-checklist)
