> Register, list and delete the URLs Plandalf sends webhook events to. Endpoints are managed through the API.

Source: https://plandalf.com/docs/api/webhook-endpoints

API and webhooks

# Webhook endpoints

A webhook endpoint is a URL on your server that receives Plandalf's [webhook events](https://plandalf.com/docs/api/webhooks). You register endpoints through the API; there's no dashboard screen for them.

## Example

```bash
curl -X POST https://admin.plandalf.dev/api/v1/webhook_endpoints \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/webhooks/plandalf", "description": "Fulfilment", "events": ["checkout.completed", "invoice.refunded", "subscription.canceled"]}'
```

The response includes the endpoint's signing `secret` (`whsec_…`). It's shown this once, so store it now: you need it to [verify signatures](https://plandalf.com/docs/api/verify-signatures).

-   `events` lists event types, or `["*"]` for every event.
-   The URL must be public and use `https`.
-   The endpoint's mode follows the key you register it with: a `test_` key's endpoint gets test-mode events only, a `live_` key's live ones only. Register one of each if you want both.
-   Deleting an endpoint stops its deliveries, including retries still waiting.
-   An endpoint is turned off if it has gone 3 days without a successful delivery. See [Delivery and retries](https://plandalf.com/docs/api/webhooks#delivery).

## Endpoints

### List webhook endpoints

GET `/api/v1/webhook_endpoints`

Newest first. An OAuth site connection sees only the endpoints it registered.

```bash
curl https://admin.plandalf.dev/api/v1/webhook_endpoints \
  -H "Authorization: Bearer $PLANDALF_API_KEY"
```

#### Response

```json
{
  "data": [
    {
      "id": 0,
      "url": "string",
      "events": [
        "string"
      ],
      "mode": "string",
      "status": "string",
      "description": "string",
      "created_at": "string"
    }
  ]
}
```

#### Errors

Status

When

`401`

The API key or OAuth token is missing or invalid.

### Create a webhook endpoint

POST `/api/v1/webhook_endpoints`

The endpoint's mode follows the key that registered it: a `test_` key's endpoint receives test-mode events only, a `live_` key's live-mode events only. `events` lists event types, or `*` for all of them. The response includes the signing `secret`, once; store it to verify the `Plandalf-Signature` header. The URL must be public https.

#### Body

Field

Type

What it is

`url`

`string`

`description` optional

`string | null`

`events`

`"*" | "checkout.completed" | "invoice.paid" | "invoice.payment_failed" | "invoice.voided" | "invoice.refunded" | "subscription.updated" | "subscription.canceled"[]`

```bash
curl -X POST https://admin.plandalf.dev/api/v1/webhook_endpoints \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"string","description":"string","events":["*"]}'
```

#### Response

```json
{
  "id": 0,
  "url": "string",
  "events": [
    "string"
  ],
  "mode": "string",
  "status": "string",
  "description": "string",
  "created_at": "string",
  "secret": "string"
}
```

#### Errors

Status

When

`401`

The API key or OAuth token is missing or invalid.

`403`

The credentials are valid but not allowed here: a site-connection token outside its scope, or the organization can't make this request.

`422`

The request failed validation; `errors` lists the problems by field.

### Delete a webhook endpoint

DELETE `/api/v1/webhook_endpoints/{webhookEndpoint}`

Stops deliveries to it, including retries that are still pending.

#### Parameters

Name

In

Type

What it is

`webhookEndpoint`

path

`integer`

```bash
curl -X DELETE https://admin.plandalf.dev/api/v1/webhook_endpoints/:webhookEndpoint \
  -H "Authorization: Bearer $PLANDALF_API_KEY"
```

#### Response

```json
{
  "id": 0,
  "deleted": true
}
```

#### Errors

Status

When

`401`

The API key or OAuth token is missing or invalid.

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
