Insertion API
Create Lead
Inserts (or idempotently upserts) a lead into your account via the Public Insertion API. The pipeline is identical to the internal /api/leads/ingest path — including idempotency on (account_id, campaign_id, external_lead_id), score-gated delivery, and workflow scheduling.
Endpoint
POST
/api/v1/insertion/leadsAuthentication
Two paths are accepted. HMAC-SHA256 signing is preferred. POST requires the leads:write scope on the API key. See the dedicated Authentication guide for the full signing recipe and Node/Python examples.
Request Body
| Name | Type | Description |
|---|---|---|
campaign_idrequired | integer | AdBuy campaign id to attach the lead to. |
external_lead_idrequired | uuid | Caller-supplied UUID. Idempotency key together with campaign_id. |
phone | string | E.164 or local phone. 10–50 chars. |
email | string | Up to 320 chars. |
first_name | string | Up to 100 chars. |
last_name | string | Up to 100 chars. |
source | string | Lead source label. |
source_form_url | string | URL the lead originated from. |
ip_address | string | Client IP captured at submit time. |
tcpa_consent | boolean | Whether TCPA consent was obtained. |
tcpa_consent_text | string | Exact consent string presented to the user. |
tcpa_consent_timestamp | string | ISO 8601 timestamp when consent was obtained. |
custom_fields | object | Arbitrary JSON object stored with the lead. |
workflow_ids | uuid[] | Optional override list of workflow ids to schedule. |
At least one of phone or email must be present. All other fields are optional. Unknown fields are rejected by the Zod schema with 400 invalid_payload.
Response
Status semantics:
inserted— first time this(campaign_id, external_lead_id)tuple was seen. Response code 201.patched— same tuple, mutated fields applied to the existing lead. Response code 200.deduped— exact replay; no changes made. Response code 200.
See Errors & Idempotency for the full error envelope and retry strategy.