Margo

n8n integration

Margo + n8n: Build automated lead generation workflows

Use n8n HTTP Request nodes with Margo's REST API to discover local businesses, poll lead jobs, and review results before CRM delivery.

Connect through the REST API

This workflow uses n8n's HTTP Request node, not a native Margo connector. Import the example JSON, open both Margo POST and Margo poll HTTP Request nodes, and select an HTTP Header Auth credential: name Authorization, value Bearer followed by your Margo API key. Store the key in credentials, never in the exported workflow.

API access requires an eligible Business account and a verified account email. Configure the target category, ISO country code, geography, and requested count before starting. The example requests 10 dentists in London with country GB and state London; state is the geography field accepted by both the governed and compatibility handlers. The governed handler also accepts city. Do not use location or limit as top-level request fields.

Download the importable n8n workflowMargo lead generation API

POST https://www.margoleads.io/api/v1/leads/generate
Authorization: Bearer <MARGO_API_KEY>
Content-Type: application/json
Idempotency-Key: n8n-london-dentists-20261004-run1

{"source":"google_maps","category":"dentist","state":"London","country":"GB","maxResults":10}

Configure a bounded search and polling loop

  1. 1Import the workflow and set the Header Auth credential on both Margo HTTP Request nodes. Generate one Idempotency-Key for each new logical search; keep it unchanged for retries of that search. The key must contain 8–160 letters, digits, dots, underscores, colons, or hyphens.
  2. 2Enable Include Response Headers and Status and Never Error so the classification node can inspect HTTP status, Retry-After, and the body. The workflow also routes transport errors to classification.
  3. 3POST category or keyword, country, state (or city on the governed handler), and maxResults. maxResults is the requested count, not a guarantee: the governed handler supports up to 300; the compatibility handler caps at 100. This example uses 10 for both.
  4. 4For HTTP 202 or a QUEUED/RUNNING job, wait and GET the returned pollUrl with the same Bearer credential. Poll only the same Margo host and /api/v1/leads/jobs/ path. GET polling does not start another search.
  5. 5Read terminal.status, deliveredCount, stopReason, limitations, and constraintCoverage. POST results expose leads at the top level; GET job results expose them at job.result.leads. Review COMPLETE or PARTIAL records before adding a separate CRM or spreadsheet node.

Handle empty results, failures, quota, and retries

EMPTY or zero delivered records end with a review receipt and no delivery. PARTIAL keeps the delivered records and reports the shortfall; never silently treat requested count as delivered count. FAILED or CANCELLED jobs stop even when the polling response is HTTP 200. Unknown terminal states and malformed responses also stop for review.

HTTP 401 means check the credential. HTTP 400/409 means correct the request or idempotency conflict. HTTP 403, including QUOTA_EXCEEDED, stops for account or quota review; do not keep retrying or create a replacement search. POST retries are paused by default: set postRetriesEnabled to true in Configure search only after confirming the governed handler is active. The synchronous compatibility handler does not honor Idempotency-Key, so automatic POST retries there can create duplicate searches. With idempotent POST retries enabled, a retryable HTTP 429, 5xx, or transport failure waits before repeating the same request with the same key; GET polling retries are safe without creating a new search. Honor Retry-After when supplied; otherwise use capped exponential backoff. The example permits at most three retries per request and 60 polls, then stops visibly. Leave POST retries paused when the handler mode is uncertain.

The exported workflow ends at a human review receipt. Margo discovers and exports leads; this example does not send messages, enroll contacts in outreach, or promise that an email will be delivered. Add your own destination only after reviewing contact availability and result limitations.

Agency prospecting workflowsEmail discovery and verification status

Frequently asked questions

What API plan do I need for n8n?

The Business API requires an eligible account, a valid API key, and a verified account email. Check account access and available quota before scheduling searches.

Can I use n8n Cloud or self-hosted n8n?

Both can call the HTTPS REST API through HTTP Request nodes. Store Bearer authentication in n8n credentials and select that credential after importing the example.

Is there an importable n8n template?

Yes. Download the example JSON on this page. It includes a manual trigger, request configuration, bounded retry and polling logic, empty and error handling, and a review receipt. It contains no API key or lead contacts.

Does this workflow automatically run outreach?

No. It ends with records and a status receipt for human review. CRM delivery or sending requires a separate workflow you configure.

Illustration of lead records moving through an n8n automation workflow

Try now

Get verified leads without the manual work.

Try now
Margo + n8n Lead Generation Automation | Margo