> ## Documentation Index
> Fetch the complete documentation index at: https://docs.covver.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook overview

> Receive webhook notifications about events in the Covver backend

## Setup

Contact [devsupport@covver.io](mailto:devsupport@covver.io) to setup a webhook destination URL

## Webhook events

```ts theme={null}
enum CovverWebhookEventType {
  // Collection events
  CollectionCreated = 'CollectionCreated',
  CollectionDeleted = 'CollectionDeleted',
  CollectionUpdated = 'CollectionUpdated',

  // Product events
  ProductCreated = 'ProductCreated',
  ProductHidden = 'ProductHidden',
  ProductShown = 'ProductShown',
  ProductUpdated = 'ProductUpdated',

  // Order events
  OrderPlaced = 'OrderPlaced',
  OrderConfirmed = 'OrderConfirmed',
  OrderFulfilled = 'OrderFulfilled',
}
```

## Webhook format

All Webhooks are sent as a POST message and have this format:

```ts theme={null}
interface CovverWebhookEvent {
  type: CovverWebhookEventType;
  data: any;
}
```

## Webhook signature

All Webhooks include a `covverSignature` header to validate that the webhook is indeed coming from us as well as `covverIdempotencyKey` which is a unique key sent out per webhook.

Webhooks are signed using the code below where the secret is your client secret and the payload is the body of the POST request

```ts theme={null}
import { createHmac } from 'crypto';

function validatePayload(headers, payload) {
  const signature = createHmac('sha256', secret)
    .update(JSON.stringify(payload), 'utf8')
    .digest('base64');

  return headers['covverSignature'] === signature;
}
```

## Note

In subsequent webhook docs when we mention PersonalizationFieldsType we are referring to

```ts theme={null}
type PersonalizationFieldsType {
  anniversary: {
    decade: string;
    hundreds: string;
    month: number;
    monthPadded: string;
    ordinal: string;
    year: number;
    years: number;
    yearsPadded: string;
    zodiac: string;
    elapsed: string;
  },
  birth: {
    decade: string;
    hundreds: string;
    month: number;
    monthPadded: string;
    ordinal: string;
    year: number;
    years: number;
    yearsPadded: string;
    zodiac: string;
    elapsed: string;
  },
  name: {
    first: string;
    firstNameInitials: string;
    firstPossessive: string;
    initials: string;
    last: string;
    lastNameInitials: string
  },
  work: {
    department: string;
    location: string;
  }
}
```
