# Create a Webhook

> Subscribe a URL to LemuTickets events; the signing secret is returned once

URL: https://docs.lemuai.com/tickets-api/webhook-subscriptions/create

Creates a webhook subscription: LemuTickets sends a signed `POST` to your URL for every matching event. See [Webhooks](https://docs.lemuai.com/tickets-api/webhooks) for the event list, the payload, verifying signatures and retries.

**Endpoint:** `POST /v1/webhooks`

Needs the `api_keys.manage` scope.

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | Yes | Where to send events. `https://` is recommended. Must resolve to a public address. Up to 1,000 characters. |
| `events` | array of strings | Yes | Event names or patterns, for example `["ticket.created", "ticket.transitioned", "comment.*"]`. Each must match at least one [event](https://docs.lemuai.com/tickets-api/webhooks#events). |
| `description` | string | No | A note for your team, for example `ERP ticket sync`. |
| `project_ids` | array of UUIDs | No | Only send events for tickets in these projects. Empty (default) means all projects and also events that are not about a ticket. |
| `enabled` | boolean | No | Default `true`. Set `false` to create it switched off. |

**Example request:**
```bash
curl -X POST https://api.tickets.lemuai.com/v1/webhooks \
  -H "Authorization: Bearer ltk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://erp.example.com/lemutickets/webhook",
    "events": ["ticket.created", "ticket.transitioned", "ticket.updated", "comment.created"],
    "description": "ERP ticket sync",
    "project_ids": ["3b0f6c1e-8a2d-4f5b-9c71-0e4d2a6b8f13"]
  }'
```

## Response

**`201`**
```json
{
  "id": "f2a4c6e8-0b1d-4f3a-8c5e-a7c9e1b3d5f7",
  "url": "https://erp.example.com/lemutickets/webhook",
  "description": "ERP ticket sync",
  "events": ["comment.created", "ticket.created", "ticket.transitioned", "ticket.updated"],
  "project_ids": ["3b0f6c1e-8a2d-4f5b-9c71-0e4d2a6b8f13"],
  "enabled": true,
  "failure_count": 0,
  "disabled_reason": null,
  "last_success_at": null,
  "last_failure_at": null,
  "created_at": "2026-11-25T10:10:00.120000+00:00",
  "updated_at": "2026-11-25T10:10:00.120000+00:00",
  "secret": "whsec_Lr6c0Xh2vJ9kQ1pT8sW3nB5mA7dF4gE2"
}
```

**Warning:** `secret` is only returned here. Store it straight away: you need it to [verify signatures](https://docs.lemuai.com/tickets-api/webhooks#verify-the-signature). If you lose it, issue a new one with **Rotate secret** in **Settings → API keys and webhooks**.

| Field | Type | Description |
|---|---|---|
| `id` | string | The webhook's id. |
| `url` | string | The endpoint URL. |
| `description` | string | Your note. |
| `events` | array of strings | The event patterns, sorted and without duplicates. |
| `project_ids` | array of strings | The project filter. Empty means all. |
| `enabled` | boolean | Whether events are being sent. |
| `failure_count` | integer | Failed attempts in a row. Resets on a successful delivery. |
| `disabled_reason` | string or null | Why the webhook was turned off automatically, if it was. |
| `last_success_at`, `last_failure_at` | string or null | The last successful and failed delivery. |
| `created_at`, `updated_at` | string | Timestamps. |
| `secret` | string | The signing secret (`whsec_...`). Only in this response. |

## Errors

| Status | `code` | When |
|---|---|---|
| `403` | `missing_capability` | The key does not have `api_keys.manage` |
| `422` | `missing_events` | `events` is empty |
| `422` | `invalid_events` | A pattern matches no event. `data.unknown` lists them |
| `422` | `invalid_url` | The URL does not start with `http://` or `https://` |
| `422` | `private_address` | The URL points at a private, local or internal address |
| `422` | `unresolvable_host` | The URL's host name does not resolve |
