5 min read

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
  }'
FieldWhat it does
emailrequiredWho the event is about.
eventrequiredWhat happened, such as signup or purchase. Stored in lower case with spaces as underscores.
propertiesoptionalUp to 25 simple values: text, numbers, true or false. Shown on the timeline.
occurred_atoptionalWhen it happened (ISO 8601). Defaults to now; can't be in the future.
idoptionalYour own id, such as an order number. An id is recorded once, so retries are safe.
contactoptionalname, first_name, last_name, company, phone, website, tags and custom fields. On an existing contact these only fill blanks and add tags.
create_contactoptionaltrue adds the person as a lead if they aren't a contact yet.
convertoptionaltrue makes them a customer. A sequence they are in ends as converted, and the email that earned it gets the credit.
sequence_idoptionalEnrols 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 was created or updated), whether they were converted, and with sequence_id, an enrollment saying whether they were enrolled and, if not, why.
  • ignored: they aren't a contact and create_contact wasn't set.
  • duplicate: an event with this id was 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#

StatusCodeMeaning
400VALIDATIONSomething in the request is wrong; the message says what.
401INVALID_KEY, KEY_REVOKEDThe key is wrong or was revoked.
403KEY_CREATOR_NO_ACCESSWhoever made the key has left or lost access. Make a new key.
403FEATURE_NOT_AVAILABLE, SUBSCRIPTION_INACTIVEThe plan doesn't include the API, or the subscription isn't active.
403CRM_CONTACTS_LIMITThe workspace is at its contact limit.
429RATE_LIMITEDMore 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/check confirms a key works and returns the workspace's name. Useful for a "Test connection" button.
  • GET /crm/events/sequences lists 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.