hookbase 4.3.0__tar.gz → 4.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {hookbase-4.3.0 → hookbase-4.4.0}/PKG-INFO +55 -1
  2. {hookbase-4.3.0 → hookbase-4.4.0}/README.md +54 -0
  3. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/_pagination.py +7 -2
  4. hookbase-4.4.0/src/hookbase/_version.py +1 -0
  5. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/__init__.py +17 -0
  6. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/destinations.py +20 -0
  7. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/events.py +36 -0
  8. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/routes.py +71 -1
  9. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/sources.py +36 -2
  10. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/routes.py +53 -0
  11. hookbase-4.4.0/tests/resources/test_shadow_traffic.py +383 -0
  12. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_source_fields.py +4 -0
  13. hookbase-4.4.0/tests/resources/test_source_header_auth.py +158 -0
  14. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_sync_async_parity.py +17 -0
  15. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_models_exports.py +11 -0
  16. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_pagination.py +17 -0
  17. hookbase-4.3.0/src/hookbase/_version.py +0 -1
  18. {hookbase-4.3.0 → hookbase-4.4.0}/.github/workflows/python-publish.yml +0 -0
  19. {hookbase-4.3.0 → hookbase-4.4.0}/.gitignore +0 -0
  20. {hookbase-4.3.0 → hookbase-4.4.0}/LICENSE +0 -0
  21. {hookbase-4.3.0 → hookbase-4.4.0}/examples/async_usage.py +0 -0
  22. {hookbase-4.3.0 → hookbase-4.4.0}/examples/basic_inbound.py +0 -0
  23. {hookbase-4.3.0 → hookbase-4.4.0}/examples/error_handling.py +0 -0
  24. {hookbase-4.3.0 → hookbase-4.4.0}/examples/send_webhooks.py +0 -0
  25. {hookbase-4.3.0 → hookbase-4.4.0}/examples/verify_webhooks.py +0 -0
  26. {hookbase-4.3.0 → hookbase-4.4.0}/pyproject.toml +0 -0
  27. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/__init__.py +0 -0
  28. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/_client.py +0 -0
  29. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/_constants.py +0 -0
  30. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/client.py +0 -0
  31. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/errors.py +0 -0
  32. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/_base.py +0 -0
  33. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/_wire.py +0 -0
  34. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/analytics.py +0 -0
  35. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/api_keys.py +0 -0
  36. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/applications.py +0 -0
  37. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/catalog.py +0 -0
  38. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/common.py +0 -0
  39. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/cron_jobs.py +0 -0
  40. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/deliveries.py +0 -0
  41. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/dlq.py +0 -0
  42. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/endpoints.py +0 -0
  43. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/event_types.py +0 -0
  44. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/filters.py +0 -0
  45. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/messages.py +0 -0
  46. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/organizations.py +0 -0
  47. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/portal_tokens.py +0 -0
  48. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/schemas.py +0 -0
  49. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/subscriptions.py +0 -0
  50. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/transforms.py +0 -0
  51. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/models/tunnels.py +0 -0
  52. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/py.typed +0 -0
  53. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/__init__.py +0 -0
  54. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/_base.py +0 -0
  55. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/analytics.py +0 -0
  56. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/api_keys.py +0 -0
  57. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/applications.py +0 -0
  58. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/cron_jobs.py +0 -0
  59. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/deliveries.py +0 -0
  60. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/destinations.py +0 -0
  61. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/dlq.py +0 -0
  62. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/endpoints.py +0 -0
  63. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/event_types.py +0 -0
  64. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/events.py +0 -0
  65. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/filters.py +0 -0
  66. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/message_log.py +0 -0
  67. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/messages.py +0 -0
  68. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/organizations.py +0 -0
  69. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/portal_tokens.py +0 -0
  70. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/providers.py +0 -0
  71. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/schemas.py +0 -0
  72. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/sources.py +0 -0
  73. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/subscriptions.py +0 -0
  74. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/transforms.py +0 -0
  75. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/resources/tunnels.py +0 -0
  76. {hookbase-4.3.0 → hookbase-4.4.0}/src/hookbase/webhook.py +0 -0
  77. {hookbase-4.3.0 → hookbase-4.4.0}/tests/__init__.py +0 -0
  78. {hookbase-4.3.0 → hookbase-4.4.0}/tests/conftest.py +0 -0
  79. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/__init__.py +0 -0
  80. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_applications.py +0 -0
  81. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_cron_jobs.py +0 -0
  82. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_destinations.py +0 -0
  83. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_dlq.py +0 -0
  84. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_endpoints.py +0 -0
  85. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_inbound_contract.py +0 -0
  86. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_messages.py +0 -0
  87. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_open_types.py +0 -0
  88. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_outbound_contract.py +0 -0
  89. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_resource_contracts.py +0 -0
  90. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_source_connections.py +0 -0
  91. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_source_contract.py +0 -0
  92. {hookbase-4.3.0 → hookbase-4.4.0}/tests/resources/test_sources.py +0 -0
  93. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_client.py +0 -0
  94. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_errors.py +0 -0
  95. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_http_client.py +0 -0
  96. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_retry.py +0 -0
  97. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_secret_redaction.py +0 -0
  98. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_slug_contract.py +0 -0
  99. {hookbase-4.3.0 → hookbase-4.4.0}/tests/test_webhook.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hookbase
3
- Version: 4.3.0
3
+ Version: 4.4.0
4
4
  Summary: Official Python SDK for the Hookbase webhook management platform
5
5
  Project-URL: Homepage, https://hookbase.app
6
6
  Project-URL: Documentation, https://www.hookbase.app/docs/send/sdk
@@ -140,6 +140,16 @@ client.sources.rotate_verify_token(wa.id)
140
140
  pending = client.sources.get_pending_verification("notion")
141
141
  client.sources.adopt_pending_verification("notion")
142
142
 
143
+ # Header auth: check a static credential instead of the provider's signature. The credential is
144
+ # the source's signing secret (omit it and one is generated): a bearer token, "username:password"
145
+ # for basic, or the token a "header" source reads from verification_header.
146
+ erp = client.sources.create({"name": "ERP", "slug": "erp", "verificationMethod": "header",
147
+ "verificationHeader": "X-Webhook-Token"})
148
+ token = erp.signing_secret # returned once; reveal_secret() and rotate_secret() later
149
+ erp.verification_method, erp.verification_header # "header", "x-webhook-token"
150
+ client.sources.update(erp.id, {"verificationMethod": "bearer"}) # same token, header removed
151
+ # Any other switch takes the new credential in the same update, as signingSecret
152
+
143
153
  # Connected sources: give Hookbase a least-privilege provider key (Stripe, GitHub or Paddle) and
144
154
  # it registers the webhook, holds its signing secret, and recovers events the provider failed to
145
155
  # deliver (Pro and Business). The key is never returned or logged, and ConnectSourceParams
@@ -193,6 +203,15 @@ bridge = client.destinations.create(CreateDestinationParams(
193
203
  result = client.destinations.test(bridge.id, payload={"type": "created"})
194
204
  result.event_type, result.event_type_exists, result.matching_endpoints
195
205
 
206
+ # Shadow destinations (Pro and Business) get sampled copies of their routes' events, with personal
207
+ # data replaced by fakes, for a dev tunnel or a preview deployment, and never production
208
+ # deliveries. HTTP only, no static IP, and the URL is an external host or one of your tunnels.
209
+ # purpose is fixed at create: an update leaves it out unless you set it.
210
+ preview = client.destinations.create({"name": "Preview", "slug": "preview",
211
+ "url": "https://preview.example.com/hook",
212
+ "purpose": "shadow"})
213
+ preview.purpose # "shadow"; "live" for every other destination
214
+
196
215
  # Routes
197
216
  client.routes.create({"name": "Route", "sourceId": "src_id", "destinationId": "dst_id"})
198
217
  client.routes.get_circuit_status("route_id")
@@ -204,6 +223,16 @@ client.routes.reset_circuit("route_id")
204
223
  client.routes.update("route_id", {"holdOnCircuitOpen": False})
205
224
  client.routes.get("route_id").held_count # get only; held_count_capped past 10,000
206
225
 
226
+ # A route to a shadow destination is a shadow route: it copies sample_rate (0.0001 to 1, all
227
+ # matching events when left out) of the events it matches, and makes no deliveries.
228
+ shadow = client.routes.create({"name": "Preview copy", "sourceId": "src_id",
229
+ "destinationId": preview.id, "sampleRate": 0.25})
230
+ shadow.mode, shadow.sample_rate # "shadow", 0.25; a live route reads "live", None
231
+ client.routes.update(shadow.id, {"sampleRate": 0.05})
232
+ # Each copy's outcome (copies never show up in deliveries), newest first, cursor-paged
233
+ for copy in client.routes.list_shadow_deliveries(shadow.id, limit=50).auto_paging_iter():
234
+ print(copy.event_id, copy.status, copy.reason, copy.status_code)
235
+
207
236
  # Events & Deliveries
208
237
  client.events.list(source_id="src_id", from_date="2024-01-01") # id or slug; unknown -> 404
209
238
  client.events.get("evt_id") # Includes payload and deliveries
@@ -331,6 +360,8 @@ for app in apps.auto_paging_iter():
331
360
  print(app.name)
332
361
  for event in client.events.list(limit=100).auto_paging_iter():
333
362
  print(event.id)
363
+ for copy in client.routes.list_shadow_deliveries("route_id").auto_paging_iter():
364
+ print(copy.status)
334
365
 
335
366
  # Limit/offset with no total (deliveries): pages until one comes back short
336
367
  for delivery in client.deliveries.list(status="failed", limit=100).auto_paging_iter():
@@ -458,6 +489,29 @@ source = client.sources.create({"name": "GitHub", "slug": "github", "provider":
458
489
  # source with a provider newer than this package still parses.
459
490
  ```
460
491
 
492
+ ## Upgrading to 4.4
493
+
494
+ - Shadow traffic: `Destination.purpose` (`"live"` or `"shadow"`) on create, get and list, and
495
+ `purpose` on `CreateDestinationParams`; `UpdateDestinationParams.purpose` is sent only when set
496
+ (a change is a 409 `PURPOSE_IMMUTABLE`). `Route.mode` (read-only: the destination's purpose)
497
+ and `Route.sample_rate` (None on a live route), and `sample_rate` on `CreateRouteParams` and
498
+ `UpdateRouteParams`, sent only when set. `routes.list_shadow_deliveries(id, limit=, cursor=)`
499
+ returns a cursor page of `ShadowDelivery` with `auto_paging_iter()`. `events.debug()` gains
500
+ `filter_evaluations` (`EventDebugFilterEvaluation`: each route's filter verdict, `mode`,
501
+ `sample_rate` and, for a shadow route, whether the event is in its sample).
502
+ - Source header auth: `verification_method` (`"signature"`, `"bearer"`, `"basic"` or
503
+ `"header"`) and `verification_header` on `Source`, `CreateSourceParams` and
504
+ `UpdateSourceParams`. `clear=["verificationHeader"]` sends its null. The credential is the
505
+ signing secret, so it stays out of `repr()`, `str()` and validation errors.
506
+ - `ShadowDelivery.status` and `reason`, `DestinationPurpose`, `RouteMode` and
507
+ `VerificationMethod` accept any string, with today's values listed for type checkers.
508
+ - The shadow error codes (`SAMPLE_RATE_NOT_ALLOWED`, `SAMPLE_RATE_INVALID`,
509
+ `ROUTE_PURPOSE_CONFLICT`, `SHADOW_DESTINATION_HTTP_ONLY`, `SHADOW_DESTINATION_NOT_ALLOWED`,
510
+ `INVALID_CURSOR`, ...) arrive in `APIError.code`; a plan without shadow traffic is a
511
+ `ForbiddenError` with code `FEATURE_DISABLED`.
512
+ - A cursor list that sends a `nextCursor` and no `hasMore` now reports `has_more` from the
513
+ cursor. Every list that already sent `hasMore` is unchanged.
514
+
461
515
  ## Upgrading to 4.3
462
516
 
463
517
  - Connected sources: `sources.connect()`, `get_connection()`, `update_connection()`,
@@ -102,6 +102,16 @@ client.sources.rotate_verify_token(wa.id)
102
102
  pending = client.sources.get_pending_verification("notion")
103
103
  client.sources.adopt_pending_verification("notion")
104
104
 
105
+ # Header auth: check a static credential instead of the provider's signature. The credential is
106
+ # the source's signing secret (omit it and one is generated): a bearer token, "username:password"
107
+ # for basic, or the token a "header" source reads from verification_header.
108
+ erp = client.sources.create({"name": "ERP", "slug": "erp", "verificationMethod": "header",
109
+ "verificationHeader": "X-Webhook-Token"})
110
+ token = erp.signing_secret # returned once; reveal_secret() and rotate_secret() later
111
+ erp.verification_method, erp.verification_header # "header", "x-webhook-token"
112
+ client.sources.update(erp.id, {"verificationMethod": "bearer"}) # same token, header removed
113
+ # Any other switch takes the new credential in the same update, as signingSecret
114
+
105
115
  # Connected sources: give Hookbase a least-privilege provider key (Stripe, GitHub or Paddle) and
106
116
  # it registers the webhook, holds its signing secret, and recovers events the provider failed to
107
117
  # deliver (Pro and Business). The key is never returned or logged, and ConnectSourceParams
@@ -155,6 +165,15 @@ bridge = client.destinations.create(CreateDestinationParams(
155
165
  result = client.destinations.test(bridge.id, payload={"type": "created"})
156
166
  result.event_type, result.event_type_exists, result.matching_endpoints
157
167
 
168
+ # Shadow destinations (Pro and Business) get sampled copies of their routes' events, with personal
169
+ # data replaced by fakes, for a dev tunnel or a preview deployment, and never production
170
+ # deliveries. HTTP only, no static IP, and the URL is an external host or one of your tunnels.
171
+ # purpose is fixed at create: an update leaves it out unless you set it.
172
+ preview = client.destinations.create({"name": "Preview", "slug": "preview",
173
+ "url": "https://preview.example.com/hook",
174
+ "purpose": "shadow"})
175
+ preview.purpose # "shadow"; "live" for every other destination
176
+
158
177
  # Routes
159
178
  client.routes.create({"name": "Route", "sourceId": "src_id", "destinationId": "dst_id"})
160
179
  client.routes.get_circuit_status("route_id")
@@ -166,6 +185,16 @@ client.routes.reset_circuit("route_id")
166
185
  client.routes.update("route_id", {"holdOnCircuitOpen": False})
167
186
  client.routes.get("route_id").held_count # get only; held_count_capped past 10,000
168
187
 
188
+ # A route to a shadow destination is a shadow route: it copies sample_rate (0.0001 to 1, all
189
+ # matching events when left out) of the events it matches, and makes no deliveries.
190
+ shadow = client.routes.create({"name": "Preview copy", "sourceId": "src_id",
191
+ "destinationId": preview.id, "sampleRate": 0.25})
192
+ shadow.mode, shadow.sample_rate # "shadow", 0.25; a live route reads "live", None
193
+ client.routes.update(shadow.id, {"sampleRate": 0.05})
194
+ # Each copy's outcome (copies never show up in deliveries), newest first, cursor-paged
195
+ for copy in client.routes.list_shadow_deliveries(shadow.id, limit=50).auto_paging_iter():
196
+ print(copy.event_id, copy.status, copy.reason, copy.status_code)
197
+
169
198
  # Events & Deliveries
170
199
  client.events.list(source_id="src_id", from_date="2024-01-01") # id or slug; unknown -> 404
171
200
  client.events.get("evt_id") # Includes payload and deliveries
@@ -293,6 +322,8 @@ for app in apps.auto_paging_iter():
293
322
  print(app.name)
294
323
  for event in client.events.list(limit=100).auto_paging_iter():
295
324
  print(event.id)
325
+ for copy in client.routes.list_shadow_deliveries("route_id").auto_paging_iter():
326
+ print(copy.status)
296
327
 
297
328
  # Limit/offset with no total (deliveries): pages until one comes back short
298
329
  for delivery in client.deliveries.list(status="failed", limit=100).auto_paging_iter():
@@ -420,6 +451,29 @@ source = client.sources.create({"name": "GitHub", "slug": "github", "provider":
420
451
  # source with a provider newer than this package still parses.
421
452
  ```
422
453
 
454
+ ## Upgrading to 4.4
455
+
456
+ - Shadow traffic: `Destination.purpose` (`"live"` or `"shadow"`) on create, get and list, and
457
+ `purpose` on `CreateDestinationParams`; `UpdateDestinationParams.purpose` is sent only when set
458
+ (a change is a 409 `PURPOSE_IMMUTABLE`). `Route.mode` (read-only: the destination's purpose)
459
+ and `Route.sample_rate` (None on a live route), and `sample_rate` on `CreateRouteParams` and
460
+ `UpdateRouteParams`, sent only when set. `routes.list_shadow_deliveries(id, limit=, cursor=)`
461
+ returns a cursor page of `ShadowDelivery` with `auto_paging_iter()`. `events.debug()` gains
462
+ `filter_evaluations` (`EventDebugFilterEvaluation`: each route's filter verdict, `mode`,
463
+ `sample_rate` and, for a shadow route, whether the event is in its sample).
464
+ - Source header auth: `verification_method` (`"signature"`, `"bearer"`, `"basic"` or
465
+ `"header"`) and `verification_header` on `Source`, `CreateSourceParams` and
466
+ `UpdateSourceParams`. `clear=["verificationHeader"]` sends its null. The credential is the
467
+ signing secret, so it stays out of `repr()`, `str()` and validation errors.
468
+ - `ShadowDelivery.status` and `reason`, `DestinationPurpose`, `RouteMode` and
469
+ `VerificationMethod` accept any string, with today's values listed for type checkers.
470
+ - The shadow error codes (`SAMPLE_RATE_NOT_ALLOWED`, `SAMPLE_RATE_INVALID`,
471
+ `ROUTE_PURPOSE_CONFLICT`, `SHADOW_DESTINATION_HTTP_ONLY`, `SHADOW_DESTINATION_NOT_ALLOWED`,
472
+ `INVALID_CURSOR`, ...) arrive in `APIError.code`; a plan without shadow traffic is a
473
+ `ForbiddenError` with code `FEATURE_DISABLED`.
474
+ - A cursor list that sends a `nextCursor` and no `hasMore` now reports `has_more` from the
475
+ cursor. Every list that already sent `hasMore` is unchanged.
476
+
423
477
  ## Upgrading to 4.3
424
478
 
425
479
  - Connected sources: `sources.connect()`, `get_connection()`, `update_connection()`,
@@ -543,7 +543,10 @@ def _extract_cursor_data(
543
543
  """Extract items + pagination from a cursor-based API response.
544
544
 
545
545
  Most cursor lists nest `hasMore`/`nextCursor` under `pagination`; inbound
546
- events (`GET /api/events`) put them at the top level next to `events`.
546
+ events (`GET /api/events`) put them at the top level next to `events`. A
547
+ list that sends no `hasMore` at all (a shadow route's copies,
548
+ `GET /api/routes/:id/shadow-deliveries`) has more while it hands out a
549
+ `nextCursor`, which is null on its last page.
547
550
  """
548
551
  if not isinstance(resp, dict):
549
552
  return [], False, None
@@ -552,8 +555,10 @@ def _extract_cursor_data(
552
555
  pagination = resp.get("pagination")
553
556
  if not isinstance(pagination, dict):
554
557
  pagination = resp
555
- has_more = pagination.get("hasMore", pagination.get("has_more", False))
556
558
  next_cursor = pagination.get("nextCursor", pagination.get("next_cursor"))
559
+ has_more = pagination.get("hasMore", pagination.get("has_more"))
560
+ if has_more is None:
561
+ has_more = next_cursor is not None
557
562
 
558
563
  return items if isinstance(items, list) else [], bool(has_more), next_cursor
559
564
 
@@ -0,0 +1 @@
1
+ __version__ = "4.4.0"
@@ -67,6 +67,7 @@ from .destinations import (
67
67
  BridgeEventTypeSource,
68
68
  CreateDestinationParams,
69
69
  Destination,
70
+ DestinationPurpose,
70
71
  DestinationSecret,
71
72
  DestinationType,
72
73
  DestinationWithSecret,
@@ -116,9 +117,11 @@ from .events import (
116
117
  EventDebugDelivery,
117
118
  EventDebugDestination,
118
119
  EventDebugEvent,
120
+ EventDebugFilterEvaluation,
119
121
  EventDebugInfo,
120
122
  EventDebugPatternHint,
121
123
  EventDebugRouteCircuit,
124
+ EventDebugShadowSample,
122
125
  EventDelivery,
123
126
  EventDetail,
124
127
  InboundEventStatus,
@@ -150,6 +153,10 @@ from .routes import (
150
153
  CircuitStatusInfo,
151
154
  CreateRouteParams,
152
155
  Route,
156
+ RouteMode,
157
+ ShadowDelivery,
158
+ ShadowDeliveryReason,
159
+ ShadowDeliveryStatus,
153
160
  UpdateRouteParams,
154
161
  )
155
162
  from .schemas import (
@@ -191,6 +198,7 @@ from .sources import (
191
198
  SourceWithSecret,
192
199
  UpdateSourceConnectionParams,
193
200
  UpdateSourceParams,
201
+ VerificationMethod,
194
202
  )
195
203
  from .subscriptions import (
196
204
  CreateSubscriptionParams,
@@ -282,6 +290,7 @@ __all__ = [
282
290
  "BridgeEventTypeSource",
283
291
  "CreateDestinationParams",
284
292
  "Destination",
293
+ "DestinationPurpose",
285
294
  "DestinationSecret",
286
295
  "DestinationType",
287
296
  "DestinationWithSecret",
@@ -336,6 +345,8 @@ __all__ = [
336
345
  "EventDebugDestination",
337
346
  "EventDebugPatternHint",
338
347
  "EventDebugRouteCircuit",
348
+ "EventDebugFilterEvaluation",
349
+ "EventDebugShadowSample",
339
350
  "EventDelivery",
340
351
  # Filters
341
352
  "CreateFilterParams",
@@ -367,7 +378,12 @@ __all__ = [
367
378
  "CircuitStatusInfo",
368
379
  "CreateRouteParams",
369
380
  "Route",
381
+ "RouteMode",
370
382
  "UpdateRouteParams",
383
+ # Shadow traffic
384
+ "ShadowDelivery",
385
+ "ShadowDeliveryReason",
386
+ "ShadowDeliveryStatus",
371
387
  # Schemas
372
388
  "CreateSchemaParams",
373
389
  "Schema",
@@ -388,6 +404,7 @@ __all__ = [
388
404
  "SourceWithSecret",
389
405
  "UpdateSourceParams",
390
406
  "IngestMethod",
407
+ "VerificationMethod",
391
408
  # Connected sources
392
409
  "ConnectionEnvironment",
393
410
  "ConnectionProvider",
@@ -26,6 +26,11 @@ PartitionBy = Literal["date", "hour", "source"]
26
26
  FieldMappingType = Literal["string", "number", "boolean", "timestamp", "json"]
27
27
  ThrottleMode = Literal["off", "rate", "concurrency"]
28
28
  RateUnit = Literal["second", "minute", "hour"]
29
+ #: What a destination is for, fixed when it is created. "live" (the default) gets deliveries.
30
+ #: "shadow" gets sampled copies of its routes' events with personal data replaced by fakes, for a
31
+ #: dev tunnel or a preview deployment, and never gets production deliveries. Any string, so a
32
+ #: value added later still parses.
33
+ DestinationPurpose = Union[Literal["live", "shadow"], str]
29
34
 
30
35
 
31
36
  class FieldMapping(HookbaseModel):
@@ -143,6 +148,10 @@ class Destination(HookbaseModel):
143
148
  has_signing_secret: bool = False
144
149
  """Whether deliveries to this destination are signed (HTTP destinations only). The secret
145
150
  itself is returned once, by `create`; after that use `destinations.reveal_secret`."""
151
+ purpose: DestinationPurpose = "live"
152
+ """"live", or "shadow" for a shadow destination (its routes send sampled, scrubbed copies
153
+ instead of deliveries). Set on create and never changed. Returned by create, get and list;
154
+ "live" when the response doesn't say."""
146
155
  delivery_count: int = 0
147
156
  last_delivery_at: str | None = None
148
157
  created_at: str = ""
@@ -310,6 +319,14 @@ class CreateDestinationParams(HookbaseModel):
310
319
  use_static_ip: bool | None = None
311
320
  batch_size: int | None = None
312
321
  batch_window_seconds: int | None = None
322
+ purpose: DestinationPurpose | None = None
323
+ """"shadow" makes a shadow destination: its routes send sampled copies of matching events,
324
+ with personal data replaced by fakes, and it never gets production deliveries. Left out (the
325
+ API's default) makes a live one. It can't change after create.
326
+
327
+ A shadow destination must be `type="http"` (400 `SHADOW_DESTINATION_HTTP_ONLY`), can't use
328
+ a static IP, and its URL must be an external host or one of the organization's own tunnel
329
+ URLs (`.../t/<subdomain>/...`). Pro and Business plans only (403 `FEATURE_DISABLED`)."""
313
330
 
314
331
  # Deprecated fields; see `create_destination_body` for what each one does
315
332
  # on the wire.
@@ -350,6 +367,9 @@ class UpdateDestinationParams(HookbaseModel):
350
367
  use_static_ip: bool | None = None
351
368
  batch_size: int | None = None
352
369
  batch_window_seconds: int | None = None
370
+ purpose: DestinationPurpose | None = None
371
+ """A destination's purpose never changes. Sent only when set: the stored value is accepted
372
+ as a no-op, any other is a 409 `PURPOSE_IMMUTABLE` (create a new destination instead)."""
353
373
 
354
374
  # Deprecated fields; see `CreateDestinationParams` for each one's status.
355
375
  description: str | None = None
@@ -7,6 +7,7 @@ from pydantic import field_validator, model_validator
7
7
 
8
8
  from ._base import HookbaseModel
9
9
  from .deliveries import Delivery, DeliveryStatus
10
+ from .routes import RouteMode
10
11
  from .sources import EventRecovery
11
12
 
12
13
  # The API derives it from the event's deliveries: delivered, failed, partial (some delivered),
@@ -204,6 +205,33 @@ class EventDebugDelivery(HookbaseModel):
204
205
  return 0 if v is None else v
205
206
 
206
207
 
208
+ class EventDebugShadowSample(HookbaseModel):
209
+ """Whether a shadow route copies this event (`EventDebugFilterEvaluation.shadow`)."""
210
+
211
+ in_sample: bool = False
212
+ """Whether the event is in the route's sample, by the route's current settings."""
213
+ note: str = ""
214
+ """What the route does with this event, in a sentence."""
215
+
216
+
217
+ class EventDebugFilterEvaluation(HookbaseModel):
218
+ """How one of the source's routes treats the event, as `events.debug` reports it."""
219
+
220
+ route_id: str
221
+ route_name: str = ""
222
+ has_filter: bool = False
223
+ evaluation: Any = None
224
+ """The filter's evaluation trace (whether it passed, and each condition's result); None
225
+ when the route has no filter or its conditions didn't parse."""
226
+ parse_error: str | None = None
227
+ mode: RouteMode = "live"
228
+ """The route's mode: "shadow" routes copy a sample of events and make no deliveries."""
229
+ sample_rate: float | None = None
230
+ """A shadow route's share of matching events copied (0.0001 to 1); None for a live route."""
231
+ shadow: EventDebugShadowSample | None = None
232
+ """Shadow routes only: whether this event gets a copy."""
233
+
234
+
207
235
  class EventDebugInfo(HookbaseModel):
208
236
  """The result of `events.debug`."""
209
237
 
@@ -212,10 +240,18 @@ class EventDebugInfo(HookbaseModel):
212
240
  """The stored payload; None for a transient event or one whose payload has expired."""
213
241
  transient: bool = False
214
242
  deliveries: list[EventDebugDelivery] = []
243
+ filter_evaluations: list[EventDebugFilterEvaluation] = []
244
+ """One entry per route of the event's source, as ingest sees them now: its filter's verdict,
245
+ and for a shadow route its sample rate and whether the event is in the sample."""
215
246
  curl_command: str = ""
216
247
  """A curl command that re-sends the event to its source. Empty for a transient event, whose
217
248
  payload is not stored."""
218
249
 
250
+ @field_validator("filter_evaluations", mode="before")
251
+ @classmethod
252
+ def _null_evaluations(cls, v: Any) -> Any:
253
+ return [] if v is None else v
254
+
219
255
  @model_validator(mode="before")
220
256
  @classmethod
221
257
  def _lift_debug_fields(cls, data: Any) -> Any:
@@ -1,12 +1,38 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Literal
3
+ from typing import Any, Literal, Union
4
4
 
5
5
  from ._base import HookbaseModel
6
6
  from .filters import FilterCondition
7
7
 
8
8
  CircuitStatus = Literal["closed", "open", "half_open"]
9
9
 
10
+ #: A route's mode: its destination's purpose. "live" routes deliver; "shadow" routes send sampled,
11
+ #: scrubbed copies (see ShadowDelivery). Any string, so a value added later still parses.
12
+ RouteMode = Union[Literal["live", "shadow"], str]
13
+
14
+ #: A shadow copy's status. sending: being prepared or sent. delivered: the receiver answered 2xx.
15
+ #: failed and skipped: see `reason`. unknown: still sending an hour after it was claimed, with no
16
+ #: outcome recorded; it may or may not have been sent, and is never resent. Any string, so a status
17
+ #: added later still parses.
18
+ ShadowDeliveryStatus = Union[
19
+ Literal["sending", "delivered", "failed", "skipped", "unknown"], str,
20
+ ]
21
+
22
+ #: Why a shadow copy was skipped or failed (None when it was delivered or is still sending). Any
23
+ #: string, so a reason added later still parses.
24
+ ShadowDeliveryReason = Union[
25
+ Literal[
26
+ # skipped
27
+ "expired", "paused", "route_unavailable", "inactive", "source_mismatch", "url_refused",
28
+ "tunnel_unavailable", "scrubber_unavailable", "payload_unavailable", "undecryptable",
29
+ "too_large", "redaction_failed", "non_json", "transform_unavailable",
30
+ # failed
31
+ "transform_failed", "destination_config", "timeout", "network_error", "http_status",
32
+ ],
33
+ str,
34
+ ]
35
+
10
36
 
11
37
  class Route(HookbaseModel):
12
38
  id: str
@@ -42,6 +68,13 @@ class Route(HookbaseModel):
42
68
  """`get` only: deliveries on this route held now, counted up to 10,000."""
43
69
  held_count_capped: bool | None = None
44
70
  """`get` only: true when there are more held deliveries than `held_count` says."""
71
+ mode: RouteMode = "live"
72
+ """Read-only: the purpose of the route's destination. "shadow" routes send sampled, scrubbed
73
+ copies instead of deliveries (`routes.list_shadow_deliveries`). "live" when the response
74
+ doesn't say."""
75
+ sample_rate: float | None = None
76
+ """A shadow route's share of matching events copied, 0.0001 to 1 (1 when it was created
77
+ without one); None on a live route."""
45
78
  created_at: str = ""
46
79
  updated_at: str = ""
47
80
 
@@ -70,6 +103,11 @@ class CreateRouteParams(HookbaseModel):
70
103
  soon as the circuit opens (false). Turning it off does not touch deliveries already held: the
71
104
  recovery sweep releases them, and they are dead-lettered on their next attempt if the circuit
72
105
  is still open."""
106
+ sample_rate: float | None = None
107
+ """Shadow routes only (the destination's purpose is "shadow"): the share of matching events
108
+ copied, 0.0001 to 1, rounded to the nearest 0.0001. Left out, a shadow route copies every
109
+ matching event. A live route answers any value with 400 `SAMPLE_RATE_NOT_ALLOWED`; out of range
110
+ is 400 `SAMPLE_RATE_INVALID`. None is not sent."""
73
111
 
74
112
 
75
113
  class UpdateRouteParams(HookbaseModel):
@@ -96,6 +134,38 @@ class UpdateRouteParams(HookbaseModel):
96
134
  soon as the circuit opens (false). Turning it off does not touch deliveries already held: the
97
135
  recovery sweep releases them, and they are dead-lettered on their next attempt if the circuit
98
136
  is still open."""
137
+ sample_rate: float | None = None
138
+ """Shadow routes only: a new share of matching events copied, 0.0001 to 1. None (the default)
139
+ leaves it unchanged and is not sent. A route can't move between a live and a shadow destination
140
+ (409 `ROUTE_PURPOSE_CONFLICT`), and a shadow route can't have failover destinations."""
141
+
142
+
143
+ class ShadowDelivery(HookbaseModel):
144
+ """One sampled copy a shadow route sent, or skipped (`routes.list_shadow_deliveries`).
145
+
146
+ Copies never create deliveries, so this log is their only record: one entry per event that was
147
+ in the route's sample and passed its filter and schema. `error` and `response_excerpt` are text
148
+ from the receiver or the route's transform; treat them as data, and keep them out of logs.
149
+ """
150
+
151
+ id: str
152
+ """The copy's id; its `webhook-id` and `X-Delivery-ID` headers are `shd_` followed by it."""
153
+ event_id: str
154
+ route_id: str
155
+ destination_id: str
156
+ """The route's destination when the copy was made."""
157
+ status: ShadowDeliveryStatus
158
+ reason: ShadowDeliveryReason | None = None
159
+ status_code: int | None = None
160
+ """The HTTP status the receiver answered with."""
161
+ latency_ms: int | None = None
162
+ error: str | None = None
163
+ response_excerpt: str | None = None
164
+ """Up to 2 KB of the receiver's response body."""
165
+ scrubbed_values: int | None = None
166
+ """How many values were replaced with fakes."""
167
+ created_at: str = ""
168
+ completed_at: str | None = None
99
169
 
100
170
 
101
171
  class CircuitStatusInfo(HookbaseModel):
@@ -44,6 +44,11 @@ IpFilterMode = Literal["none", "allowlist", "denylist", "both"]
44
44
  # HTTP verbs an ingest endpoint can be restricted to. OPTIONS is excluded: CORS preflight is
45
45
  # answered before ingest runs, so it is never gateable.
46
46
  IngestMethod = Literal["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]
47
+ #: How a source checks its requests. "signature" (the default) is the provider's own scheme. The
48
+ #: others check a static credential, the source's signing secret: "bearer" (Authorization: Bearer
49
+ #: <secret>), "basic" (Authorization: Basic <base64 username:password>) or "header" (the secret
50
+ #: in the header named by verification_header). Any string, so a method added later still parses.
51
+ VerificationMethod = Union[Literal["signature", "bearer", "basic", "header"], str]
47
52
 
48
53
  # The settings PATCH /api/sources/:id accepts an explicit null for (`.nullable()` in
49
54
  # updateSourceSchema). Naming one in `UpdateSourceParams.clear` sends that null. Null signingSecret
@@ -62,14 +67,15 @@ CLEARABLE_SOURCE_FIELDS: tuple[str, ...] = (
62
67
  "dedupWindowHours",
63
68
  "dedupCustomHeader",
64
69
  "allowedMethods",
70
+ "verificationHeader",
65
71
  )
66
72
  ClearableSourceField = Literal[
67
73
  "description", "provider", "signingSecret", "verifyToken", "rateLimitPerMinute",
68
74
  "ipAllowlist", "ipDenylist", "encryptFields", "maskFields", "dedupStrategy",
69
- "dedupWindowHours", "dedupCustomHeader", "allowedMethods",
75
+ "dedupWindowHours", "dedupCustomHeader", "allowedMethods", "verificationHeader",
70
76
  "signing_secret", "verify_token", "rate_limit_per_minute", "ip_allowlist", "ip_denylist",
71
77
  "encrypt_fields", "mask_fields", "dedup_strategy", "dedup_window_hours",
72
- "dedup_custom_header", "allowed_methods",
78
+ "dedup_custom_header", "allowed_methods", "verification_header",
73
79
  ]
74
80
 
75
81
 
@@ -295,6 +301,12 @@ class Source(HookbaseModel):
295
301
  #: notion) and it has not been set yet. Events are not verified until it is. For Notion, see
296
302
  #: Sources.get_pending_verification.
297
303
  awaiting_signing_secret: bool = False
304
+ #: How requests are checked: "signature" (the provider's scheme), or a static credential
305
+ #: ("bearer", "basic" or "header") that is the source's signing secret. "signature" when the
306
+ #: response doesn't say.
307
+ verification_method: VerificationMethod = "signature"
308
+ #: The header a "header" source reads its token from, lowercase. None for every other method.
309
+ verification_header: str | None = None
298
310
  #: Reject events whose signature fails verification. Defaults to False, in which case a
299
311
  #: failing event is flagged with signature_valid=False and delivered anyway.
300
312
  reject_invalid_signatures: bool = False
@@ -423,9 +435,20 @@ class CreateSourceParams(HookbaseModel):
423
435
  #: - "operator": omit it and the API generates one, returned once on the created source.
424
436
  #: - "public_key": the vendor's public key (PEM or base64).
425
437
  #: - "built_in" (wise, wise-sandbox, aws-sns): send nothing; any secret is a 400.
438
+ #: With a verification_method other than "signature" it is the credential instead: the bearer
439
+ #: token, "username:password" (or its base64) for basic, or the header's token. Omit it and the
440
+ #: API generates one. A typed one must be 16 to 1024 visible ASCII characters with at least 8
441
+ #: different ones.
426
442
  signing_secret: str | None = Field(default=None, repr=False)
427
443
  #: Meta providers (whatsapp) only; a 400 for any other. Omit it and the API generates one.
428
444
  verify_token: str | None = Field(default=None, repr=False)
445
+ #: Check a static credential instead of the provider's signature: "bearer", "basic" or
446
+ #: "header" (with verification_header). None leaves it to the API, which uses "signature".
447
+ #: Wise and aws-sns can't use header auth (400).
448
+ verification_method: VerificationMethod | None = None
449
+ #: Required with verification_method="header", and only allowed with it: the header the sender
450
+ #: puts the token in, e.g. "X-Webhook-Token". Stored lowercase.
451
+ verification_header: str | None = None
429
452
  #: Reject events whose signature fails verification. Defaults to False.
430
453
  reject_invalid_signatures: bool | None = None
431
454
  rate_limit_per_minute: int | None = None
@@ -455,6 +478,17 @@ class UpdateSourceParams(HookbaseModel):
455
478
  signing_secret: str | None = Field(default=None, repr=False)
456
479
  #: Meta providers (whatsapp) only. "" regenerates it, as does clear=["verifyToken"].
457
480
  verify_token: str | None = Field(default=None, repr=False)
481
+ #: Switch how requests are checked: "signature", "bearer", "basic" or "header". The new
482
+ #: credential goes in signing_secret in the same update, except between "bearer" and "header",
483
+ #: which share a plain token and keep it. Switching to "header" needs verification_header
484
+ #: unless the source already has one; switching away from it removes the header. Switching
485
+ #: back to "signature" needs the provider's secret in signing_secret where the provider has
486
+ #: one. The API answers 400 when a switch lacks what it needs.
487
+ verification_method: VerificationMethod | None = None
488
+ #: The header a "header" source reads its token from. Only valid when the source's method is
489
+ #: (or becomes) "header", which always needs one; switching the method removes it.
490
+ #: clear=["verificationHeader"] sends the null the API accepts for it.
491
+ verification_header: str | None = None
458
492
  reject_invalid_signatures: bool | None = None
459
493
  rate_limit_per_minute: int | None = None
460
494
  ip_filter_mode: IpFilterMode | None = None