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

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

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

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

## Webhook map

* `collections`
  * `collectionCompleted` (`collections.collectionCompleted`)

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

## Collections

### Collection Completed

`collections.collectionCompleted`

Fires when a Collection completes and a new Result Set is available

**Payload**

| Name           | Type     | Required | Description |
| -------------- | -------- | -------- | ----------- |
| `request_info` | `object` | Yes      | —           |
| `collection`   | `object` | Yes      | —           |
| `result_set`   | `object` | Yes      | —           |

<AccordionGroup>
  <Accordion title="request_info full type">
    ```ts theme={null}
    {
      success?: boolean,
      type?: collection_resultset_completed
    }
    ```
  </Accordion>

  <Accordion title="collection full type">
    ```ts theme={null}
    {
      id: string,
      name?: string
    }
    ```
  </Accordion>

  <Accordion title="result_set full type">
    ```ts theme={null}
    {
      id: number | string,
      started_at?: string,
      ended_at?: string,
      requests_completed?: number,
      requests_failed?: number,
      download_links?: {
        json?: {
          pages?: string[],
          all_pages?: string
        },
        jsonlines?: {
          pages?: string[],
          all_pages?: string
        },
        csv?: {
          pages?: string[],
          all_pages?: string
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      request_info: {
        success?: boolean,
        type?: collection_resultset_completed
      },
      collection: {
        id: string,
        name?: string
      },
      result_set: {
        id: number | string,
        started_at?: string,
        ended_at?: string,
        requests_completed?: number,
        requests_failed?: number,
        download_links?: {
          json?: {
            pages?: string[],
            all_pages?: string
          },
          jsonlines?: {
            pages?: string[],
            all_pages?: string
          },
          csv?: {
            pages?: string[],
            all_pages?: string
          }
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

```ts theme={null}
asindataapi({
    webhookHooks: {
        collections: {
            collectionCompleted: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***
