TypeScript SDK: Webhooks

⚠️
Preview — this feature is being built; the design below is the spec.

Manage endpoints and verify deliveries.

import Syntic from '@syntic/sdk'
 
const client = new Syntic() // reads SYNTIC_API_KEY
MethodEndpointReturns
webhooks.createPOST /v1/webhooksWebhook
webhooks.listGET /v1/webhooksSyncPage[Webhook]
webhooks.updatePATCH /v1/webhooks/{webhook_id}Webhook
webhooks.deleteDELETE /v1/webhooks/{webhook_id}WebhookDeleted
webhooks.rotateSecretPOST /v1/webhooks/{webhook_id}/rotate_secretWebhook
webhooks.testPOST /v1/webhooks/{webhook_id}/testWebhookDelivery
webhooks.unwrap(local, no request)WebhookEvent

Methods

webhooks.create

Register an endpoint; the result holds the signing secret once. Maps to POST /v1/webhooks.

const result = await client.webhooks.create({
  url: "https://hooks.example.com/syntic",
  events: [
    "batch.completed"
  ]
})

webhooks.list

List endpoints. Maps to GET /v1/webhooks.

for await (const item of client.webhooks.list()) {
  console.log(item)
}

webhooks.update

Change events, URL or status. Maps to PATCH /v1/webhooks/{webhook_id}.

const result = await client.webhooks.update("whk_01JCA4C6E8G0J2L4N6Q8", {
  status: "disabled"
})

webhooks.delete

Remove an endpoint. Maps to DELETE /v1/webhooks/{webhook_id}.

const result = await client.webhooks.delete("whk_01JCA4C6E8G0J2L4N6Q8")

webhooks.rotateSecret

New signing secret; both are valid during the overlap. Maps to POST /v1/webhooks/{webhook_id}/rotate_secret.

const result = await client.webhooks.rotateSecret("whk_01JCA4C6E8G0J2L4N6Q8")

webhooks.test

Send a webhook.test event. Maps to POST /v1/webhooks/{webhook_id}/test.

const result = await client.webhooks.test("whk_01JCA4C6E8G0J2L4N6Q8")

webhooks.unwrap

Verify the syntic-signature header against the raw body and return the typed event; raises on a bad signature or a stale timestamp.

const result = await client.webhooks.unwrap(rawBody, {
  headers: req.headers,
  secret: "whsec_…"
})

Conventions

Every method accepts a final options object with headers, query, timeout, maxRetries and signal (an AbortSignal). List methods return pages that work with for await across all pages.

See the TypeScript SDK overview for installation, errors and retries.

Was this page helpful?