Python SDK: Webhooks

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

Manage endpoints and verify deliveries.

from syntic import Syntic
 
client = 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.rotate_secretPOST /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.

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

webhooks.list

List endpoints. Maps to GET /v1/webhooks.

for item in client.webhooks.list():
    print(item.id if hasattr(item, 'id') else item)

webhooks.update

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

result = client.webhooks.update('whk_01JCA4C6E8G0J2L4N6Q8', status="disabled")

webhooks.delete

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

result = client.webhooks.delete('whk_01JCA4C6E8G0J2L4N6Q8')

webhooks.rotate_secret

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

result = client.webhooks.rotate_secret('whk_01JCA4C6E8G0J2L4N6Q8')

webhooks.test

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

result = 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.

result = client.webhooks.unwrap(raw_body, headers=request.headers, secret="whsec_…")

Conventions

Every method accepts extra_headers, extra_query, extra_body and timeout keyword arguments, and has an async twin on AsyncSyntic. List methods return pages that iterate across all pages automatically.

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

Was this page helpful?