# Register a webhook endpoint (/api/createWebhook)

The only response that carries the signing secret in full. Store it
when you receive it — every later read answers with `secret_preview`,
and there is no way to ask for it again.

Endpoint: POST /api/v1/webhooks
Full URL: https://app.sendkuy.com/api/v1/webhooks
- header parameter Idempotency-Key (optional): string — Any unique string, one per logical request. Retrying with the same key returns the first answer instead of doing the work twice, and answers with `Idempotent…
Request body (JSON, required); required fields: none
Example "Only tell me about failures": {"url":"https://example.com/hooks/sendkuy","events":["message.failed"]}
Success status: 201

cURL:

```bash
curl -X POST https://app.sendkuy.com/api/v1/webhooks \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com/hooks/sendkuy",
  "events": [
    "message.failed"
  ]
}'
```

Node.js:

```ts
import { SendKuy } from 'sendkuy';

const sendkuy = new SendKuy('sk_live_YOUR_API_KEY');

const result = await sendkuy.webhooks.create({
  url: 'https://example.com/hooks/sendkuy',
  events: [
    'message.failed',
  ],
});
```

PHP:

```php
<?php

use SendKuy\SendKuy;

$sendkuy = new SendKuy('sk_live_YOUR_API_KEY');

$result = $sendkuy->webhooks()->create([
    'url' => 'https://example.com/hooks/sendkuy',
    'events' => [
        'message.failed',
    ],
]);
```

Python:

```python
import requests

response = requests.request(
    "POST",
    "https://app.sendkuy.com/api/v1/webhooks",
    headers={"Authorization": "Bearer sk_live_YOUR_API_KEY"},
    json={
        "url": "https://example.com/hooks/sendkuy",
        "events": [
            "message.failed"
        ]
    },
)

data = response.json()["data"]
```