> ## Documentation Index
> Fetch the complete documentation index at: https://relay-demo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Receive webhooks on localhost, send test events and replay failed deliveries.

```bash theme={null}
npm install -g relay-cli
relay login
```

`relay login` opens the dashboard in your browser and stores a restricted key for the CLI in `~/.config/relay`.

## Forward webhooks to your machine

```bash theme={null}
relay listen --forward-to localhost:3000/webhooks
```

The CLI opens a connection to Relay and forwards every test-mode event to your local server, signed with a session secret it prints when it starts. Add `--events invoice.*,customer.created` to forward only some types.

![Sequence diagram between Relay, the Relay CLI and a local server on your laptop: relay listen opens an outbound connection to Relay and prints a session signing secret; you send a test event with relay events send or an rk\_test\_ key; Relay sends every test-mode event over the connection, signed with the session secret; the CLI posts it to localhost:3000/webhooks, where the server verifies the signature and answers 200.](https://mintcdn.com/relay-demo/EZNTzLZZIWlaFK8l/images/cli-listen.png?fit=max\&auto=format\&n=EZNTzLZZIWlaFK8l\&q=85\&s=5b6c3ec632979fd6db0179e004f5b962)

The CLI connects out to Relay, so your laptop needs no public URL. Test-mode events come down that connection and the CLI posts them to your local server.

## Send a test event

```bash theme={null}
relay events send invoice.paid --data '{"invoice_id": "inv_123", "amount": 4900}'
```

## Replay deliveries

```bash theme={null}
relay deliveries list --status failed --since 24h
relay deliveries replay dlv_8Hc1Rm
```

## Commands

| Command | Does |
| - | - |
| `relay listen` | Forwards webhooks to a local URL. |
| `relay events send <type>` | Sends an event. |
| `relay events get <id>` | Shows an event and its deliveries. |
| `relay deliveries list` | Lists deliveries, filtered by `--status`, `--endpoint` and `--since`. |
| `relay deliveries replay <id>` | Sends a delivery again, as a new attempt. |
| `relay endpoints list` | Lists endpoints and their subscriptions. |


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