Skip to content
Via Webhook

Send Your Own Website Forms to LeadCentre

If your site has a hand-built form, or a backend you control, it can post each enquiry to your LeadCentre webhook URL. The right way to do it is from your server. Here's why, with a short example you or your developer can use.

Via Webhook: The platform posts each lead to your LeadCentre webhook URL.

What This Does

Your form sends the enquiry to your own server. Your server shows the visitor your thank-you page and posts the details to LeadCentre, which creates a lead and sends the alert.

Why not post the HTML form straight to the webhook URL?

A plain form with the webhook URL in its action attribute does reach LeadCentre, but you wouldn't want to keep it:

  • Your visitor sees raw JSON. After pressing send, they land on a page reading something like ok: true, with no thank-you message and no way back to your site.
  • Your key is in the page source. The URL contains the key, so anyone can read it and send junk into your account. All you could do then is replace it.
  • Calling it from JavaScript doesn't solve this. The key is still visible in the browser. LeadCentre also sends no cross-origin headers, so browsers block JSON posts and hide the response from other kinds.

So use your backend. A serverless function on your hosting counts, if it keeps the URL in an environment variable.

Example: PHP

<?php
// contact.php receives your form, then passes it on.
$lead = [
  'name'    => $_POST['name'] ?? '',
  'email'   => $_POST['email'] ?? '',
  'phone'   => $_POST['phone'] ?? '',
  'message' => $_POST['message'] ?? '',
];
$ch = curl_init(getenv('LEADCENTRE_WEBHOOK_URL'));
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($lead),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 10,
]);
curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) !== 200) {
  error_log('LeadCentre did not accept a lead');
}
header('Location: /thank-you');

Note json_encode on the fields. Passing PHP cURL an array sends multipart/form-data, which LeadCentre doesn't read.

Example: JavaScript on your server

// Runs on your server, never in the browser.
const response = await fetch(process.env.LEADCENTRE_WEBHOOK_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name, email, phone, message }),
});
if (!response.ok) console.error('LeadCentre refused', response.status);

Don't pass a FormData object as the body, for the same reason: it sends multipart.

File uploads

Forms with a file input have to be sent as multipart/form-data, and LeadCentre doesn't read that. It refuses the post with a 415, so no lead is created. If your form takes files, have your backend receive the form, store the file, then post the text fields to LeadCentre as JSON, with a link to the file if you want one. LeadCentre doesn't store files, and a post can be up to 64 KB.

Spam

LeadCentre doesn't filter spam, so check submissions on your backend first. A hidden honeypot field or a captcha will stop most junk becoming leads and alerts.

Useful For

  • A developer maintaining a hand-built site for a local trade business
  • An owner with a PHP contact form who'd rather not rebuild the site to get enquiries on their phone
  • Teams with a quote calculator or booking form that already runs on their own server
  • Anyone with a static site who can add one serverless function

How Leads Flow Into LeadCentre

  1. Step 1

    A visitor presses send

    The form posts to your own server, and they see your thank-you page.

  2. Step 2

    Your server checks it

    Validate the fields and turn away spam, using your own checks.

  3. Step 3

    Your server posts to LeadCentre

    JSON or URL-encoded, using a URL kept in an environment variable, away from the page.

  4. Step 4

    LeadCentre creates the lead

    Your saved matching fills in the fields, and a push notification goes to the app.

How to Set It Up

  1. 1

    Create a key

    In LeadCentre, go to Settings > Connections. Under "Add another key", type a name such as Website form and press "Create". Press "Copy". The URL is only shown once, so put it straight into your server's environment variables, not your code.

  2. 2

    Add the post to your backend

    Use one of the examples above, sending the field names you want to see in LeadCentre. Simple ones like name, email, phone, postcode, service and message are recognised by Smart Match.

  3. 3

    Start listening

    Follow "Next: test and match fields", or open the key from Settings > Connections, and press "Listen for test data". It lasts 15 minutes, and the page updates itself.

  4. 4

    Send a test enquiry

    Submit your form with every field filled in, because empty fields don't appear on the matching screen. They should appear under "2. Match the fields" a few seconds later. Developers can check the response at the same time: {"ok":true,"results":["test"]} means LeadCentre treated it as test data.

  5. 5

    Match and save

    Check Smart Match's suggestions, choose a field for each row you want to keep, or leave it on Do not use. If your backend creates its own enquiry reference, match it to Unique ID to stop duplicates. Press "Save field matching".

  6. 6

    Stop listening and check

    Press "Stop listening", because a real enquiry sent while listening counts as test data. Submit one more enquiry and check it reaches your Leads list and you get the alert.

Supported Fields

You decide the names because your backend sends them. These are the ones we'd use. The full list of LeadCentre fields and the technical limits are in the webhook reference.

Field sentUsually matched to
name, or first_name and last_nameFull name, or First name and Last name
emailEmail
phonePhone (mobile or landline)
postcodePostcode
serviceEnquiry type
messageEnquiry / Message
page (the page the form was on)A custom field
id (your own reference)Unique ID (stops duplicates)

Common Problems

My test data isn't showing

Press "Listen for test data" first, as it stops after 15 minutes. Log the status code your server gets back: 401 means the URL or key is wrong, 400 means LeadCentre couldn't read the body, 415 means you sent multipart, and 200 means it arrived, so check you're on the right key's page. An empty value doesn't appear as a field.

LeadCentre answers with a 415

You're sending multipart/form-data, which LeadCentre doesn't read, so no lead was created. Send JSON or URL-encoded data. In PHP, wrap your array in json_encode or http_build_query. In JavaScript, don't pass a FormData object as the body.

A lead shows "Waiting for field matching"

It was sent before anything was matched on that key, so it's held. Match the fields and press "Save field matching". The banner tells you how many waiting leads were added.

Recent activity says "No name, phone or email"

None of your matched fields held a name, phone or email. This often follows a rename in your form or backend. Match the new name and save, and LeadCentre retries those posts.

My key has been exposed in page source or a repository

Open the key and press "Replace this URL". The old one stops at once, and your field matching stays. Move the new URL into an environment variable and post from your backend. Archive any junk it let in.

I lost the webhook URL

It's shown once, and LeadCentre only keeps a scrambled copy, so it can't be looked up. Check your environment variables first. If it's gone, press "Replace this URL", or "Get a URL to copy" if it has never been used, and update your server.

I need to rotate the key

The old URL stops the moment you press "Replace this URL", and anything sent to it gets a 401. Have your deployment ready, so the gap is short, and log enquiries on your side in case any need sending again.

Questions About This Connection

My site has no backend at all. What can I do?

Add one small serverless function, which most static hosts support. Or move the form to a tool that sends webhooks for you, or to a form tool with a Zapier or Make trigger. Posting straight from the page works technically, but it exposes your key and shows visitors raw JSON.

Do I have to send JSON?

No. LeadCentre also reads a URL-encoded form post. It decides from the body itself, so a wrong Content-Type header isn't a problem. The only format to avoid is multipart/form-data.

What if LeadCentre doesn't respond?

Don't make your visitor wait or show them an error. Set a short timeout, show your thank-you page regardless and keep your own record, such as a notification email. You can then deal with any missed enquiry by hand.

Can I send the key in a header?

Yes. Remove the ?key= part from the URL and send the key in an x-api-key header. This keeps it out of server logs that record URLs.

Get Your Leads Flowing.

Set up your LeadCentre account, connect this source and see your next enquiry arrive on your phone.

Get Started