# POST /api/v1/webhooks/o2c

> Register an outbound webhook endpoint

- **Tag:** o2c-webhooks
- **Operation ID:** `create_webhook_endpoint_api_v1_webhooks_o2c_post`

## Description

Register a URL to receive O2C events. The response includes the plaintext `secret` exactly once — store it to verify the `X-DayZero-Signature` (HMAC-SHA256) header on delivered events.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `WebhookEndpointCreate`

- `url` (string · required) — HTTPS URL to POST events to.
- `event_types` (array · string · required) — Event types to subscribe to (e.g. ['order.countersigned']).
- `secret` (string) — Optional shared HMAC secret; auto-generated if omitted.
- `is_active` (boolean) — Whether the endpoint is active.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_WebhookEndpointCreateResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (WebhookEndpointCreateResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/webhooks/o2c' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "string",
  "event_types": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/webhooks/o2c', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "url": "string",
  "event_types": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "url": "string",
  "event_types": []
}

response = httpx.post("https://api.ondayzero.com/api/v1/webhooks/o2c", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/o2c-webhooks/create-webhook-endpoint
- OpenAPI slice: https://www.ondayzero.com/docs/reference/o2c-webhooks/create-webhook-endpoint/openapi.json
- Other endpoints in **o2c-webhooks**: https://www.ondayzero.com/docs/reference/o2c-webhooks
