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

> Microsoft Teams incoming webhooks: event paths, payloads, and response data.

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

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

## Webhook map

* `channels`
  * `created` (`channels.created`)
  * `message` (`channels.message`)
* `chats`
  * `message` (`chats.message`)
* `members`
  * `changed` (`members.changed`)

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

## Channels

### Created

`channels.created`

A channel was created, updated, or deleted in a team

**Payload**

| Name    | Type       | Required | Description |
| ------- | ---------- | -------- | ----------- |
| `value` | `object[]` | Yes      | —           |

<AccordionGroup>
  <Accordion title="value full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.channel,
        @odata.id?: string,
        id: string
      }
    }[]
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.channel,
        @odata.id?: string,
        id: string
      }
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

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

***

### Message

`channels.message`

A message was created or updated in a team channel

**Payload**

| Name    | Type       | Required | Description |
| ------- | ---------- | -------- | ----------- |
| `value` | `object[]` | Yes      | —           |

<AccordionGroup>
  <Accordion title="value full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.chatMessage,
        @odata.id?: string,
        id: string
      }
    }[]
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.chatMessage,
        @odata.id?: string,
        id: string
      }
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
teams({
    webhookHooks: {
        channels: {
            message: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Chats

### Message

`chats.message`

A message was created or updated in a chat

**Payload**

| Name    | Type       | Required | Description |
| ------- | ---------- | -------- | ----------- |
| `value` | `object[]` | Yes      | —           |

<AccordionGroup>
  <Accordion title="value full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.chatMessage,
        @odata.id?: string,
        id: string
      }
    }[]
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.chatMessage,
        @odata.id?: string,
        id: string
      }
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
teams({
    webhookHooks: {
        chats: {
            message: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Members

### Changed

`members.changed`

A team membership was added, updated, or removed

**Payload**

| Name    | Type       | Required | Description |
| ------- | ---------- | -------- | ----------- |
| `value` | `object[]` | Yes      | —           |

<AccordionGroup>
  <Accordion title="value full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.aadUserConversationMember,
        @odata.id?: string,
        id: string
      }
    }[]
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      subscriptionId: string,
      changeType: created | updated | deleted,
      resource: string,
      tenantId?: string,
      clientState?: string,
      resourceData?: {
        @odata.type?: #Microsoft.Graph.aadUserConversationMember,
        @odata.id?: string,
        id: string
      }
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
teams({
    webhookHooks: {
        members: {
            changed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***
