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
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.
apiKeyheader
x-api-key<token>application/json- body
name*stringLength
1 <= length <= 100url*stringeventTypes*array<>Items
1 <= itemschannels?array<>|nullmailboxIds?array<>|nullnamespaceId?|nullheaders?|nullstatus?|nullSuccess
application/json- response
endpoint*secret*stringimport { 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"
}