> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nelkap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Events and webhooks

> Start workflows and wake waiting runs with events.

## Emit an event

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
const { runIds } = await nelkap.emit({ event: 'user.created', payload: 'user_42' });
```

Every workflow listening for `user.created` starts a run, with the event's payload and tags. `emit` returns the ids of those runs.

## Wake waiting runs

Add `wakeOn` to wake the runs waiting on a key:

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
await nelkap.emit({ event: 'refund.reviewed', payload: { approved: true }, wakeOn: 'refund_ord_42' });
```

Every run waiting on `refund_ord_42` goes on, and its [`step.wait`](https://docs.nelkap.com/reference/step-wait) returns the payload. The same event also starts the workflows listening for `refund.reviewed`.

## Webhooks

A webhook turns calls from another service into an event. Create a webhook, choose the event it emits, and give its URL to the service.

Each call to that URL emits the event, with the call's JSON body as its payload. Every workflow listening for it starts a run.

* The URL holds the webhook's secret. Rotate it, and the old URL stops working at once.
* Set allowed IPs to accept calls only from the service's addresses.

## Follow your events

Events lists every event, with the runs it started.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.