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

# Convex

> Verify webhook signatures and route events with @mynthio/sdk/convex.

`@mynthio/sdk/convex` provides `mynthWebhookAction()` for handling signed Mynth webhooks in Convex HTTP actions.

## Webhook helper

```ts theme={"theme":"kanagawa-dragon"}
import { mynthWebhookAction } from "@mynthio/sdk/convex";

export const mynthWebhook = mynthWebhookAction({
  imageTaskCompleted: async (payload, { context }) => {
    console.log(payload.task.id);
    console.log(payload.result.images);
  },
  imageTaskFailed: async (payload) => {
    console.error("Task failed", payload.task.id);
  },
  imageRateTaskCompleted: async (payload, { context }) => {
    console.log(payload.result.results);
  },
  imageRateTaskFailed: async (payload) => {
    console.error("Rate task failed", payload.task.id);
  },
  imageAltTaskCompleted: async (payload, { context }) => {
    console.log(payload.result.results);
  },
  imageAltTaskFailed: async (payload) => {
    console.error("Alt text task failed", payload.task.id);
  },
});
```

Each handler maps to a webhook event:

| Handler                  | Event                           |
| ------------------------ | ------------------------------- |
| `imageTaskCompleted`     | `task.image.generate.completed` |
| `imageTaskFailed`        | `task.image.generate.failed`    |
| `imageRateTaskCompleted` | `task.image.rate.completed`     |
| `imageRateTaskFailed`    | `task.image.rate.failed`        |
| `imageAltTaskCompleted`  | `task.image.alt.completed`      |
| `imageAltTaskFailed`     | `task.image.alt.failed`         |

The helper:

* verifies the `X-Mynth-Signature` header using HMAC-SHA256
* requires the `X-Mynth-Event` header, then routes on `payload.event`
* exposes Convex `context` (and the original `request`) for running queries and mutations

If you do not pass `webhookSecret` explicitly, the helper reads `MYNTH_WEBHOOK_SECRET` from the environment.

## Full walkthrough

For a complete Convex integration including schema, actions, webhooks, and reactive UI, see the [Convex full-stack guide](/guides/convex-full-stack-image-generation).
