# Quickstart

Create an inbox, route events into it, and pull, work and acknowledge one event.

You'll create an inbox, send an event into it, and have an agent pull it and acknowledge it.

## 1. Create an inbox

In the dashboard, open **Destinations → New destination** and choose **Inbox**. An inbox has no URL: events wait in it until an agent asks for them. Or create one with the API:

```bash
curl -X POST https://api.getensue.com/v1/agent/inbox \
  -H "authorization: Bearer $ENSUE_API_KEY" \
  -H "content-type: application/json" \
  -d '{"name":"billing-agent"}'
```

## 2. Route events into it

Create a [flow](/gateway/quickstart/) from a source to the inbox, the same way you would to any destination. Events from that source now wait in the inbox.

## 3. Pull an event

```bash
curl "https://api.getensue.com/v1/agent/inbox/$INBOX_ID/next?wait=30" \
  -H "authorization: Bearer $ENSUE_API_KEY"
```

The call waits up to 30 seconds for an event, then returns it as an [envelope](/agents/inbox-and-leases/#the-event-envelope) with a `lease_id`. While the lease is open, no other consumer receives the event.

## 4. Acknowledge it

When the work is done:

```bash
curl -X POST https://api.getensue.com/v1/events/$EVENT_ID/ack \
  -H "authorization: Bearer $ENSUE_API_KEY" \
  -H "content-type: application/json" \
  -d '{"lease_id":"'$LEASE_ID'"}'
```

If the agent crashes first, the lease runs out and the event comes back.

> [!IMPORTANT]
> Delivery is at-least-once. Use the event `id` as a dedupe key so a repeat doesn't do the work twice.