Events API
Send sign-ups, purchases and other events from your website or store to LeadFlow with an API key, to add contacts, mark customers and start sequences.
Events API#
The Events API lets your website, store or any server tell LeadFlow what a person did: signed up, bought, renewed, downloaded. Each event lands on the contact's timeline, and it can add them as a lead, mark them as a customer or enrol them in a sequence.
It is on the Professional and Business plans.
On WordPress, the CommFlow plugin sends WooCommerce orders, WordPress Download Manager sign-ups and purchases, and new registrations for you, with no code.
API keys#
Managers, owners and admins make keys under LeadFlow > API > New API key. For each key, choose:
- a name, such as the site that will use it;
- the owner of new contacts it adds (you, by default);
- optionally, a group to put them in.
The key is shown once, so copy it then. LeadFlow keeps only a fingerprint of it. A workspace can have up to 10 keys, and Revoke stops one at once.
A key acts for the person who made it. If they leave the workspace or lose access to all contacts, the key stops working until someone makes a new one; the API tab shows which keys are affected.
Keep keys on your server. Never put one in a web page or an app, where anyone could read it.
Send an event#
curl https://api.commflow.io/crm/events \
-H "Authorization: Bearer lf_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "kim@example.com",
"event": "purchase",
"properties": { "plan": "pro", "amount": 99 },
"id": "order-1001",
"contact": { "name": "Kim Lee", "company": "Example Ltd" },
"create_contact": true,
"convert": true
}'| Field | What it does | |
|---|---|---|
email | required | Who the event is about. |
event | required | What happened, such as signup or purchase. Stored in lower case with spaces as underscores. |
properties | optional | Up to 25 simple values: text, numbers, true or false. Shown on the timeline. |
occurred_at | optional | When it happened (ISO 8601). Defaults to now; can't be in the future. |
id | optional | Your own id, such as an order number. An id is recorded once, so retries are safe. |
contact | optional | name, first_name, last_name, company, phone, website, tags and custom fields. On an existing contact these only fill blanks and add tags. |
create_contact | optional | true adds the person as a lead if they aren't a contact yet. |
convert | optional | true makes them a customer. A sequence they are in ends as converted, and the email that earned it gets the credit. |
sequence_id | optional | Enrols them in this sequence, after any conversion. |
Unknown fields are refused, so a typo shows up as an error instead of being lost.
Answers#
Every accepted event answers 200 with a status:
recorded: the event is on the timeline. The answer has the contact (id,email,stage, whether it wascreatedorupdated), whether they wereconverted, and withsequence_id, anenrollmentsaying whether they were enrolled and, if not, why.ignored: they aren't a contact andcreate_contactwasn't set.duplicate: an event with thisidwas recorded before; nothing changed.
Being left out of a sequence never fails the event. The usual reasons are that they are already in a sequence, were in this one before, or unsubscribed.
Errors#
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION | Something in the request is wrong; the message says what. |
| 401 | INVALID_KEY, KEY_REVOKED | The key is wrong or was revoked. |
| 403 | KEY_CREATOR_NO_ACCESS | Whoever made the key has left or lost access. Make a new key. |
| 403 | FEATURE_NOT_AVAILABLE, SUBSCRIPTION_INACTIVE | The plan doesn't include the API, or the subscription isn't active. |
| 403 | CRM_CONTACTS_LIMIT | The workspace is at its contact limit. |
| 429 | RATE_LIMITED | More than 300 events a minute on one key. Wait for the Retry-After seconds. |
Retry on network errors, 429 and 5xx, with the same id, so nothing is recorded twice.
Other calls#
GET /crm/events/checkconfirms a key works and returns the workspace's name. Useful for a "Test connection" button.GET /crm/events/sequenceslists the running and paused sequences the key can enrol people in, for a "choose a sequence" setting.
Both take the same Authorization header.
See what arrived#
The API tab lists the latest events: who they were about, which key sent them, and whether they added, converted or enrolled someone.
Automate with events#
AutoFlow's Event Received trigger runs a flow when an event arrives, filtered by its name. The flow can read the event's properties, for example to notify your team in Team Chat when someone buys a particular plan.
Was this page helpful?
Let us know if you found what you were looking for.