# Receiving webhooks

Miare sends events to your application through HTTP callbacks. Give the technical team a
receiver URL on your servers to enable delivery.

Events are sent as HTTP `POST` requests with a JSON body. Use the top-level `event` field to
identify the payload:

| Event group | Payload | Events |
|-------------|---------|--------|
| [Trip](/webhooks) | `trip`; delegated issue events also include `issue` | Trip creation, assignment, pickup, delivery, course changes, cancellation, `trip_issue_reported`, and `trip_issue_resolved`; availability depends on account configuration. |
| [Course](/webhooks) | `course` | `course_added__course` |
| [Issue](/webhooks) | `issue` | `issue_added`, `issue_picked`, `issue_message_added`, `issue_resolved` |
| [Area](/webhooks) | `area` | `area_radius_changed` |
| [Financial](/guides/accounting#financial-events) | Batch identifiers, `financials`, and `changes` | `financial_calculated`, `financial_adjusted` |

## Authentication

> Authentication header:

```
Authorization: Token <your token>
```

Webhook requests use `Authorization: Token <your token>`. Explicitly configured tokenless trip callbacks are the only exception; issue, area and financial callbacks require the header.

:::caution

Reject requests without the expected `Authorization` header unless tokenless trip callbacks
have explicitly been configured for your account.

:::

## Versioning

> Version header:

```
X-Miare-API-Version: 2
```

Trip, course, issue, and area events include `X-Miare-API-Version: 2`.
Financial events do not include this header. Identify them using the `event` field;
their `revision` field tracks financial changes within a batch, not the API version.

## Retry

We ignore the response body of the request made to your servers. Return a `2XX` response code
after accepting an event.

For trip, course, issue, and area events, HTTP `500` responses trigger up to five retries with
five seconds between attempts. Do not rely on the same retry behavior for every `5XX` status.

Financial events use a separate delivery policy: any non-`2XX` response or network failure is
retried, with a ten-second request timeout. Retry delays are configurable; the defaults are
30, 120, 300, 900, and 1800 seconds after successive failures. Retries preserve the original
payload. Delivery can be duplicated or arrive out of order; see [Financial Events](/guides/accounting#financial-events)
for revision handling.

:::note

You should not rely solely on webhook requests. After a network failure or a long service outage,
recover trip lifecycle state using [List Trips](/api/public/delivery#list-trips) and issue state using
[List Issues](/api/public/support#list-issues). For financial data, use
the recovery endpoint described under [Financial Events](/guides/accounting#financial-events).

:::

## Processing events

Validate the expected authorization token, inspect `event`, and persist the accepted notification before returning a `2XX` response. Treat callbacks as potentially duplicated and out of order. For trip, course, issue and area callbacks, the payload is a current snapshot reloaded before delivery; the event name does not guarantee the current state.

`course_added` contains a trip snapshot, while `course_added__course` contains one course. Delegated issue events include the trip and a restricted `issue` object; `issue_*` callbacks use their own issue snapshot and omit message history.

The old reference listed `returning` and `canceled_by_delay` as standalone webhook names. The current Go service does not emit those names. They remain trip states; recover current lifecycle state with List Trips. Do not wait for a dedicated callback to learn every transition.

The [webhook reference](/webhooks) contains the event schemas, required headers and examples. [Financial events](/guides/accounting#financial-events) have their own revision, retry and recovery rules.
