> ## 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.

# Daytona webhooks

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

The Daytona plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/daytona/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

* `sandbox`
  * `created` (`sandbox.created`)
  * `stateUpdated` (`sandbox.stateUpdated`)
* `snapshot`
  * `created` (`snapshot.created`)
  * `removed` (`snapshot.removed`)
  * `stateUpdated` (`snapshot.stateUpdated`)
* `volume`
  * `created` (`volume.created`)
  * `stateUpdated` (`volume.stateUpdated`)

## 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

## Sandbox

### Created

`sandbox.created`

A sandbox was created (event sandbox.created)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        sandbox: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### State Updated

`sandbox.stateUpdated`

A sandbox's state changed (oldState, newState) (event sandbox.state.updated)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        sandbox: {
            stateUpdated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Snapshot

### Created

`snapshot.created`

A snapshot was created (event snapshot.created)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        snapshot: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Removed

`snapshot.removed`

A snapshot was removed (event snapshot.removed)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        snapshot: {
            removed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### State Updated

`snapshot.stateUpdated`

A snapshot's state changed (event snapshot.state.updated)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        snapshot: {
            stateUpdated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Volume

### Created

`volume.created`

A volume was created (event volume.created)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        volume: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### State Updated

`volume.stateUpdated`

A volume's state changed (event volume.state.updated)

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | The event type, such as sandbox.state.updated. |
| `timestamp` | `string \| null` | No | When it happened (ISO 8601). |
| `id` | `string \| null` | No | The sandbox, snapshot or volume id. |
| `organizationId` | `string \| null` | No | — |
| `name` | `string \| null` | No | Snapshot or volume name. |
| `state` | `string \| null` | No | — |
| `oldState` | `string \| null` | No | — |
| `newState` | `string \| null` | No | — |
| `sandboxClass` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: string,
>   timestamp?: string | null,
>   id?: string | null,
>   organizationId?: string | null,
>   name?: string | null,
>   state?: string | null,
>   oldState?: string | null,
>   newState?: string | null,
>   sandboxClass?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
daytona({
    webhookHooks: {
        volume: {
            stateUpdated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


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