# REST hooks

> Let your code or your own connector subscribe a URL to one event and remove it again through the API, the way Zapier, Make and n8n do.

A **REST hook** is a [webhook](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/webhooks) that a tool creates and removes through the API instead of someone adding it on the page. Turning a trigger on subscribes it; turning it off unsubscribes it. It's how instant triggers work in no-code tools, and how you'd build one into your own product.

Each hook carries **one event type** and is signed, retried and logged like any webhook. It shows on the **Integrations** page with the name of the key or app that created it (*via Zapier*, for example), and counts toward the same endpoint limit.

You need an [API key](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/api-keys) with `webhooks:write` and the read scope of the event's app.

## Subscribe {#subscribe}

```bash
curl -X POST https://nomongeta.zenhalab.com/api/integrations/v1/hooks \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event": "<event type>", "targetUrl": "https://example.com/hooks/abc"}'
```

The answer (`201`) is the hook, with its signing `secret`, shown this once:

```json
{
  "id": "0f6e2a9c-3b1d-4c5e-8f7a-9b0c1d2e3f4a",
  "event": "<event type>",
  "app": "<app>",
  "targetUrl": "https://example.com/hooks/abc",
  "state": "active",
  "via": "My connector",
  "createdAt": "2026-10-04T12:00:00.000Z",
  "secret": "whsec_…"
}
```

- `event` is a type from the [event catalog](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/events). `GET /event-types` lists the ones this key may subscribe, with each one's JSON Schema and example.
- `targetUrl` must be `https://` and public. Tools that send it as `target_url`, `hookUrl` or `url` work too.
- `description` (optional) is the name shown on the page; it defaults to the key's name.

| Status | `error` | Why |
| --- | --- | --- |
| `404` | `unknown_event_type` | No such event type. |
| `422` | `invalid_url` | Not `https`, private, or malformed (`reason` says which). |
| `422` | `invalid_event` | This app doesn't send that event. |
| `422` | `app_required` | An account event without `app`. |
| `429` | `limit_reached` | The endpoint limit is used up (`limit` says how many). |

## Unsubscribe {#unsubscribe}

```bash
curl -X DELETE https://nomongeta.zenhalab.com/api/integrations/v1/hooks/<hook id> \
  -H "Authorization: Bearer $API_KEY"
```

`204` means done; deliveries stop at once. `404` means it was already gone: treat it as done too.

A hook also goes away on its own when:

- your receiver answers a delivery with **`410 Gone`** (the REST Hooks convention: Zapier does it when a Zap is deleted);
- the API key that created it is revoked, or the app that created it is disconnected.

`GET /hooks` lists the hooks **this key** created, and `GET /hooks/<id>` shows one. A key never sees, or removes, the hooks of another key or app, even of the same account.

## Samples and polling {#samples}

`GET /events/<type>/sample` answers the latest events of a type, exactly in the shape a hook delivers them. Tools use it to show sample data while someone sets up a trigger. With nothing real yet, it answers the catalog's example, marked `"test": true`.

| Query | |
| --- | --- |
| `limit` | 1 to 100 (default 3). |
| `since` | Only events after this instant (ISO 8601): poll with the `timestamp` of the last one you saw. |
| `example` | `false` to get an empty list instead of the example (what a polling trigger wants). |
| `app` | For account events, as when subscribing. |

Prefer hooks to polling: they arrive the moment something happens and cost nothing while nothing does.

## Verify what arrives {#verify}

Deliveries to a hook are signed with its `secret`, exactly as described in [verify webhook signatures](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/verify-signatures). Keep the secret if your receiver can check it; if it can't, keep the target URL secret instead: it works like a password.
