---
title: "Create a webhook subscription"
method: POST
path: "/v1/webhook-subscriptions"
tags: ["Webhooks"]
---

# Create a webhook subscription

`POST /v1/webhook-subscriptions`

## Request

- Base URL: `https://api.mailrith.com`
- URL: `https://api.mailrith.com/v1/webhook-subscriptions`
- Auth: HTTP bearer

Creates a signed outbound webhook subscription and returns the signing secret once. The caller must also have read scopes for the selected event families. A workspace can have up to 20 webhook subscriptions, including disabled subscriptions.

## Headers

- `Idempotency-Key` string

## Request body

- WebhookSubscriptionCreateRequest
  - `name` string, required
  - `url` string, required: Public HTTPS destination URL for signed event delivery. Localhost, private network, link-local, and reserved destinations are not accepted.
  - `event_patterns` string[], required: Events or wildcard patterns to deliver through this outbound webhook destination.
  - `status` 'active' | 'disabled'

## Response `201`

Webhook subscription created

- object
  - `data` WebhookSubscriptionCreateResult, required
    - `subscription` WebhookSubscription, required
      - `self` string, required: Stable relative Public API path for retrieving this resource.
      - `id` string, required
      - `name` string, required
      - `url` string, required
      - `status` 'active' | 'disabled', required: Whether Mailrith currently delivers matching events to this destination.
      - `event_patterns` string[], required: Events or wildcard patterns to deliver through this outbound webhook destination.
      - `signing_secret_preview` string, required
      - `delivery_attempts` integer, required
      - `last_delivery_status` 'delivered' | 'failed' | 'null', nullable, required
      - `last_delivery_error` string, nullable, required
      - `last_delivered_at` string, date-time, nullable, required
      - `last_failed_at` string, date-time, nullable, required
      - `created_at` string, date-time, required
      - `updated_at` string, date-time, required
    - `signing_secret` string, required

## Other responses

- `400`: Invalid request
- `409`: The subscription name already exists or the workspace has reached its 20-subscription limit.

---

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