# Manage your endpoints

> Create, read and disable the addresses that take your deliveries, and keep each one's signing secret.

A webhook endpoint is one address of yours that takes deliveries. Your backend creates and reads its
organization's endpoints with the API, with the scope `webhooks:write`. There is no read-only scope
for endpoints: reading them takes `webhooks:write` too.

## The routes

| Route                                                      | Does                                                |
| ---------------------------------------------------------- | --------------------------------------------------- |
| `POST /v1/webhook-endpoints`                               | Creates an endpoint, and answers its signing secret |
| `GET /v1/webhook-endpoints`                                | Lists your organization's endpoints                 |
| `GET /v1/webhook-endpoints/{webhook_endpoint_id}`          | Reads one                                           |
| `POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable` | Stops deliveries to it                              |

The endpoints are your organization's: another organization's endpoint answers `404`. Your
[sandbox](/docs/sandbox) has endpoints of its own.

## Create an endpoint

```bash
curl https://api.youth-platform.io/v1/webhook-endpoints \
  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: 6d1f2b0a-8f3c-4a77-9d1e-3b2f5c6a7d81" \
  --data '{
    "url": "https://partner.example.com/youth-webhook",
    "event_types": ["AccessCode.redeemed", "Access.ended"],
    "description": "Billing"
  }'
```

| Field         | Means                                                                                    |
| ------------- | ---------------------------------------------------------------------------------------- |
| `url`         | Where deliveries go, at most 2,048 characters: see [The address](#the-address)           |
| `event_types` | The events it receives, at least one and at most 20: see [Events](/docs/webhooks#events) |
| `description` | A note of yours about it, such as the system it feeds, at most 200 characters. Optional  |

The answer is `201`, with the endpoint, its signing secret, and its address in `Location`:

```json
{
  "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90",
  "url": "https://partner.example.com/youth-webhook",
  "description": "Billing",
  "event_types": ["Access.ended", "AccessCode.redeemed"],
  "status": "active",
  "created_at": "2026-11-20T09:30:00.000Z",
  "updated_at": "2026-11-20T09:30:00.000Z",
  "signing_secret": "whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl"
}
```

| Refused with                     | When                                                                                                                                      |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `422` `url_not_allowed`          | The address isn't `https` on port 443, carries a user or password, or names a host no delivery may go to: see [The address](#the-address) |
| `409` `endpoint_limit_reached`   | Your organization keeps ten endpoints already, disabled ones aside: disable one first                                                     |
| `422` `unknown_event_type`       | An event type isn't one YOU(th) sends                                                                                                     |
| `422` `invalid_request`          | A field is missing, not valid, or not one the request takes                                                                               |
| `400` `idempotency_key_required` | The request has no `Idempotency-Key`                                                                                                      |
| `400` `idempotency_key_invalid`  | The key is empty, or longer than 255 characters                                                                                           |
| `409` `idempotency_conflict`     | The `Idempotency-Key` was used for another body: use a new key                                                                            |
| `409` `idempotency_in_progress`  | A request with the key runs now: send it again after `Retry-After`                                                                        |
| `503` `temporarily_unavailable`  | The secret can't be made now: send it again after `Retry-After`                                                                           |

## Read and list endpoints

`GET /v1/webhook-endpoints/{webhook_endpoint_id}` answers one endpoint as above, without its
`signing_secret`. `GET /v1/webhook-endpoints` answers your endpoints oldest first, a page at a
time: `limit` sets the page's length, 50 unless you say, at most 100, and you pass a page's `next`
as `after` for the next one. The last page's `next` is `null`. An `after` that isn't one of your
endpoints is refused with `422` `invalid_request`.

```json
{
  "items": [
    {
      "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90",
      "url": "https://partner.example.com/youth-webhook",
      "description": "Billing",
      "event_types": ["Access.ended", "AccessCode.redeemed"],
      "status": "active",
      "created_at": "2026-11-20T09:30:00.000Z",
      "updated_at": "2026-11-20T09:30:00.000Z"
    }
  ],
  "next": null
}
```

## Disable an endpoint

`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`, with no body, stops an active or a
paused endpoint and answers it, `disabled`. Every delivery it still had to receive fails at once:
read what it missed from the API. A delivery already on its way when you disable it still
arrives. A disabled endpoint can't be turned on again: create one for the address instead.
Disabling it again answers it as it stands.

## What an endpoint holds

- **Its address**, where YOU(th) sends each delivery: see [The address](#the-address).
- **The events it receives**, by `event_type`: see [Events](/docs/webhooks#events). An event type
  YOU(th) does not know is refused with `422`.
- **Its status**: `active`, `paused` or `disabled`.

An organization can have several endpoints, each with its own events and its own secret: one for
your billing system and one for your data platform, for example. It keeps ten at most, disabled
ones aside.

## The signing secret

Creating an endpoint answers `201`, with the endpoint and its signing secret, `signing_secret`: a
string that starts with `whsec_`. Only the create shows it, and a repeat of the same create (see
below). No read returns it, so store it in your server's secret store before you do anything
else. Your receiver
[verifies each delivery](/docs/webhooks/verify) with it.

The request that creates an endpoint must carry an `Idempotency-Key`, as
[Errors and rate limits](/docs/errors#repeat-a-request-safely) describes, so a repeat after a
timeout does not create a second one. A repeat with the same key and body, within 24 hours,
answers the same endpoint as it now stands, with the same secret.

## The address

| Rule               | Means                                                                              |
| ------------------ | ---------------------------------------------------------------------------------- |
| HTTPS, on port 443 | No plain HTTP, and no other port                                                   |
| A public address   | A host that resolves to a private, loopback or link-local address gets no delivery |
| No redirects       | A `3xx` answer is a failure, and is not followed                                   |

YOU(th) resolves the host each time it sends, so the rules hold for every delivery, not only when
the endpoint is created. Creating one already refuses a host that can't be public: `localhost`, a
name of one label such as `intranet`, or an IP address that is private, loopback or link-local.

## Status

| `status`   | Means                                                                                                                                                     |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `active`   | Deliveries are sent                                                                                                                                       |
| `paused`   | YOU(th) stopped sending, because the address kept answering `404` or `410`: see [When an address is gone](/docs/webhooks/retries#when-an-address-is-gone) |
| `disabled` | You stopped it                                                                                                                                            |

A paused or disabled endpoint gets no new deliveries. Read what it missed from the API:
[access codes](/docs/access-codes/reconcile#catch-up-after-an-outage) and
[checkups](/docs/webhooks/catch-up).

## Move to a new address

Create an endpoint for the new address, give your new receiver its secret, check that deliveries
arrive, then disable the old endpoint. While both are active, each event comes to both: your
receivers skip an `event_id` they have [already handled](/docs/webhooks/retries#take-each-event-once).
