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

# Shotstack webhooks

> Shotstack incoming webhooks in Corsair: the event paths to subscribe to, the payload each event carries, and the response data.

The Shotstack plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/shotstack/overview.md) for setup context and the exact URL shape).

> [!NOTE]
>
> **New to Corsair?** See [webhooks](https://docs.corsair.dev/concepts/webhooks.md) and [hooks](https://docs.corsair.dev/concepts/hooks.md).

## Webhook map

* `render` (`render`)
* `serve` (`serve`)
* `source` (`source`)

## HTTP handler setup

```ts app/api/webhook/route.ts theme={null}
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    // With multiTenancy, give each tenant its own URL (/api/webhook?tenantId=acme):
    // the query says whose account, secret and hooks handle the delivery.
    const query = Object.fromEntries(new URL(request.url).searchParams);
    // The raw text, not request.json(): signatures are checked over the exact bytes sent.
    const body = await request.text();
    const result = await processWebhook(corsair, headers, body, query);
    if (!result.plugin) {
        return Response.json({ success: false }, { status: 404 });
    }
    // A refusal (bad signature) carries no status and answers 400; a handler
    // that threw comes back with 500, so the sender retries it.
    const status =
        result.response?.success === false ? (result.response.statusCode ?? 400) : 200;
    return Response.json(result.response ?? { success: true }, {
        status,
        headers: result.responseHeaders,
    });
}
```

## Events

## Render

### Render

`render`

A render (renders.create or templates.render with a callback URL) finished: status done or failed, with the output URL. Checked against the API, since Shotstack does not sign callbacks.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `edit` | Yes | — |
| `action` | `render` | Yes | — |
| `id` | `string` | Yes | The render, source or hosted asset id. |
| `owner` | `string` | Yes | The Shotstack account (owner) id. |
| `status` | `string` | Yes | The job status: done or failed for a render, ready or failed for a source or hosted copy. |
| `url` | `string \| null` | No | Where the output or ingested file is, read back from the API. |
| `error` | `string \| null` | No | Why the job failed, when it did. |
| `completed` | `string \| null` | No | When the job ended (ISO 8601). |
| `poster` | `string \| null` | No | — |
| `thumbnail` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: edit,
>   action: render,
>   id: string,
>   owner: string,
>   status: string,
>   url?: string | null,
>   error?: string | null,
>   completed?: string | null,
>   poster?: string | null,
>   thumbnail?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
shotstack({
    webhookHooks: {
        render: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})
```

***

## Serve

### Serve

`serve`

The hosting copy of a render output is ready on the Shotstack CDN (sent with render callbacks): the durable CDN URL and the render id. Checked against the API.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `serve` | Yes | — |
| `action` | `string` | Yes | copy: the hosting copy of an output. |
| `id` | `string` | Yes | The render, source or hosted asset id. |
| `owner` | `string` | Yes | The Shotstack account (owner) id. |
| `status` | `string` | Yes | The job status: done or failed for a render, ready or failed for a source or hosted copy. |
| `url` | `string \| null` | No | Where the output or ingested file is, read back from the API. |
| `error` | `string \| null` | No | Why the job failed, when it did. |
| `completed` | `string \| null` | No | When the job ended (ISO 8601). |
| `render` | `string \| null` | No | The render id the hosted asset came from. |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: serve,
>   action: string,
>   id: string,
>   owner: string,
>   status: string,
>   url?: string | null,
>   error?: string | null,
>   completed?: string | null,
>   render?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
shotstack({
    webhookHooks: {
        serve: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})
```

***

## Source

### Source

`source`

A source fetch (sources.fetch with a callback URL) finished: status ready or failed, with the ingested file URL. Checked against the API.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `ingest` | Yes | — |
| `action` | `source` | Yes | — |
| `id` | `string` | Yes | The render, source or hosted asset id. |
| `owner` | `string` | Yes | The Shotstack account (owner) id. |
| `status` | `string` | Yes | The job status: done or failed for a render, ready or failed for a source or hosted copy. |
| `url` | `string \| null` | No | Where the output or ingested file is, read back from the API. |
| `error` | `string \| null` | No | Why the job failed, when it did. |
| `completed` | `string \| null` | No | When the job ended (ISO 8601). |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: ingest,
>   action: source,
>   id: string,
>   owner: string,
>   status: string,
>   url?: string | null,
>   error?: string | null,
>   completed?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
shotstack({
    webhookHooks: {
        source: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})
```

***


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