Custom events

A custom events API that starts your email automations.

Custom events are things that happened in your product: a sign-up, a payment, an abandoned cart. Send one with a single call and every enabled automation that listens for it starts a run for that contact. A run that waits for it goes on. Behavioral email follows from that: what a person does decides what they get.

Free plan with 100 emails a day. No credit card.

import { BillionSend } from "@billionsend/node";
const bs = new BillionSend(); // reads BILLIONSEND_API_KEY
const { error } = await bs.events.send(
{
event: "user.signed_up",
email: "ana@example.com",
payload: { plan: "pro", seats: 5 },
},
{ idempotencyKey: "signup/ana" },
);
if (error) throw error;

// 202 { "object": "event", "event": "user.signed_up" }

  • 32KB of payload per event
  • 1,000event definitions per team
  • 14days event records are kept
  • 600requests a minute per API key

How it works

From one of your custom events to a run.

Defining an event is optional. Sending one is a single call.

  1. 01

    Define it, if you want types

    POST /events names an event and gives it a schema: a flat map from each payload key to string, number, boolean or date.

  2. 02

    Send it

    POST /events/send takes the event name, a contact id or an email address and a payload. The answer is 202 as soon as the event is recorded.

  3. 03

    Automations react

    Every enabled automation that starts on that name starts a run, and every run waiting for it goes on. The payload is readable in the steps as event.<key>.

Endpoints and limits

One call to send, four to manage.

Events share the API's rate limit, and there is no batch endpoint.

CallWhat it doesLimitWho can call it
POST /events/sendRecord an event for a contact. A contact that does not exist is created when an automation needs one.32 KB of payload, 8 levels deepA full-access key not limited to one domain; no role needed
POST /eventsDefine an event with a schema that types its payload.1,000 definitions per teamA full-access key; in the dashboard and over MCP, owners, admins and marketing
GET /eventsList the definitions, newest first.Pages of up to 100A full-access key; in the dashboard and over MCP, every member
PATCH /events/{id_or_name}Replace the schema, or clear it with null. The name cannot change.Applies to events sent afterwardsA full-access key; in the dashboard and over MCP, owners, admins and marketing
DELETE /events/{id_or_name}Delete the definition. Automations match by name, so they keep working.The payload is no longer checkedA full-access key; in the dashboard and over MCP, owners, admins and marketing

In your code

Handle what comes back.

The call answers at once. What happens to the event afterwards shows in the dashboard.

  • 202The event is recorded. Matching happens in the background, so the answer does not say how many runs started.
  • 409invalid_idempotent_request: the Idempotency-Key was used with a different body. Send the same body, or use a new key.
  • 422A typed value does not fit its schema, or the name is reserved. The message names the key, and the event is not recorded.
  • droppedThe event could do nothing and a retry would not help: the contact was deleted, the contact limit is reached, the address cannot receive mail or too many runs are open. Replay it from the dashboard once the cause is fixed.
  • deadBillionSend failed to handle it after repeated tries and has been alerted. It sits in the Events inbox, ready to replay.
HTTP 422 · a typed value that does not fit
{
"statusCode": 422,
"name": "validation_error",
"message": "payload.total must be a number."
}

Where it fits

Use custom events for anything your product knows first.

  1. 01

    Sign-up and activation

    Send user.signed_up and user.activated, and let a flow welcome the person and nudge them only if they stall.

  2. 02

    Orders and carts

    Define order.placed with a total and a currency, and branch on the amount in the flow.

  3. 03

    Billing

    Send an event when a payment fails or a trial ends, and start the reminder flow for that contact.

  4. 04

    Agents

    An agent sends events with the send_event MCP tool, and writes the drafts of the automations that react to them.

Before you ship

Plan for keys, limits and typos.

  • HTTP 403Key scope

    Sending needs a full-access key that is not limited to one domain. A restricted key gets 403 restricted_api_key.

  • HTTP 429Rate limit

    Events count against the API's limit of 600 requests a minute per key. There is no batch endpoint.

  • Idempotency-KeySafe retries

    A repeat with the same key and body within a day answers 202 again and records nothing new. Without a key, sending twice is two events and starts two runs.

  • NamesA typo starts nothing

    A name no definition and no automation knows is accepted all the same, so a misspelled event raises no error. Define your events to get a list of names.

Around the event

What it starts, and who can send it.

An event does nothing alone until an automation listens.

  • Automations

    Build the flow an event starts: send, wait, branch and update the contact. A new automation starts disabled.

    Automations
  • MCP server

    Connect an agent and it can send events and define them, with an agent key that can send. Enabling an automation stays with a person.

    MCP server

FAQ

Questions, answered.

Something missing? Ask us at support@billionsend.com.

Send your first email in five minutes.