> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlegion.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle webhooks and recover interrupted work

> Use the chat stream for an open conversation and signed webhook events for work your backend needs to handle.

An open chat receives the reply as it is written. Your server can learn that the same job finished after the person closed the tab by subscribing to `run.completed`. Use the webhook to update your product, for instance by marking the customer's brief ready.

## Receive an event

Add a handler for the event type to the `webhooks` map in your kit route. The kit verifies the signature before dispatching the event. Locally, `npx openlegion dev` forwards deliveries to the running application's webhook route. For a deployed integration, register your public HTTPS endpoint and configure its signing secret on your server. Send a test `ping` and confirm that the endpoint returns a successful response.

| Event | How your product can use it |
| - | - |
| `action.requires_approval` | Direct the appropriate person to the saved approval in the conversation. |
| `run.completed` | Show the finished result or tell the user it is ready. |
| `run.failed` or `run.cancelled` | Show the outcome and retain any partial response. |
| `connection.needs_reauth` | Offer a reconnect action for the affected workspace account. |
| `schedule.missed` | Inspect the reason a scheduled task could not start, such as insufficient credits. |

## Handle retries and missing updates

Persist the event ID with the work it triggers. A delivery can arrive again with the same ID, including after a manual resend. If the payload has `data.truncated: true`, retrieve the referenced object before acting on its current state. A handler should acknowledge the event after durably recording it or completing its work.

If a notification is missing, check the endpoint's deliveries and response codes. Use `GET /events` to reconcile activity after downtime. The delivery API can resend a settled delivery. A browser losing its chat connection is a separate case. The kit can reattach to an existing run and load its history. [Webhook delivery and verification](https://platform.openlegion.ai/docs/guides/webhooks) · [Chat streaming and recovery](https://platform.openlegion.ai/docs/guides/chat)


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