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

# Create a webhook

`POST /v1/webhooks`

## Request

- Base URL: `https://api.samva.dev`
- URL: `https://api.samva.dev/v1/webhooks`
- Auth: API key in header `x-api-key`

Creates a signed webhook endpoint for Samva delivery and inbound events, stores subscriptions, and returns the endpoint and signing secret with a 201 response. `namespaceId` confines the endpoint to one namespace's events and `mailboxIds` to those mailboxes' events; when both are set, every mailbox must belong to the namespace.

## Request body

- CreateWebhookPayload
  - `name` string, required
  - `url` string, required
  - `eventTypes` string[], required
  - `channels` string[], nullable
  - `mailboxIds` MailboxId[], nullable
  - `namespaceId` string
  - `headers` object, nullable
  - `status` 'active' | 'disabled', nullable

## Response `201`

Success

- object
  - `endpoint` WebhookEndpoint, required
    - `id` string, required
    - `name` string, required
    - `url` string, required
    - `eventTypes` string[], required
    - `channels` string[], nullable, required
    - `mailboxIds` MailboxId[], nullable, required
    - `namespaceId` string, required
    - `status` 'active' | 'disabled', required
    - `hasCustomHeaders` boolean, required
    - `failureStartedAt` string, nullable, required
    - `lastSucceededAt` string, nullable, required
    - `createdAt` string, required
    - `updatedAt` string, required
  - `secret` string, required

## Other responses

- `401`: UnauthorizedError
- `402`: PaymentRequiredError
- `403`: ForbiddenError
- `404`: ResourceNotFoundError
- `409`: ConflictError
- `422`: ValidationError
- `500`: InternalError
- `502`: BillingProviderError
- `504`: GatewayTimeoutError

---

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