# Replay a failed delivery

Replay a failed delivery

`POST https://api.cadmospay.com/machine/v1/gateway/webhooks/replay`

Queues one replacement per failed delivery ID, with the original business event ID. Further retries return that replacement. Replay its ID if the replacement also fails. Only the registered callback receives deliveries.

## Authentication

`Authorization: Bearer <accessToken>`

The `accessToken` from `POST /v1/external-auth/token`, valid 15 minutes.

## Example requests

```bash
curl --fail-with-body 'https://api.cadmospay.com/machine/v1/gateway/webhooks/replay' \
  -H "Authorization: Bearer ${CADMOS_ACCESS_TOKEN:?Set CADMOS_ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  --data-binary @- <<JSON
{
  "deliveryId": 1
}
JSON
```

```javascript
const { CADMOS_ACCESS_TOKEN } = process.env;
if (!CADMOS_ACCESS_TOKEN) {
  throw new Error("Set CADMOS_ACCESS_TOKEN");
}

const url = new URL("https://api.cadmospay.com/machine/v1/gateway/webhooks/replay");
const body = {
  "deliveryId": 1
};
const response = await fetch(url, {
  method: "POST",
  redirect: "error",
  headers: {
    Authorization: "Bearer " + CADMOS_ACCESS_TOKEN,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(body),
});
console.log(response.status, await response.json());
```

```python
from http.client import HTTPSConnection
import json
import os

conn = HTTPSConnection("api.cadmospay.com", timeout=30)
path = "/machine/v1/gateway/webhooks/replay"
body = json.dumps({
  "deliveryId": 1
})
headers = {
    "Authorization": "Bearer " + os.environ["CADMOS_ACCESS_TOKEN"],
    "Content-Type": "application/json",
}
conn.request("POST", path, body=body, headers=headers)
response = conn.getresponse()
print(response.status, response.read().decode())
conn.close()
```

## Request body

`application/json`

[ReplayRequest](https://cadmospay.com/developers/schemas/replay-request.md)

Only the listed properties are accepted.

- `deliveryId` (integer, required, value 1 to 2147483647). 

## Responses

### 202

Replay a failed delivery

[WebhookDelivery](https://cadmospay.com/developers/schemas/webhook-delivery.md)

```json
{
  "deliveryId": 42,
  "eventId": "test-11111111-2222-4333-8444-555555555555",
  "type": "gateway.test",
  "status": "sent",
  "attempts": 1,
  "createdAt": "2026-10-01T12:00:00Z",
  "lastUpdatedAt": "2026-10-01T12:01:00Z",
  "sentAt": "2026-10-01T12:01:00Z",
  "nextAttemptAt": null,
  "outcome": null,
  "replayedBy": null
}
```

### 401

No token, or a token that is expired or not for this route: sign in again.

[Error](https://cadmospay.com/developers/schemas/error.md)

### 403

Your identity is not allowed this route, or has no business wallet.

[Error](https://cadmospay.com/developers/schemas/error.md)

### 404

No matching delivery for this wallet.

[Error](https://cadmospay.com/developers/schemas/error.md)

### 409

The delivery has no failed attempt or the callback is unavailable.

[Error](https://cadmospay.com/developers/schemas/error.md)

### 422

The request does not match this contract: `VALIDATION_ERROR` lists each field and the rule it broke. An amount outside $0.50 to $1,000,000 is refused here too.

[Error](https://cadmospay.com/developers/schemas/error.md)

### 429

Over a limit. Wait and retry.

[Error](https://cadmospay.com/developers/schemas/error.md)
