# Forward events to your machine

Canonical page: https://docs.ovok.com/cli/forward-events

<Effort complexity={1} clients="Terminal" time="5 minutes" />

`ovok listen` forwards events to your machine and removes everything it created when you stop it.

## Set up [Terminal] [#set-up-terminal]

[Install the ovok command and sign in](/cli). Signals routes need a manager app, and FHIR Subscriptions need an app whose [access policy](/access-policies/signals) can create one.

## Forward FHIR events [Terminal] [#forward-fhir-events-terminal]

Pass one `--fhir` criteria for each resource type to watch, and the local URL that receives them:

```bash
ovok listen --fhir Observation --forward-to http://localhost:3000/fhir
```

- `listen` opens a FHIR WebSocket Subscription for each `--fhir` and posts each resource to `--forward-to`.
- Each request is signed with `X-Signature`, the way a rest-hook Subscription is signed.
- Set `OVOK_LISTEN_SECRET` to sign with your own secret. Otherwise `listen` makes one and prints it.
- Each event prints one line: the time, the resource type and id, the status your endpoint answered and how long it took. The body is never printed.

## Forward Signals events [Terminal] [#forward-signals-events-terminal]

Signals posts to the webhook itself, so give `--signals-url` a public address, such as a tunnel to your machine:

```bash
ovok listen --signals-url https://{{TUNNEL_HOST}}/signals --signals-event alert.triggered
```

- `listen` creates a temporary Signals webhook and prints its signing secret.
- Without `--signals-event`, it sends `alert.*`.
- `--signals-reach all` reaches every resident, and `--signals-reach attached` only those attached to the webhook.

Use both groups of options to receive both kinds of events in one run.

## Control the session [Terminal] [#control-the-session-terminal]

While `listen` runs in a terminal:

- `r` resends the last FHIR event.
- `c` clears the screen.
- `q` or Ctrl+C stops it and removes the Subscriptions and webhook it created.

A second Ctrl+C quits at once and leaves whatever was not removed yet. `listen` names anything it could not remove, so you can delete it yourself.

## Test your integration [#test-your-integration]

| Scenario | How to trigger it | Expected result |
| --- | --- | --- |
| FHIR event arrives | Create an `Observation` in your sandbox project | A line with the resource and your endpoint's status |
| Resend | Press `r` | The same event is posted again |
| Signals event arrives | Run `ovok webhooks test <id>` for the webhook `listen` created | A delivery reaches your tunnel |
| Cleanup | Press `q` | `listen` prints a line for each Subscription and webhook it removed |

## See also [#see-also]

- [Listen for events](/cli/reference/listen)
- [Manage Signals webhooks](/cli/reference/webhooks)
- [Sign in](/cli/reference/login)
- [Signals access policies](/access-policies/signals)
