Python API
The current public surface is Python-first.
Construction
Section titled “Construction”app = knocker.open( "knocker.db", queue_name="knocker.events", visibility_timeout_s=60, max_attempts=3, max_readers=8,)Endpoint and handler registration
Section titled “Endpoint and handler registration”app.add_endpoint( name="stripe", path="/webhooks/stripe", provider="stripe", secrets=["whsec_123"],)
@app.handle(endpoint="stripe", event_type="checkout.session.completed")def handle_checkout(event, tx): ...Ingress
Section titled “Ingress”result = app.receive( endpoint="stripe", body=b"...", headers={"stripe-signature": "..."},)Lower-level contract entry:
result = app.ingest( endpoint="stripe", body=b"...", headers={}, query={}, method="POST", event_type="checkout.session.completed", provider_event_id="evt_1", provider_delivery_id="dlv_1", dedupe_key="evt_1", signature_valid=True, signature_error=None,)event = app.get_event(42)events = app.list_events(limit=50)
delivery = app.get_delivery(99)deliveries = app.list_deliveries(limit=50)Actions
Section titled “Actions”app.ignore(42)app.replay(42)app.requeue(42)Retention
Section titled “Retention”summary = app.prune_events(statuses=["handled", "ignored"], older_than=1700000000, limit=100)orphans = app.prune_orphan_deliveries(older_than=1700000000, limit=100)Result types
Section titled “Result types”IngestResult
delivery_id: intevent_id: int | Noneduplicate: boolstatus_code: int
Event
idendpointevent_typeprovider_event_idprovider_delivery_iddedupe_keystatusattempt_countheadersquerybodyreceived_athandled_atlast_error
Delivery
idevent_idendpointevent_typeprovider_event_idprovider_delivery_iddedupe_keymethodheadersquerybodyreceived_atsignature_validsignature_error
PruneEventsResult
events_prunedattempts_pruneddeliveries_prunedlive_jobs_pruned
PruneDeliveriesResult
deliveries_pruned