# Hooks and events

> Get called when something happens on a job.

## Events

Everything that happens to a job is recorded as an event: created, assigned, started, a node reached, an action completed, canceled. Read them with [`GET /engine/jobs/{jobId}/events`](https://docs.remi.robot.com/engine/reference#listJobEvents), oldest first. Event ids are time-ordered.

## Hooks

A hook calls your URL when an event matches its filters. Add it when you create the job (`hooks`) or later with [`POST /engine/jobs/{jobId}/hooks`](https://docs.remi.robot.com/engine/reference#addHook):

```json
{
  "name": "notify-arrival",
  "eventType": ["node_arrived"],
  "nodeName": ["dropoff"],
  "target": "https://example.com/hooks/remi",
  "metadata": { "webhook": { "method": "POST", "headers": { "X-Key": "your-secret" } } }
}
```

- Filters: `eventType`, `nodeName`, `actionName`, `actionType`, `packageName` and `jobState`. A filter you leave out matches everything.
- An `https://` target is a webhook. Put your secret in `metadata.webhook.headers`: calls are not signed.
- The body is `{ timestamp, event, hook, jobId }`, with the [Event](https://docs.remi.robot.com/engine/reference#type-Event) that fired it.

## Order

Hooks of one job that share a `queueName` run one at a time, in event order, and a failing call is retried before the next one runs. Without a `queueName`, hooks run concurrently.

The [Delivery API's webhooks](https://docs.remi.robot.com/delivery/webhooks) are hooks like these, on one queue per delivery.
