# Replay webhook messages

## Service Description

This service allows replaying webhook messages by submitting a list of `eventIds`. Event ID can be requested using [get-list-of-webhook-messages](https://docs.lhv.com/home/connect/services/webhooks/webhook-services/get-list-of-webhook-messages "mention") service.

New webhook messages are dispatched to the originally configured endpoints, regardless of the original delivery status. Messages with the status `Retry Pending` can be replayed; doing so will cancel the scheduled retry and create a new webhook message with a new `eventId`.  Webhooks that were successfully delivered can also be replayed, provided they are no older than 5 days (120 hours).

Invalid or unknown `eventIds` are skipped and reported in the response. A summary is returned indicating which events were successfully dispatched and which were not.

## Request

<mark style="color:green;">`POST`</mark> <https://connect.lhv.com/notifications/replay>

Example request

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "eventIds": [
    "f9b1c178-dca4-4e71-85c3-53922b77110e",
    "3a23b238-8729-45df-a3d0-3f6b37b3e3aa",
    "9b5b5b5c-8147-4f13-981d-bfd41bc91f44"
  ]
}
</code></pre>

## Response

Example response

{% tabs %}
{% tab title="200 - success" %}

```json
{
  "dispatched": [
    {
      "eventId": "f9b1c178-dca4-4e71-85c3-53922b77110e"
    },
    {
      "eventId": "3a23b238-8729-45df-a3d0-3f6b37b3e3aa"
    }
    {
      "eventId": "9b5b5b5c-8147-4f13-981d-bfd41bc91f44"
    }
  ],
  "failed": []
}
```

{% endtab %}

{% tab title="400 - fail" %}
{% code overflow="wrap" %}

```json
{
  "dispatched": [],
  "failed": [
    {
      "eventId": "f9b1c178-dca4-4e71-85c3-53922b77110e",
      "error": "Cannot replay webhook. No valid and active webhook configuration found for webhook response with eventId: f9b1c178-dca4-4e71-85c3-53922b77110e"
    },
    {
      "eventId": "3a23b238-8729-45df-a3d0-3f6b37b3e3aa",
      "error": "Cannot replay webhook. WebhookResponse not found for contract 123 and webhook eventId: 3a23b238-8729-45df-a3d0-3f6b37b3e3aa"
    }
    {
      "eventId": "9b5b5b5c-8147-4f13-981d-bfd41bc91f44",
      "error": "Cannot replay webhook. WebhookResponse not found for contract 123 and webhook eventId: 9b5b5b5c-8147-4f13-981d-bfd41bc91f44"
    }
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
