# Create a webhook configuration

`POST https://api.mothership.com/beta/webhookConfigs`

Sandbox: `https://sandbox.api.mothership.com/beta/webhookConfigs`

Creates a webhook configuration for your shipper account.

> [!NOTE]
> Consult the [Webhooks](https://developers.mothership.com/reference/webhooks) section of Mothership's API documentation for details about available event subscriptions.

The SHA256 signature of each payload can be found in the `X-Mothership-Signature` header of the webhook POST request and verified using the `secretKey` available on the Create Webhook Config response body. See [Validating webhook payloads](https://developers.mothership.com/docs/webhooks-validation) for more information.

`webhookUrl` must be an `https` URL on a domain name, not an IP address or `localhost`.

## Authorization

Send your API token as a Bearer token: `Authorization: Bearer <token>`.

## Request body

- `webhookUrl` (string, required): URL that Mothership POSTs webhook events to.
- `subscribedEvents` (array of strings, required): Events that trigger a webhook. One of: `billOfLading.created`, `billOfLading.updated`, `proofOfDelivery.created`, `proofOfDelivery.updated`, `deliveryReceipt.created`, `deliveryReceipt.updated`, `certificateOfInsurance.created`, `shipment.purchased`, `shipment.status.updated`.

## Responses

### 201

The created webhook configuration, inside `data`.

- `data` (object, required)
  - `id` (string, required): ID of the webhook configuration.
  - `createdAt` (string<date-time>, required): When this webhook configuration was created, as an ISO 8601 date-time.
  - `status` (string, required): Current status of the webhook config. One of: `active`, `inactive`.
  - `subscribedEvents` (array of strings, required): Events that trigger a webhook. One of: `billOfLading.created`, `billOfLading.updated`, `proofOfDelivery.created`, `proofOfDelivery.updated`, `deliveryReceipt.created`, `deliveryReceipt.updated`, `certificateOfInsurance.created`, `shipment.purchased`, `shipment.status.updated`.
  - `webhookUrl` (string, required): URL that Mothership POSTs webhook events to.
  - `secretKey` (string, required): Secret key for this webhook configuration, used to validate incoming webhook payloads.

## Example request

```bash
curl --request POST \
  --url 'https://sandbox.api.mothership.com/beta/webhookConfigs' \
  --header "Authorization: Bearer $MOTHERSHIP_API_TOKEN" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "webhookUrl": "https://www.yourserver.com/webhook/mothership",
  "subscribedEvents": [
    "shipment.purchased",
    "billOfLading.created",
    "proofOfDelivery.created"
  ]
}'
```

## Example response (201)

```json
{
  "data": {
    "id": "48asjgaoi33nkl4t3lae",
    "createdAt": "2019-03-20T16:17:13.424Z",
    "status": "active",
    "subscribedEvents": ["shipment.purchased", "billOfLading.created", "proofOfDelivery.created"],
    "webhookUrl": "https://www.yourserver.com/webhook/mothership",
    "secretKey": "de3ADDAek3245DLAdANe91Dn3asklAMSsna03aGKkl23agsJea"
  }
}
```