---
title: Events
description: Send custom events for a contact to start or continue automations, and define an event's payload schema so its values arrive typed.
seo:
  title: Custom events API
---

An event is something that happened to a contact in your own product: they signed up, paid, abandoned a cart. You send it with `POST /events/send`, and [automations](/docs/concepts/automations) react: an enabled automation whose `trigger` names the event starts a run, and a run waiting for that event goes on. The event's `payload` is data the automation reads as `event.<key>`.

## Send an event

```sh
curl -X POST https://api.billionsend.com/events/send \
  -H "Authorization: Bearer $BILLIONSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: signup/ana" \
  -d '{
    "event": "user.signed_up",
    "email": "success@simulator.amazonses.com",
    "payload": { "plan": "pro", "seats": 5 }
  }'
```

The answer is `202` with `{ "object": "event", "event": "user.signed_up" }`: the event is recorded, and runs start shortly after. Nothing about the event is checked against automations when you send it, so the answer does not say how many runs started.

- **`event`** is the name: 1 to 255 characters, case sensitive (`User.Signed_Up` is another event). Names that start with `billionsend:` or another system prefix are reserved and answer `422`.
- **`contact_id` or `email`**: give exactly one, or the request answers `422`.
- **`payload`** is a JSON object of at most **32 KB** and 8 levels of nesting. Leave it out for `{}`.

Event names that no definition and no automation knows are accepted all the same, so a typo in a name starts nothing and raises no error.

## Which contact

With `contact_id`, the contact must belong to your team, or the answer is `404`. With `email`, the address matches a contact without regard to case. If there is none, the contact is created **when an automation needs one**: only when at least one enabled automation starts on this event. The new contact has `source: "api"` and counts toward your plan's contact limit.

If the contact cannot be created (the plan's contact limit is reached, or the address cannot receive mail) the event is recorded as `dropped` and is not retried.

## Define an event and its schema

A definition is optional. It gives an event a name you can list and a `schema` that types the payload.

```sh
curl -X POST https://api.billionsend.com/events \
  -H "Authorization: Bearer $BILLIONSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "order.placed",
    "schema": { "total": "number", "currency": "string", "placed_at": "date", "gift": "boolean" }
  }'
```

The answer is `201` with `{ "object": "event", "id": "..." }`. A second definition with the same name answers `409`. A team may define at most **1,000** events. `schema` is a flat map from a payload key to `string`, `number`, `boolean` or `date`, with at most 100 keys of 1 to 128 characters each. Leave `schema` out, or send `null`, for an event with none.

When an event has a schema, `events.send` checks the payload against it and converts each typed value **before** the automation sees it:

| Type | Accepts | Becomes |
| --- | --- | --- |
| `string` | text, a number or a boolean | text |
| `number` | a number, or text such as `"19.5"` | a number |
| `boolean` | `true`, `false`, or the text `"true"` or `"false"` | a boolean |
| `date` | ISO 8601 text, with or without a time and zone (none means UTC) | UTC ISO text, such as `2026-11-18T09:30:00.000Z` |

A value that does not fit, including `null`, answers `422` and names the key (`payload.total must be a number.`); the event is not recorded. Keys the schema does not name pass unchanged, and a key it names may be left out. The schema is read only when an event is sent: changing it never touches a run in flight.

## Read, change and delete definitions

| Operation | |
| --- | --- |
| `GET /events` | The definitions, newest first, with `limit` (1 to 100, default 20) and `after` or `before` cursors. |
| `GET /events/{id_or_name}` | One definition, by its id or its name. A name that contains `/` or `%` must be URL-encoded. |
| `PATCH /events/{id_or_name}` | Replaces the `schema` (`null` clears it). The name cannot change. |
| `DELETE /events/{id_or_name}` | Deletes the definition. Automations match by name, so they keep working; the payload is just no longer checked or converted. |

## Retries and idempotency

Sending the same event twice is two events, and each starts its own runs. When a request may be repeated, add an **`Idempotency-Key`** header of 1 to 256 characters (a longer or empty key answers `400 invalid_idempotency_key`). A repeat with the same key and the same body within 24 hours answers `202` again and records nothing new. The same key with a different body answers `409 invalid_idempotent_request`, and a repeat while the first request is still running answers `409 concurrent_idempotent_requests`. Event keys are kept apart from the keys of emails: using one key for both does not clash.

## What happens next

Events are handled in the background, in batches, a moment after they arrive. For each event:

1. Every enabled automation with a `trigger` for this name starts a run for the contact, with the payload kept for `event.*`. Disabled and deleted automations start nothing, and stopping or enabling takes effect for the next event.
2. Every run of that contact that is waiting in a `wait_for_event` for this name, and whose `filter_rule` the event passes, goes on.

One event may do both. A contact who unsubscribed or is suppressed still triggers runs: it is the `send_email` step that skips them (see [Automations](/docs/concepts/automations#sending-rules)).

An event ends `processed`, or `dropped` when it started and resumed nothing for a reason that retrying does not fix: the contact was deleted before the event was handled, the contact could not be created (above), the address cannot receive mail, or 20 runs of the automation were already open for the contact. A failure inside BillionSend is retried with growing pauses and, after 10 attempts, the event is marked `dead` and BillionSend is alerted.

## Retention and replay

Event records are kept for **14 days** and then removed. The API does not list or read them back: what you see afterward is the runs they started, under `GET /automations/{id}/runs`.

A `dropped` or `dead` event did nothing, so running it again cannot count it twice. Replay them from the dashboard: **Events → Inbox** lists every dead and dropped event with its reason and last error; select one and choose **Replay event**, or use **Replay N events** to replay every dead event at once. Members with the marketing role or above can replay. You can also send the event again with a new `Idempotency-Key`. An event dropped for `contact_limit` or `undeliverable` is dropped again on replay until the cause is fixed. A replayed event keeps its original arrival time, so a run that began waiting for the event only after it arrived does not take it.

## Who can use it

- **API keys.** `POST /events/send` needs a full-access key that is not limited to one domain; a restricted key gets `403 restricted_api_key`. Sending needs no particular role, and the same holds for a signed-in app on [MCP](/docs/mcp) (`send_event`, permission `events:send`).
- **Definitions.** In the dashboard and on MCP, creating, changing and deleting definitions is for owners, admins and marketing members; every member can read them. An API key is not checked against a role. See [Team roles](/docs/team-roles).
- **Rate limit.** Events share the API's per-minute limit: 600 requests per key and 3,000 per team. There is no batch endpoint.

## Limits

| What | Limit |
| --- | --- |
| Event name | 1 to 255 characters; `billionsend:` and other system prefixes reserved |
| Payload | 32 KB, 8 levels of nesting |
| Schema | 100 keys, each 1 to 128 characters |
| Definitions per team | 1,000 |
| Idempotency key | 1 to 256 characters, kept 24 hours |
| Event records | 14 days |
| Open runs of one automation for one contact | 20 |
