Send leads from your server

Use a server-only application's token with the leads API to send leads from your own systems and check what became of them.

Send a lead#

The leads API takes leads from your own systems, a partner's, or anything else that isn't a visitor's browser. Use a server-only application with the read, write and crm scopes (see Server-only or browser).

Code
POST https://subcontext.com/api/v1/crm/ingests
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Idempotency-Key: a-value-unique-to-this-lead
json
{
  "source": "my_website",
  "campaign": "YOUR_CAMPAIGN_KEY",
  "identity": { "first_name": "Ada", "last_name": "Lovelace", "email": "ada@example.com" },
  "consent": { "service": { "email": true }, "method": "web_form" },
  "provenance": { "page_url": "https://www.example.com/contact?utm_source=newsletter" }
}
  • source (required) is your system's name: lowercase letters, numbers, _, . and -, up to 64 characters.
  • campaign is the campaign's key. In the dashboard, open CRM, Campaigns and the campaign. The key is under its name. The campaign's Lead capture tab links to a ready-made example (See the example).
  • Idempotency-Key (strongly recommended) is a value unique to this lead, such as your own record's id. If you send the same lead again with the same key, for example after a timeout, Subcontext answers as before and makes no second lead.

The answer#

The answer is 202 Accepted. Subcontext has stored the lead and works on it in the background. The body's data is the lead as received (its id, status and a plain explanation), with duplicate (true if Subcontext already had it). The Location header is where to ask what became of it later: GET https://subcontext.com/api/v1/crm/ingests/<id> with the same kind of token.

Everything you can send (who the person is, what they told you, consent with your evidence, where they came from) is in the lead form guide's Sending leads from a server and the dashboard help article Sending leads in: everything you can send.

Examples#

send-lead.mjs (Node), send-lead.php (PHP) and dotnet send-lead in Program.cs (C#) do all of this: each gets a token, sends a lead with an Idempotency-Key, and checks what became of it.

Stuck, or something missing?

Get in touch and a person on the team will help.

Contact us