# Webhooks we send

> Every event PerfectRide sends to your webhook URL, with an example, retries and signing.

## Delivery

|   | Rule |
|---|---|
| Method | `POST` to your webhook URL, `Content-Type: application/json` |
| Signature | Signed like every call with your webhook secret and path `/`, whatever your URL's path |
| Envelope | Every event has `event`, `event_id` and `occurred_at` |
| Success | Any 2xx within 8 seconds. Redirects are not followed |
| Retries | 30 seconds, then doubling, at most 1 hour apart, for 24 hours |
| Repeats | The `event_id` never changes between retries. Ignore one you have already handled |
| Ordering | Not guaranteed. Use `occurred_at` and the current state, not arrival order |

**Node**

```javascript
const seen = new Set(); // use your database

app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const raw = req.body.toString("utf8");
  // Our webhook calls are signed with path "/", whatever your URL is.
  if (!prVerify(process.env.PR_SECRET, "POST", "/", raw, req.headers)) return res.sendStatus(401);
  const e = JSON.parse(raw);
  if (!seen.has(e.event_id)) {
    seen.add(e.event_id);
    handle(e); // driver.paused, statement.ready, trip.rider_contact, ...
  }
  res.sendStatus(200); // any 2xx stops our retries
});
```

**Python**

```python
seen = set()  # use your database

@app.post("/webhook")
def webhook():
    raw = request.get_data(as_text=True)
    # Our webhook calls are signed with path "/", whatever your URL is.
    if not pr_verify(os.environ["PR_SECRET"], "POST", "/", raw, request.headers):
        return "", 401
    e = json.loads(raw)
    if e["event_id"] not in seen:
        seen.add(e["event_id"])
        handle(e)  # driver.paused, statement.ready, trip.rider_contact, ...
    return "", 200  # any 2xx stops our retries
```

**PHP**

```php
<?php
$raw = file_get_contents('php://input');
// Our webhook calls are signed with path "/", whatever your URL is.
if (!pr_verify(getenv('PR_SECRET'), 'POST', '/', $raw)) { http_response_code(401); exit; }
$e = json_decode($raw, true);
if (!event_seen($e['event_id'])) { // use your database
    mark_event_seen($e['event_id']);
    handle($e); // driver.paused, statement.ready, trip.rider_contact, ...
}
http_response_code(200); // any 2xx stops our retries
```

## Events

| Event | When | Fields |
|---|---|---|
| `trip.rider_contact` | Live trips, when a driver is assigned, and again on reassign | `pr_trip_id`, `partner_trip_id`, `rider { first_name, phone }` |
| `driver.paused` | PerfectRide paused a driver | `driver_id`, `reason` (rider_complaints, low_ratings, safety_review, documents, other), `until` (or null) |
| `driver.reinstated` | The pause ended | `driver_id` |
| `partner.balance_due` | You owe us at the end of a period, or you passed your credit limit | `amount_due`, `currency`, then `period_start` and `period_end`, or `reason: "credit_limit"` |
| `account.status_changed` | Your account status changed | `from`, `to` (sandbox, in_review, pilot, live, paused), `reason` (optional) |
| `statement.ready` | Once a day, for the day before (WAT) | `date`, `trips`, `amount` (what we owe you, kobo), `currency` |

**Example: trip.rider_contact**

**Body**

```json
{
  "event": "trip.rider_contact",
  "event_id": "evt_0b6f2c4e-...",
  "occurred_at": "2026-12-03T10:01:13Z",
  "pr_trip_id": "pr_55a9",
  "partner_trip_id": "t_9931",
  "rider": { "first_name": "Ada", "phone": "+2348031234521" }
}
```

**Example: driver.paused**

**Body**

```json
{
  "event": "driver.paused",
  "event_id": "evt_6a1e...",
  "occurred_at": "2026-12-03T12:00:00Z",
  "driver_id": "d_771",
  "reason": "rider_complaints",
  "until": null
}
```

**Example: partner.balance_due**

**Body**

```json
{
  "event": "partner.balance_due",
  "event_id": "evt_91c3...",
  "occurred_at": "2026-12-08T06:00:00Z",
  "amount_due": 1250000,
  "currency": "NGN",
  "period_start": "2026-12-01T00:00:00.000Z",
  "period_end": "2026-12-08T00:00:00.000Z"
}
```

**Example: account.status_changed**

**Body**

```json
{
  "event": "account.status_changed",
  "event_id": "evt_2d7a...",
  "occurred_at": "2026-12-10T09:00:00Z",
  "from": "in_review",
  "to": "pilot"
}
```

**Example: statement.ready**

**Body**

```json
{
  "event": "statement.ready",
  "event_id": "evt_7f3a...",
  "occurred_at": "2026-12-04T06:00:00Z",
  "date": "2026-12-03",
  "trips": 38,
  "amount": 21450000,
  "currency": "NGN"
}
```

> **Tip:** New fields may appear at any time. Ignore ones you don't recognise.

## Next

- [Events you send](https://docs.perfectride.io/docs/events-you-send.md): Every trip event PerfectRide accepts at the events URL, with its fields.
- [Keys and signing](https://docs.perfectride.io/docs/keys-and-signing.md): Which key goes where, and how every request is signed in both directions.
- [Money and statements](https://docs.perfectride.io/docs/money.md): How you are paid: the quoted price, your commission, statements, payouts and the credit limit.

Source: https://docs.perfectride.io/docs/webhooks
