# Create a webhook

POST https://api.oletapp.com/your-store/v1/webhooks

Subscribes a URL to one event. The credential needs the read scope of the event's resource: `sales:read` for sale events, `customers:read` for customer events, `catalog:read` for product events and `inventory:read` for inventory events.

- `201`: the webhook was created. The response carries the signing `secret`. It is shown once and cannot be retrieved again.
- `200`: this credential already has a webhook for the same event and URL. The existing webhook is returned with `secret: null`.
- `403 INSUFFICIENT_SCOPE`: the credential lacks the read scope for the event.
- `422 VALIDATION_FAILED`: the event is unknown.
- `422 UNPROCESSABLE`: the URL is not https, is longer than 2000 characters, contains credentials, or does not resolve to a public address; or the credential already has 50 webhooks.

Each credential can have 50 webhooks. Deliveries follow the Webhooks guide.

**Requires scope:** `any`

Required scope: `any`

## Parameters

None.

## Request body

```
{
  event: string
  target_url: string
}
```

## Response (201)

```
{
  data: {
  created_at: string
  event: string
  id: string
  secret: string | null
  status: "active" | "disabled"
  target_url: string
}
}
```

Errors follow the standard error envelope: https://getolet.com/resources/developers/errors.md

## Example

```bash
curl -X POST "https://api.oletapp.com/your-store/v1/webhooks" \
  -H "Authorization: Bearer olet_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event":"string","target_url":"string"}'
```
