Skip to content
Browse documentation

API

Submissions API

Submit published forms from an allowed browser origin and continue partial captures securely.

Open Markdown

POST /api/leads

Submit a published form from a registered browser origin. Send the business public key in the Authorization header. A server request without a validated Origin is not supported by this endpoint.

Request body

json
{
  "formId": "67a1b2c3d4e5f6a7b8c9d0e1",    // required
  "submissionVersion": 2,
  "responses": [                              // published step IDs
    { "stepId": "service", "selectedOptions": [{ "id": "web-design" }] }
  ],
  "contact": {                                // optional — bypasses extraction
    "name": "Alex Smyntyna",
    "email": "[email protected]",
    "phone": "+15551234567"
  },
  "hiddenFields": {                           // optional
    "utm_source": "google",
    "plan": "enterprise"
  },
  "sessionId": "sess_abc123",                // optional
  "source": "website",                        // optional
  "submissionStage": "complete",              // "partial" | "complete"
  "scheduledDate": "2026-07-15T10:00:00Z",  // optional
  "scheduledDuration": 30                     // optional (minutes)
}

Fields

FieldTypeDescription
formIdstringForm ID from your dashboard (required)
submissionVersionnumberSend 2 to receive a real lead ID plus a separate continuation token
responsesArrayAnswers keyed by published stepId; choice IDs must match published options
contactObjectPre-filled contact: { name?, email?, phone? }
hiddenFieldsObjectKey-value metadata (UTM, plan, etc.)
sessionIdstringClient-side session identifier for dedup
sourcestringSource label (e.g. 'website', 'facebook')
submissionStagestring"partial" (saved draft) or "complete" (final)
scheduledDatestringISO 8601 date for booking/appointment forms
scheduledDurationnumberDuration in minutes for booked slots
leadIdstringExisting partial lead ID for a version 2 continuation
continuationTokenstringRequired with leadId on a version 2 POST/PATCH update; expires after 24 hours
boundaryStepIdstringStep ID where the lead was captured

Contact extraction

When you supply a contact object, it is used directly as the lead's contact. If you omit it, the server runs a heuristic over the form responses to extract a name and email. If the heuristic finds nothing, the lead appears as "Unknown" in your CRM.

Best practice: always include a contact object when you know who the submitter is. The extraction heuristic can add missing fields but won't replace values you explicitly provide.

Partial submissions

Set submissionStage: "partial" to save a draft. Keep the returned leadId and continuationToken in browser memory, then send both with submissionVersion: 2 and submissionStage: "complete" to POST or PATCH /api/leads. A public key and bare lead ID cannot update a partial lead. An expired or missing token requires restarting the form; the captured partial lead remains saved. Older unversioned clients receive an opaque leadId containing the credential and must return it unchanged.

Response

json
// 201 Created
{
  "success": true,
  "leadId": "67f1a2b3c4d5e6f708091011",
  "continuationToken": "RANDOM_43_CHARACTER_TOKEN_KEEP_IN_MEMORY",
  "continuationExpiresAt": "2026-06-07T12:00:00.000Z"
}

Example

ts
const res = await fetch("https://api.inflow.build/api/leads", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer pk_...",
  },
  body: JSON.stringify({
    submissionVersion: 2,
    formId: "67a1b2c3d4e5f6a7b8c9d0e1",
    responses: [
      { stepId: "service", selectedOptions: [{ id: "web-design" }] },
    ],
    contact: {
      name: "Alex Smyntyna",
      email: "[email protected]",
    },
    hiddenFields: {
      utm_source: "google",
      utm_campaign: "spring_2026",
    },
    submissionStage: "complete",
  }),
});

if (!res.ok) throw new Error((await res.json()).message || "Could not send");
const { leadId, continuationToken } = await res.json();
// Keep both in memory if you later update a partial capture.