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

# Granola webhooks

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

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

* `notes`
  * `accessGranted` (`notes.accessGranted`)
  * `edited` (`notes.edited`)
  * `generated` (`notes.generated`)

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

## Notes

### Access Granted

`notes.accessGranted`

A note was shared with the endpoint, directly or through a folder (note.access\_granted).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event_id` | `string` | Yes | The event id; the same on every retry, so a dedupe key. |
| `event_type` | `note.access_granted` | Yes | — |
| `note_id` | `string` | Yes | The note the event is about. Fetch it with notes.get. |
| `occurred_at` | `string \| null` | No | When the event occurred (ISO 8601). |
| `data` | `object \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   changed_fields?: string[] | null
> } | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event_id: string,
>   event_type: note.access_granted,
>   note_id: string,
>   occurred_at?: string | null,
>   data?: {
>     changed_fields?: string[] | null
>   } | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
granola({
    webhookHooks: {
        notes: {
            accessGranted: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Edited

`notes.edited`

A note's summary was edited or regenerated (note.edited); data.changed\_fields says what changed.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event_id` | `string` | Yes | The event id; the same on every retry, so a dedupe key. |
| `event_type` | `note.edited` | Yes | — |
| `note_id` | `string` | Yes | The note the event is about. Fetch it with notes.get. |
| `occurred_at` | `string \| null` | No | When the event occurred (ISO 8601). |
| `data` | `object \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   changed_fields?: string[] | null
> } | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event_id: string,
>   event_type: note.edited,
>   note_id: string,
>   occurred_at?: string | null,
>   data?: {
>     changed_fields?: string[] | null
>   } | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
granola({
    webhookHooks: {
        notes: {
            edited: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Generated

`notes.generated`

A note's first AI summary was generated (note.generated). Carries the note id; fetch the note with notes.get.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event_id` | `string` | Yes | The event id; the same on every retry, so a dedupe key. |
| `event_type` | `note.generated` | Yes | — |
| `note_id` | `string` | Yes | The note the event is about. Fetch it with notes.get. |
| `occurred_at` | `string \| null` | No | When the event occurred (ISO 8601). |
| `data` | `object \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   changed_fields?: string[] | null
> } | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event_id: string,
>   event_type: note.generated,
>   note_id: string,
>   occurred_at?: string | null,
>   data?: {
>     changed_fields?: string[] | null
>   } | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
granola({
    webhookHooks: {
        notes: {
            generated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


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