Lead Hub
API Docs

Lead Hub API

Internal API for ingesting leads across sites.

POST /api/leads

Accepts a lead, verifies contact info via XVerify, saves to Supabase, and syncs to Beehiiv.

Authentication

All requests must include:

x-api-key: <LEAD_HUB_API_KEY>

Missing or incorrect key returns 401 Unauthorized.

Request Fields

Content-Type: application/json

Required

FieldTypeDefaultDescription
sourcestringOriginating site/form (e.g. "weekly-investor")
emailstringValid email address

Core

FieldTypeDefaultDescription
phonestringPhone number — used for XVerify
firstNamestring
lastNamestring

Consent

FieldTypeDefaultDescription
marketing_consentbooleanfalse
sms_consentbooleanfalse
double_opt_override"on" | "off" | "not_set""not_set"Overrides Beehiiv double opt-in. "on" sends confirmation email before activating. "off" activates immediately. "not_set" uses publication default.

Tracking

FieldTypeDefaultDescription
universal_leadidstringTrustedForm / Universal LeadId
affstringAffiliate ID
s1 – s20stringSub-ID / click-tracking params (s1 = primary transaction ID)

UTM

FieldTypeDefaultDescription
utm_sourcestring
utm_mediumstring
utm_campaignstring
utm_termstring
utm_contentstring

browserData (object, optional)

FieldTypeDefaultDescription
deviceTypestring
operatingSystemstring
browserstring
browserVersionstring
screenResolutionstring
viewportSizestring
languagestring
timezonestring
timezoneOffsetnumber
connectionTypestring
pageUrlstring
pageTitlestring
landingPagestring
referrerstring
sessionIdstring
isReturningVisitorboolean
timeOnPagenumberseconds
formCompletionTimenumberseconds

locationData (object, optional)

FieldTypeDefaultDescription
countrystring
regionstring
citystring
postalstring
latitudenumber
longitudenumber

Example Request

curl -X POST https://your-domain.com/api/leads \
  -H "Content-Type: application/json" \
  -H "x-api-key: your_api_key_here" \
  -d '{
    "source": "weekly-investor",
    "email": "jane@example.com",
    "phone": "5551234567",
    "firstName": "Jane",
    "lastName": "Doe",
    "marketing_consent": true,
    "sms_consent": false,
    "double_opt_override": "off",
    "aff": "aff123",
    "s1": "click_abc",
    "utm_source": "facebook",
    "utm_medium": "cpc",
    "utm_campaign": "q1-promo"
  }'

Responses

200 OK

{
  "success": true,
  "leadId": "uuid-string",
  "source": "weekly-investor",
  "verified": { "email": true, "phone": true }
}

400 — Validation failed

{ "error": "Validation failed", "details": { ... } }

Also returned when XVerify marks the contact as invalid (production only).

401 — Unauthorized

{ "error": "Unauthorized" }

409 — Duplicate

{ "error": "Already submitted. Check your email for confirmation.", "isDuplicate": true }

Same email or phone + source submitted within 5 minutes.

503 — Verification unavailable

{ "error": "Verification service unavailable. Please try again." }

500 — Internal error

{ "error": "Internal server error" }

Behavior Notes