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

# Webhooks

> Zoho Mail incoming webhooks: event paths, payloads, and response data.

The Zoho Mail plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](/plugins/zohomail/overview) for setup context and the exact URL shape).

<Info>
  **New to Corsair?** See [webhooks](/concepts/webhooks) and [hooks](/concepts/hooks).
</Info>

## Webhook map

* `challenge`
  * `handshake` (`challenge.handshake`)
* `messages`
  * `received` (`messages.received`)

## 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);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}
```

## Events

## Challenge

### Handshake

`challenge.handshake`

Zoho Mail initial webhook handshake via x-hook-secret header

**Payload:** *empty object*

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      hookSecret: string
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
zohomail({
    webhookHooks: {
        challenge: {
            handshake: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Messages

### Received

`messages.received`

A new email was received in the mailbox

**Payload**

| Name            | Type               | Required | Description |
| --------------- | ------------------ | -------- | ----------- |
| `messageId`     | `string`           | No       | —           |
| `folderId`      | `string`           | No       | —           |
| `subject`       | `string`           | No       | —           |
| `summary`       | `string`           | No       | —           |
| `html`          | `string`           | No       | —           |
| `fromAddress`   | `string`           | No       | —           |
| `toAddress`     | `string`           | No       | —           |
| `ccAddress`     | `string`           | No       | —           |
| `sender`        | `string`           | No       | —           |
| `sentDateInGMT` | `string`           | No       | —           |
| `receivedTime`  | `string`           | No       | —           |
| `size`          | `string \| number` | No       | —           |

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      messageId?: string,
      folderId?: string,
      subject?: string,
      summary?: string,
      html?: string,
      fromAddress?: string,
      toAddress?: string,
      ccAddress?: string,
      sender?: string,
      sentDateInGMT?: string,
      receivedTime?: string,
      size?: string | number
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
zohomail({
    webhookHooks: {
        messages: {
            received: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***
