# Redeliver

POST /v1/webhook-deliveries/{deliveryId}/redeliver. Sends a delivery again, with the same event id, starting from its first attempt.

`POST https://api.chatwise.so/v1/webhook-deliveries/{deliveryId}/redeliver`

Sends a delivery again, with the same event id, starting from its first attempt. It can be delivered, failed, cancelled or waiting for a retry. A delivery to a paused or disabled endpoint waits until the endpoint is active.

The API key needs the `webhooks:write` scope. It also needs `messages:read` when the delivery is for a `message.*` event. See [authentication and scopes](https://chatwise.so/docs/authentication.md).

## Example

**curl**:

```bash
curl -X POST 'https://api.chatwise.so/v1/webhook-deliveries/wd_3f1c0a9b5d7e42688c1f0e2d4b6a8c90/redeliver' \
  -H "Authorization: Bearer $CHATWISE_API_KEY"
```

**Node.js**:

```js
const response = await fetch("https://api.chatwise.so/v1/webhook-deliveries/wd_3f1c0a9b5d7e42688c1f0e2d4b6a8c90/redeliver", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CHATWISE_API_KEY}`,
  },
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${body.message}`);
console.log(body.data);
```

**Python**:

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://api.chatwise.so/v1/webhook-deliveries/wd_3f1c0a9b5d7e42688c1f0e2d4b6a8c90/redeliver",
    method="POST",
    headers={
        "Authorization": f"Bearer {os.environ['CHATWISE_API_KEY']}",
    },
)
with urllib.request.urlopen(request) as response:
    print(json.load(response)["data"])
```

## Path parameters

| Name | Type | Description |
| --- | --- | --- |
| `deliveryId` | string | **Required.** The delivery's id (`wd_…`). |

## Response

**200.** The delivery, waiting to be sent.

```json
{
  "data": {
    "id": "wd_3f1c0a9b5d7e42688c1f0e2d4b6a8c90",
    "eventId": "evt_01JE2Z3QK4T8M6N2R5S7V9W1X3",
    "eventType": "message.received",
    "occurredAt": "2026-11-12T09:25:36.000Z",
    "status": "PENDING",
    "attempts": 0,
    "lastStatusCode": 503,
    "lastError": null,
    "lastDurationMs": 214,
    "nextAttemptAt": "2026-11-12T10:02:11.000Z",
    "deliveredAt": null,
    "createdAt": "2026-11-12T09:25:37.000Z",
    "endpointId": "we_01JE2Z3K8Q9V7W5X4Y3Z2A1B0C",
    "payload": {
      "message": {
        "id": "5678",
        "conversationId": "1234",
        "channel": "WHATSAPP",
        "direction": "inbound",
        "type": "text",
        "text": "Is this available in blue?",
        "sentAt": "2026-11-12T09:25:36.000Z",
        "ingestedAt": "2026-11-12T09:25:36.412Z",
        "replyToMessageId": null,
        "attachments": []
      },
      "conversation": {
        "id": "1234",
        "channel": "WHATSAPP",
        "status": "open",
        "participant": {
          "name": "Jordan Example",
          "channelId": "12025550147",
          "phoneNumber": "12025550147",
          "instagramUsername": null
        },
        "createdAt": "2026-11-01T09:12:00.000Z",
        "lastMessageAt": "2026-11-12T09:25:36.000Z"
      },
      "account": {
        "id": "11",
        "channel": "WHATSAPP"
      }
    },
    "attemptLog": [
      {
        "attemptNumber": 1,
        "startedAt": "2026-11-12T09:25:37.120Z",
        "durationMs": 214,
        "statusCode": 503,
        "error": "http_503"
      }
    ]
  }
}
```

| Field | Type | Description |
| --- | --- | --- |
| `data.id` | string | The delivery's id, also sent as the `X-Chatwise-Delivery` header. |
| `data.eventId` | string | The event's id, also sent as the `webhook-id` header. |
| `data.eventType` | string | The event's name. One of `message.received`, `message.sent`, `message.delivered`, `message.read`, `message.failed`, `comment.received`. |
| `data.occurredAt` | string | When the event happened. ISO 8601, in UTC. |
| `data.status` | string | `PENDING` (waiting), `PROCESSING` (being sent), `RETRY` (waiting for its next attempt), `DELIVERED`, `FAILED` or `CANCELLED`. |
| `data.attempts` | integer | Attempts so far. Redelivering starts again from 0. |
| `data.lastStatusCode` | integer or null | The HTTP status the last attempt got. Null when there was no answer. |
| `data.lastError` | string or null | Why the last attempt failed, such as `http_500` or `timeout`. `retry_exhausted` once the last of all attempts failed. |
| `data.lastDurationMs` | integer or null | How long the last attempt took, in milliseconds. |
| `data.nextAttemptAt` | string or null | When it is next due to be sent, while it is `PENDING` or `RETRY`. Otherwise null. ISO 8601, in UTC. |
| `data.deliveredAt` | string or null | When it was delivered. ISO 8601, in UTC. |
| `data.createdAt` | string | When the delivery was created. ISO 8601, in UTC. |
| `data.endpointId` | string | The endpoint it is for. |
| `data.payload` | object or null | The event's `data`. Null until the event is prepared, and once its message was unsent, deleted or hidden. |
| `data.attemptLog` | array of objects | The attempts that were recorded: all but a success on the first try. After a redelivery the numbers start again and the earlier attempts stay, so sort by `startedAt`. |
| `data.attemptLog[].attemptNumber` | integer | The attempt's number, from 1. |
| `data.attemptLog[].startedAt` | string | When it started. ISO 8601, in UTC. |
| `data.attemptLog[].durationMs` | integer or null | How long it took, in milliseconds. |
| `data.attemptLog[].statusCode` | integer or null | The HTTP status your endpoint answered. |
| `data.attemptLog[].error` | string or null | Why it failed. Null when it succeeded. |

## Errors

| Status | Message | What it means |
| --- | --- | --- |
| 400 | Validation failed | A parameter or body field is missing, unknown or malformed. `errors` lists each one. |
| 400 | This delivery is already waiting to be sent. | It is `PENDING` or `PROCESSING`. |
| 400 | The endpoint no longer subscribes to message.received. | Subscribe the endpoint to the event again first. |
| 400 | The message was unsent, deleted or hidden, so it can't be sent again. | The message is no longer visible through the API either. |
| 401 | A valid Bearer API key is required | The `Authorization` header is missing or isn't `Bearer <API key>`. |
| 401 | Invalid or revoked API key | The key doesn't exist, was revoked, or has expired. |
| 401 | Invalid API key | Chatwise couldn't check the key. Try again. |
| 403 | API key does not have the required scope: webhooks:write | The key lacks the route's scope. Create a key that has it. |
| 403 | Reading a message event's delivery needs an API key with the messages:read scope too. | The delivery is for a `message.*` event and the key lacks `messages:read`. |
| 404 | Webhook delivery not found | No delivery with this id, or its endpoint was deleted, or it is older than 30 days. |
| 429 | API key rate limit exceeded | Wait the number of seconds in the `Retry-After` header. |
| 500 | Internal server error | Something failed in Chatwise. Retry reads with backoff. |

The body of an error is described in [errors](https://chatwise.so/docs/errors.md).
