Skip to Content

Create a webhook

Creates a signed webhook endpoint for Samva delivery and inbound events, stores subscriptions, and returns the endpoint and signing secret with a 201 response.

POST
/v1/webhooks

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.

Authorization

apiKey
headerx-api-key<token>

Request Body

application/json
  1. body
name*string
Length1 <= length <= 100
url*string
eventTypes*array<>
Items1 <= items
channels?array<>|null
mailboxIds?array<>|null
namespaceId?|null
headers?|null
status?|null

Response Body

Success

application/json
  1. response
endpoint*
secret*string
Example Request
import { createClient } from "samva";

const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });

const result = await samva.webhooks.create({
  "name": "example",
  "url": "example",
  "eventTypes": [
    "message.sent"
  ]
});
Example Response
{
  "endpoint": {
    "id": "string",
    "name": "string",
    "url": "string",
    "eventTypes": [
      "message.sent"
    ],
    "channels": [
      "sms"
    ],
    "mailboxIds": [
      "string"
    ],
    "namespaceId": "string",
    "status": "active",
    "hasCustomHeaders": true,
    "failureStartedAt": "string",
    "lastSucceededAt": "string",
    "createdAt": "string",
    "updatedAt": "string"
  },
  "secret": "string"
}

Related documentation