Skip to content

Sync Leads from Your Website Form

Use this recipe when someone fills out a “Request a Quote” form on your marketing site and you want it landing in the BuildWorkPro pipeline within seconds. Pair it with a duplicate check so the same prospect filling out the form twice doesn’t generate two leads.

  1. Receive the form submission server-side.

    Don’t call the BuildWorkPro API from the browser — that would expose your API key. Have the form POST to a backend route that you control.

    app.post('/website/lead', express.json(), async (req, res) => {
    const { name, email, message, submissionId } = req.body;
    await syncLead({ name, email, message, submissionId });
    res.status(204).end();
    });
  2. Look up the default “New” stage.

    stageId is required. Fetch the tenant’s lead stages once at startup and cache the id of the column you want new web leads to land in.

    const stages = await fetch('https://app.buildworkpro.com/api/v1/lead-stages', {
    headers: { Authorization: `Bearer ${process.env.BWP_KEY}` },
    }).then((r) => r.json());
    const NEW_STAGE_ID = stages.data.find((s) => s.name === 'New').id;
  3. Dedupe by email before creating.

    Search existing leads for the same email — if one exists, skip the create:

    const existing = await fetch(
    `https://app.buildworkpro.com/api/v1/leads?search=${encodeURIComponent(email)}`,
    { headers: { Authorization: `Bearer ${process.env.BWP_KEY}` } }
    ).then((r) => r.json());
    if (existing.data.length > 0) return; // already in the pipeline
  4. POST the lead with the form submission id as the idempotency key.

    await fetch('https://app.buildworkpro.com/api/v1/leads', {
    method: 'POST',
    headers: {
    Authorization: `Bearer ${process.env.BWP_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': `web-form-${submissionId}`,
    },
    body: JSON.stringify({
    name,
    stageId: NEW_STAGE_ID,
    source: 'website',
    description: message,
    }),
    });

    Using the form’s submission id as the key means a network retry of the same submission is a safe no-op rather than a duplicate.