---
title: "Subscribe to an event"
method: POST
path: "/hooks"
tags: ["Event subscriptions"]
---

# Subscribe to an event

`POST /hooks`

## Request

- Base URL: `https://api.flogpt.com/api/v1`
- URL: `https://api.flogpt.com/api/v1/hooks`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Registers a URL to receive an event. Deliveries are signed with the
returned `signingSecret` using the `X-FloGPT-Signature:
t=<unix>,v1=<hex>` header, where the signed string is
`<timestamp>.<raw body>`.

Idempotent on `(event, targetUrl)`: re-subscribing reactivates the
existing subscription and issues a fresh secret rather than creating a
duplicate, so one event is never delivered twice to the same URL.

`signingSecret` is returned by this endpoint only and cannot be read
back afterwards. `targetUrl` must be HTTPS and publicly routable.

## Request body

- object
  - `event` string, required: One of the names from `GET /hooks/events`.
  - `targetUrl` string, uri, required

## Response `201`

Subscription created

## Other responses

- `400`: The request is invalid.

---

[API](https://skmtc.dev/flogpt/apis/flogpt-organization-api.md) · [All operations](https://skmtc.dev/flogpt/apis/flogpt-organization-api/llms.txt) · [OpenAPI document](https://skmtc.dev/flogpt/apis/flogpt-organization-api/revisions/c3a6cff76797?raw)
