airweave-sdk 0.8.64__py3-none-any.whl → 0.8.66__py3-none-any.whl

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 (46) hide show
  1. airweave/__init__.py +44 -38
  2. airweave/client.py +19 -16
  3. airweave/collections/__init__.py +3 -6
  4. airweave/collections/client.py +273 -113
  5. airweave/collections/raw_client.py +633 -94
  6. airweave/collections/types/__init__.py +2 -4
  7. airweave/core/client_wrapper.py +4 -30
  8. airweave/errors/__init__.py +10 -2
  9. airweave/errors/conflict_error.py +11 -0
  10. airweave/errors/not_found_error.py +11 -0
  11. airweave/errors/too_many_requests_error.py +11 -0
  12. airweave/errors/unprocessable_entity_error.py +1 -2
  13. airweave/{types/message_status.py → events/__init__.py} +2 -1
  14. airweave/events/client.py +919 -0
  15. airweave/events/raw_client.py +1435 -0
  16. airweave/source_connections/client.py +210 -162
  17. airweave/source_connections/raw_client.py +574 -137
  18. airweave/sources/client.py +42 -18
  19. airweave/sources/raw_client.py +118 -17
  20. airweave/types/__init__.py +33 -33
  21. airweave/types/{create_subscription_request.py → conflict_error_response.py} +9 -6
  22. airweave/types/delivery_attempt.py +61 -0
  23. airweave/types/event_message.py +55 -0
  24. airweave/types/event_message_with_attempts.py +59 -0
  25. airweave/types/{endpoint_secret_out.py → not_found_error_response.py} +9 -2
  26. airweave/types/{subscription_with_attempts_out.py → rate_limit_error_response.py} +9 -6
  27. airweave/types/recovery_task.py +35 -0
  28. airweave/types/search_request.py +13 -10
  29. airweave/types/search_response.py +6 -3
  30. airweave/types/source_connection.py +73 -18
  31. airweave/types/source_connection_job.py +65 -15
  32. airweave/types/source_connection_list_item.py +45 -10
  33. airweave/types/sync_event_payload.py +72 -0
  34. airweave/types/{patch_subscription_request.py → validation_error_detail.py} +16 -5
  35. airweave/types/validation_error_response.py +30 -0
  36. airweave/types/webhook_subscription.py +68 -0
  37. {airweave_sdk-0.8.64.dist-info → airweave_sdk-0.8.66.dist-info}/METADATA +1 -5
  38. {airweave_sdk-0.8.64.dist-info → airweave_sdk-0.8.66.dist-info}/RECORD +39 -34
  39. airweave/collections/types/search_collections_readable_id_search_post_response.py +0 -8
  40. airweave/types/collection_update.py +0 -35
  41. airweave/types/endpoint_out.py +0 -35
  42. airweave/types/message_attempt_out.py +0 -37
  43. airweave/types/message_attempt_trigger_type.py +0 -3
  44. airweave/types/message_out.py +0 -29
  45. airweave/types/message_status_text.py +0 -5
  46. {airweave_sdk-0.8.64.dist-info → airweave_sdk-0.8.66.dist-info}/WHEEL +0 -0
@@ -0,0 +1,919 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
+ from ..core.request_options import RequestOptions
8
+ from ..types.event_message import EventMessage
9
+ from ..types.event_message_with_attempts import EventMessageWithAttempts
10
+ from ..types.event_type import EventType
11
+ from ..types.recovery_task import RecoveryTask
12
+ from ..types.webhook_subscription import WebhookSubscription
13
+ from .raw_client import AsyncRawEventsClient, RawEventsClient
14
+
15
+ # this is used as the default value for optional parameters
16
+ OMIT = typing.cast(typing.Any, ...)
17
+
18
+
19
+ class EventsClient:
20
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
21
+ self._raw_client = RawEventsClient(client_wrapper=client_wrapper)
22
+
23
+ @property
24
+ def with_raw_response(self) -> RawEventsClient:
25
+ """
26
+ Retrieves a raw implementation of this client that returns raw responses.
27
+
28
+ Returns
29
+ -------
30
+ RawEventsClient
31
+ """
32
+ return self._raw_client
33
+
34
+ def get_messages(
35
+ self,
36
+ *,
37
+ event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ) -> typing.List[EventMessage]:
40
+ """
41
+ Retrieve all event messages for your organization.
42
+
43
+ Event messages represent webhook payloads that were sent (or attempted to be sent)
44
+ to your subscribed endpoints. Each message contains the event type, payload data,
45
+ and delivery status information.
46
+
47
+ Use the `event_types` query parameter to filter messages by specific event types,
48
+ such as `sync.completed` or `sync.failed`.
49
+
50
+ Parameters
51
+ ----------
52
+ event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
53
+ Filter messages by event type(s). Accepts multiple values, e.g., `?event_types=sync.completed&event_types=sync.failed`.
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ typing.List[EventMessage]
61
+ List of event messages
62
+
63
+ Examples
64
+ --------
65
+ from airweave import AirweaveSDK
66
+
67
+ client = AirweaveSDK(
68
+ api_key="YOUR_API_KEY",
69
+ )
70
+ client.events.get_messages()
71
+ """
72
+ _response = self._raw_client.get_messages(event_types=event_types, request_options=request_options)
73
+ return _response.data
74
+
75
+ def get_message(
76
+ self,
77
+ message_id: str,
78
+ *,
79
+ include_attempts: typing.Optional[bool] = None,
80
+ request_options: typing.Optional[RequestOptions] = None,
81
+ ) -> EventMessageWithAttempts:
82
+ """
83
+ Retrieve a specific event message by its ID.
84
+
85
+ Returns the full message details including the event type, payload data,
86
+ timestamp, and delivery channel information. Use this to inspect the
87
+ exact payload that was sent to your webhook endpoints.
88
+
89
+ Use `include_attempts=true` to also retrieve delivery attempts for this message,
90
+ which include HTTP response codes, response bodies, and timestamps for debugging
91
+ delivery failures.
92
+
93
+ Parameters
94
+ ----------
95
+ message_id : str
96
+ The unique identifier of the message to retrieve (UUID).
97
+
98
+ include_attempts : typing.Optional[bool]
99
+ Include delivery attempts for this message. Each attempt includes the HTTP response code, response body, and timestamp.
100
+
101
+ request_options : typing.Optional[RequestOptions]
102
+ Request-specific configuration.
103
+
104
+ Returns
105
+ -------
106
+ EventMessageWithAttempts
107
+ Event message details
108
+
109
+ Examples
110
+ --------
111
+ from airweave import AirweaveSDK
112
+
113
+ client = AirweaveSDK(
114
+ api_key="YOUR_API_KEY",
115
+ )
116
+ client.events.get_message(
117
+ message_id="550e8400-e29b-41d4-a716-446655440000",
118
+ include_attempts=True,
119
+ )
120
+ """
121
+ _response = self._raw_client.get_message(
122
+ message_id, include_attempts=include_attempts, request_options=request_options
123
+ )
124
+ return _response.data
125
+
126
+ def get_subscriptions(
127
+ self, *, request_options: typing.Optional[RequestOptions] = None
128
+ ) -> typing.List[WebhookSubscription]:
129
+ """
130
+ List all webhook subscriptions for your organization.
131
+
132
+ Returns all configured webhook endpoints, including their URLs, subscribed
133
+ event types, and current status (enabled/disabled). Use this to audit
134
+ your webhook configuration or find a specific subscription.
135
+
136
+ Parameters
137
+ ----------
138
+ request_options : typing.Optional[RequestOptions]
139
+ Request-specific configuration.
140
+
141
+ Returns
142
+ -------
143
+ typing.List[WebhookSubscription]
144
+ List of webhook subscriptions
145
+
146
+ Examples
147
+ --------
148
+ from airweave import AirweaveSDK
149
+
150
+ client = AirweaveSDK(
151
+ api_key="YOUR_API_KEY",
152
+ )
153
+ client.events.get_subscriptions()
154
+ """
155
+ _response = self._raw_client.get_subscriptions(request_options=request_options)
156
+ return _response.data
157
+
158
+ def create_subscription(
159
+ self,
160
+ *,
161
+ url: str,
162
+ event_types: typing.Sequence[EventType],
163
+ secret: typing.Optional[str] = OMIT,
164
+ request_options: typing.Optional[RequestOptions] = None,
165
+ ) -> WebhookSubscription:
166
+ """
167
+ Create a new webhook subscription.
168
+
169
+ Webhook subscriptions allow you to receive real-time notifications when events
170
+ occur in Airweave. When you create a subscription, you specify:
171
+
172
+ - **URL**: The HTTPS endpoint where events will be delivered
173
+ - **Event Types**: Which events you want to receive (e.g., `sync.completed`, `sync.failed`)
174
+ - **Secret** (optional): A custom signing secret for verifying webhook signatures
175
+
176
+ After creation, Airweave will send HTTP POST requests to your URL whenever
177
+ matching events occur. Each request includes a signature header for verification.
178
+
179
+ Parameters
180
+ ----------
181
+ url : str
182
+ The HTTPS URL where webhook events will be delivered. Must be a publicly accessible endpoint that returns a 2xx status code.
183
+
184
+ event_types : typing.Sequence[EventType]
185
+ List of event types to subscribe to. Events not in this list will not be delivered to this subscription. Available types: `sync.pending`, `sync.running`, `sync.completed`, `sync.failed`, `sync.cancelled`.
186
+
187
+ secret : typing.Optional[str]
188
+ Optional custom signing secret for webhook signature verification. If not provided, a secure secret will be auto-generated. Must be at least 24 characters if specified.
189
+
190
+ request_options : typing.Optional[RequestOptions]
191
+ Request-specific configuration.
192
+
193
+ Returns
194
+ -------
195
+ WebhookSubscription
196
+ Created subscription
197
+
198
+ Examples
199
+ --------
200
+ from airweave import AirweaveSDK
201
+
202
+ client = AirweaveSDK(
203
+ api_key="YOUR_API_KEY",
204
+ )
205
+ client.events.create_subscription(
206
+ url="https://api.mycompany.com/webhooks/airweave",
207
+ event_types=["sync.completed", "sync.failed"],
208
+ )
209
+ """
210
+ _response = self._raw_client.create_subscription(
211
+ url=url, event_types=event_types, secret=secret, request_options=request_options
212
+ )
213
+ return _response.data
214
+
215
+ def get_subscription(
216
+ self,
217
+ subscription_id: str,
218
+ *,
219
+ include_secret: typing.Optional[bool] = None,
220
+ request_options: typing.Optional[RequestOptions] = None,
221
+ ) -> WebhookSubscription:
222
+ """
223
+ Retrieve a specific webhook subscription with its recent delivery attempts.
224
+
225
+ Returns the subscription configuration along with a history of message delivery
226
+ attempts. This is useful for debugging delivery issues or verifying that your
227
+ endpoint is correctly receiving events.
228
+
229
+ Use `include_secret=true` to also retrieve the signing secret for webhook
230
+ signature verification. Keep this secret secure.
231
+
232
+ Parameters
233
+ ----------
234
+ subscription_id : str
235
+ The unique identifier of the subscription to retrieve (UUID).
236
+
237
+ include_secret : typing.Optional[bool]
238
+ Include the signing secret for webhook signature verification. Keep this secret secure and use it to verify the 'svix-signature' header.
239
+
240
+ request_options : typing.Optional[RequestOptions]
241
+ Request-specific configuration.
242
+
243
+ Returns
244
+ -------
245
+ WebhookSubscription
246
+ Subscription with delivery attempts
247
+
248
+ Examples
249
+ --------
250
+ from airweave import AirweaveSDK
251
+
252
+ client = AirweaveSDK(
253
+ api_key="YOUR_API_KEY",
254
+ )
255
+ client.events.get_subscription(
256
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
257
+ include_secret=True,
258
+ )
259
+ """
260
+ _response = self._raw_client.get_subscription(
261
+ subscription_id, include_secret=include_secret, request_options=request_options
262
+ )
263
+ return _response.data
264
+
265
+ def delete_subscription(
266
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
267
+ ) -> WebhookSubscription:
268
+ """
269
+ Permanently delete a webhook subscription.
270
+
271
+ Once deleted, Airweave will stop sending events to this endpoint immediately.
272
+ This action cannot be undone. Any pending message deliveries will be cancelled.
273
+
274
+ If you want to temporarily stop receiving events, consider disabling the
275
+ subscription instead using the PATCH endpoint.
276
+
277
+ Parameters
278
+ ----------
279
+ subscription_id : str
280
+ The unique identifier of the subscription to delete (UUID).
281
+
282
+ request_options : typing.Optional[RequestOptions]
283
+ Request-specific configuration.
284
+
285
+ Returns
286
+ -------
287
+ WebhookSubscription
288
+ Deleted subscription
289
+
290
+ Examples
291
+ --------
292
+ from airweave import AirweaveSDK
293
+
294
+ client = AirweaveSDK(
295
+ api_key="YOUR_API_KEY",
296
+ )
297
+ client.events.delete_subscription(
298
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
299
+ )
300
+ """
301
+ _response = self._raw_client.delete_subscription(subscription_id, request_options=request_options)
302
+ return _response.data
303
+
304
+ def patch_subscription(
305
+ self,
306
+ subscription_id: str,
307
+ *,
308
+ url: typing.Optional[str] = OMIT,
309
+ event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
310
+ disabled: typing.Optional[bool] = OMIT,
311
+ recover_since: typing.Optional[dt.datetime] = OMIT,
312
+ request_options: typing.Optional[RequestOptions] = None,
313
+ ) -> WebhookSubscription:
314
+ """
315
+ Update an existing webhook subscription.
316
+
317
+ Use this endpoint to modify a subscription's configuration. You can:
318
+
319
+ - **Change the URL**: Update where events are delivered
320
+ - **Update event types**: Modify which events trigger notifications
321
+ - **Enable/disable**: Temporarily pause delivery without deleting the subscription
322
+ - **Recover messages**: When re-enabling, optionally recover missed messages
323
+
324
+ Only include the fields you want to change. Omitted fields will retain their
325
+ current values.
326
+
327
+ When re-enabling a subscription (`disabled: false`), you can optionally provide
328
+ `recover_since` to automatically retry all messages that were generated while
329
+ the subscription was disabled.
330
+
331
+ Parameters
332
+ ----------
333
+ subscription_id : str
334
+ The unique identifier of the subscription to update (UUID).
335
+
336
+ url : typing.Optional[str]
337
+ New URL for webhook delivery. Must be a publicly accessible HTTPS endpoint.
338
+
339
+ event_types : typing.Optional[typing.Sequence[EventType]]
340
+ New list of event types to subscribe to. This replaces the existing list entirely.
341
+
342
+ disabled : typing.Optional[bool]
343
+ Set to `true` to pause delivery to this subscription, or `false` to resume. Disabled subscriptions will not receive events.
344
+
345
+ recover_since : typing.Optional[dt.datetime]
346
+ When re-enabling a subscription (`disabled: false`), optionally recover failed messages from this timestamp. Only applies when enabling.
347
+
348
+ request_options : typing.Optional[RequestOptions]
349
+ Request-specific configuration.
350
+
351
+ Returns
352
+ -------
353
+ WebhookSubscription
354
+ Updated subscription
355
+
356
+ Examples
357
+ --------
358
+ from airweave import AirweaveSDK
359
+
360
+ client = AirweaveSDK(
361
+ api_key="YOUR_API_KEY",
362
+ )
363
+ client.events.patch_subscription(
364
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
365
+ )
366
+ """
367
+ _response = self._raw_client.patch_subscription(
368
+ subscription_id,
369
+ url=url,
370
+ event_types=event_types,
371
+ disabled=disabled,
372
+ recover_since=recover_since,
373
+ request_options=request_options,
374
+ )
375
+ return _response.data
376
+
377
+ def recover_failed_messages(
378
+ self,
379
+ subscription_id: str,
380
+ *,
381
+ since: dt.datetime,
382
+ until: typing.Optional[dt.datetime] = OMIT,
383
+ request_options: typing.Optional[RequestOptions] = None,
384
+ ) -> RecoveryTask:
385
+ """
386
+ Retry failed message deliveries for a webhook subscription.
387
+
388
+ Triggers a recovery process that replays all failed messages within the
389
+ specified time window. This is useful when:
390
+
391
+ - Your endpoint was temporarily down and you want to catch up
392
+ - You've fixed a bug in your webhook handler
393
+ - You want to reprocess events after re-enabling a disabled subscription
394
+
395
+ Messages are retried in chronological order. Successfully delivered messages
396
+ are skipped; only failed or pending messages are retried.
397
+
398
+ Parameters
399
+ ----------
400
+ subscription_id : str
401
+ The unique identifier of the subscription to recover messages for (UUID).
402
+
403
+ since : dt.datetime
404
+ Start of the recovery time window (inclusive). All failed messages from this time onward will be retried.
405
+
406
+ until : typing.Optional[dt.datetime]
407
+ End of the recovery time window (exclusive). If not specified, recovers all failed messages up to now.
408
+
409
+ request_options : typing.Optional[RequestOptions]
410
+ Request-specific configuration.
411
+
412
+ Returns
413
+ -------
414
+ RecoveryTask
415
+ Recovery task information
416
+
417
+ Examples
418
+ --------
419
+ import datetime
420
+
421
+ from airweave import AirweaveSDK
422
+
423
+ client = AirweaveSDK(
424
+ api_key="YOUR_API_KEY",
425
+ )
426
+ client.events.recover_failed_messages(
427
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
428
+ since=datetime.datetime.fromisoformat(
429
+ "2024-03-14 00:00:00+00:00",
430
+ ),
431
+ )
432
+ """
433
+ _response = self._raw_client.recover_failed_messages(
434
+ subscription_id, since=since, until=until, request_options=request_options
435
+ )
436
+ return _response.data
437
+
438
+
439
+ class AsyncEventsClient:
440
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
441
+ self._raw_client = AsyncRawEventsClient(client_wrapper=client_wrapper)
442
+
443
+ @property
444
+ def with_raw_response(self) -> AsyncRawEventsClient:
445
+ """
446
+ Retrieves a raw implementation of this client that returns raw responses.
447
+
448
+ Returns
449
+ -------
450
+ AsyncRawEventsClient
451
+ """
452
+ return self._raw_client
453
+
454
+ async def get_messages(
455
+ self,
456
+ *,
457
+ event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
458
+ request_options: typing.Optional[RequestOptions] = None,
459
+ ) -> typing.List[EventMessage]:
460
+ """
461
+ Retrieve all event messages for your organization.
462
+
463
+ Event messages represent webhook payloads that were sent (or attempted to be sent)
464
+ to your subscribed endpoints. Each message contains the event type, payload data,
465
+ and delivery status information.
466
+
467
+ Use the `event_types` query parameter to filter messages by specific event types,
468
+ such as `sync.completed` or `sync.failed`.
469
+
470
+ Parameters
471
+ ----------
472
+ event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
473
+ Filter messages by event type(s). Accepts multiple values, e.g., `?event_types=sync.completed&event_types=sync.failed`.
474
+
475
+ request_options : typing.Optional[RequestOptions]
476
+ Request-specific configuration.
477
+
478
+ Returns
479
+ -------
480
+ typing.List[EventMessage]
481
+ List of event messages
482
+
483
+ Examples
484
+ --------
485
+ import asyncio
486
+
487
+ from airweave import AsyncAirweaveSDK
488
+
489
+ client = AsyncAirweaveSDK(
490
+ api_key="YOUR_API_KEY",
491
+ )
492
+
493
+
494
+ async def main() -> None:
495
+ await client.events.get_messages()
496
+
497
+
498
+ asyncio.run(main())
499
+ """
500
+ _response = await self._raw_client.get_messages(event_types=event_types, request_options=request_options)
501
+ return _response.data
502
+
503
+ async def get_message(
504
+ self,
505
+ message_id: str,
506
+ *,
507
+ include_attempts: typing.Optional[bool] = None,
508
+ request_options: typing.Optional[RequestOptions] = None,
509
+ ) -> EventMessageWithAttempts:
510
+ """
511
+ Retrieve a specific event message by its ID.
512
+
513
+ Returns the full message details including the event type, payload data,
514
+ timestamp, and delivery channel information. Use this to inspect the
515
+ exact payload that was sent to your webhook endpoints.
516
+
517
+ Use `include_attempts=true` to also retrieve delivery attempts for this message,
518
+ which include HTTP response codes, response bodies, and timestamps for debugging
519
+ delivery failures.
520
+
521
+ Parameters
522
+ ----------
523
+ message_id : str
524
+ The unique identifier of the message to retrieve (UUID).
525
+
526
+ include_attempts : typing.Optional[bool]
527
+ Include delivery attempts for this message. Each attempt includes the HTTP response code, response body, and timestamp.
528
+
529
+ request_options : typing.Optional[RequestOptions]
530
+ Request-specific configuration.
531
+
532
+ Returns
533
+ -------
534
+ EventMessageWithAttempts
535
+ Event message details
536
+
537
+ Examples
538
+ --------
539
+ import asyncio
540
+
541
+ from airweave import AsyncAirweaveSDK
542
+
543
+ client = AsyncAirweaveSDK(
544
+ api_key="YOUR_API_KEY",
545
+ )
546
+
547
+
548
+ async def main() -> None:
549
+ await client.events.get_message(
550
+ message_id="550e8400-e29b-41d4-a716-446655440000",
551
+ include_attempts=True,
552
+ )
553
+
554
+
555
+ asyncio.run(main())
556
+ """
557
+ _response = await self._raw_client.get_message(
558
+ message_id, include_attempts=include_attempts, request_options=request_options
559
+ )
560
+ return _response.data
561
+
562
+ async def get_subscriptions(
563
+ self, *, request_options: typing.Optional[RequestOptions] = None
564
+ ) -> typing.List[WebhookSubscription]:
565
+ """
566
+ List all webhook subscriptions for your organization.
567
+
568
+ Returns all configured webhook endpoints, including their URLs, subscribed
569
+ event types, and current status (enabled/disabled). Use this to audit
570
+ your webhook configuration or find a specific subscription.
571
+
572
+ Parameters
573
+ ----------
574
+ request_options : typing.Optional[RequestOptions]
575
+ Request-specific configuration.
576
+
577
+ Returns
578
+ -------
579
+ typing.List[WebhookSubscription]
580
+ List of webhook subscriptions
581
+
582
+ Examples
583
+ --------
584
+ import asyncio
585
+
586
+ from airweave import AsyncAirweaveSDK
587
+
588
+ client = AsyncAirweaveSDK(
589
+ api_key="YOUR_API_KEY",
590
+ )
591
+
592
+
593
+ async def main() -> None:
594
+ await client.events.get_subscriptions()
595
+
596
+
597
+ asyncio.run(main())
598
+ """
599
+ _response = await self._raw_client.get_subscriptions(request_options=request_options)
600
+ return _response.data
601
+
602
+ async def create_subscription(
603
+ self,
604
+ *,
605
+ url: str,
606
+ event_types: typing.Sequence[EventType],
607
+ secret: typing.Optional[str] = OMIT,
608
+ request_options: typing.Optional[RequestOptions] = None,
609
+ ) -> WebhookSubscription:
610
+ """
611
+ Create a new webhook subscription.
612
+
613
+ Webhook subscriptions allow you to receive real-time notifications when events
614
+ occur in Airweave. When you create a subscription, you specify:
615
+
616
+ - **URL**: The HTTPS endpoint where events will be delivered
617
+ - **Event Types**: Which events you want to receive (e.g., `sync.completed`, `sync.failed`)
618
+ - **Secret** (optional): A custom signing secret for verifying webhook signatures
619
+
620
+ After creation, Airweave will send HTTP POST requests to your URL whenever
621
+ matching events occur. Each request includes a signature header for verification.
622
+
623
+ Parameters
624
+ ----------
625
+ url : str
626
+ The HTTPS URL where webhook events will be delivered. Must be a publicly accessible endpoint that returns a 2xx status code.
627
+
628
+ event_types : typing.Sequence[EventType]
629
+ List of event types to subscribe to. Events not in this list will not be delivered to this subscription. Available types: `sync.pending`, `sync.running`, `sync.completed`, `sync.failed`, `sync.cancelled`.
630
+
631
+ secret : typing.Optional[str]
632
+ Optional custom signing secret for webhook signature verification. If not provided, a secure secret will be auto-generated. Must be at least 24 characters if specified.
633
+
634
+ request_options : typing.Optional[RequestOptions]
635
+ Request-specific configuration.
636
+
637
+ Returns
638
+ -------
639
+ WebhookSubscription
640
+ Created subscription
641
+
642
+ Examples
643
+ --------
644
+ import asyncio
645
+
646
+ from airweave import AsyncAirweaveSDK
647
+
648
+ client = AsyncAirweaveSDK(
649
+ api_key="YOUR_API_KEY",
650
+ )
651
+
652
+
653
+ async def main() -> None:
654
+ await client.events.create_subscription(
655
+ url="https://api.mycompany.com/webhooks/airweave",
656
+ event_types=["sync.completed", "sync.failed"],
657
+ )
658
+
659
+
660
+ asyncio.run(main())
661
+ """
662
+ _response = await self._raw_client.create_subscription(
663
+ url=url, event_types=event_types, secret=secret, request_options=request_options
664
+ )
665
+ return _response.data
666
+
667
+ async def get_subscription(
668
+ self,
669
+ subscription_id: str,
670
+ *,
671
+ include_secret: typing.Optional[bool] = None,
672
+ request_options: typing.Optional[RequestOptions] = None,
673
+ ) -> WebhookSubscription:
674
+ """
675
+ Retrieve a specific webhook subscription with its recent delivery attempts.
676
+
677
+ Returns the subscription configuration along with a history of message delivery
678
+ attempts. This is useful for debugging delivery issues or verifying that your
679
+ endpoint is correctly receiving events.
680
+
681
+ Use `include_secret=true` to also retrieve the signing secret for webhook
682
+ signature verification. Keep this secret secure.
683
+
684
+ Parameters
685
+ ----------
686
+ subscription_id : str
687
+ The unique identifier of the subscription to retrieve (UUID).
688
+
689
+ include_secret : typing.Optional[bool]
690
+ Include the signing secret for webhook signature verification. Keep this secret secure and use it to verify the 'svix-signature' header.
691
+
692
+ request_options : typing.Optional[RequestOptions]
693
+ Request-specific configuration.
694
+
695
+ Returns
696
+ -------
697
+ WebhookSubscription
698
+ Subscription with delivery attempts
699
+
700
+ Examples
701
+ --------
702
+ import asyncio
703
+
704
+ from airweave import AsyncAirweaveSDK
705
+
706
+ client = AsyncAirweaveSDK(
707
+ api_key="YOUR_API_KEY",
708
+ )
709
+
710
+
711
+ async def main() -> None:
712
+ await client.events.get_subscription(
713
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
714
+ include_secret=True,
715
+ )
716
+
717
+
718
+ asyncio.run(main())
719
+ """
720
+ _response = await self._raw_client.get_subscription(
721
+ subscription_id, include_secret=include_secret, request_options=request_options
722
+ )
723
+ return _response.data
724
+
725
+ async def delete_subscription(
726
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
727
+ ) -> WebhookSubscription:
728
+ """
729
+ Permanently delete a webhook subscription.
730
+
731
+ Once deleted, Airweave will stop sending events to this endpoint immediately.
732
+ This action cannot be undone. Any pending message deliveries will be cancelled.
733
+
734
+ If you want to temporarily stop receiving events, consider disabling the
735
+ subscription instead using the PATCH endpoint.
736
+
737
+ Parameters
738
+ ----------
739
+ subscription_id : str
740
+ The unique identifier of the subscription to delete (UUID).
741
+
742
+ request_options : typing.Optional[RequestOptions]
743
+ Request-specific configuration.
744
+
745
+ Returns
746
+ -------
747
+ WebhookSubscription
748
+ Deleted subscription
749
+
750
+ Examples
751
+ --------
752
+ import asyncio
753
+
754
+ from airweave import AsyncAirweaveSDK
755
+
756
+ client = AsyncAirweaveSDK(
757
+ api_key="YOUR_API_KEY",
758
+ )
759
+
760
+
761
+ async def main() -> None:
762
+ await client.events.delete_subscription(
763
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
764
+ )
765
+
766
+
767
+ asyncio.run(main())
768
+ """
769
+ _response = await self._raw_client.delete_subscription(subscription_id, request_options=request_options)
770
+ return _response.data
771
+
772
+ async def patch_subscription(
773
+ self,
774
+ subscription_id: str,
775
+ *,
776
+ url: typing.Optional[str] = OMIT,
777
+ event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
778
+ disabled: typing.Optional[bool] = OMIT,
779
+ recover_since: typing.Optional[dt.datetime] = OMIT,
780
+ request_options: typing.Optional[RequestOptions] = None,
781
+ ) -> WebhookSubscription:
782
+ """
783
+ Update an existing webhook subscription.
784
+
785
+ Use this endpoint to modify a subscription's configuration. You can:
786
+
787
+ - **Change the URL**: Update where events are delivered
788
+ - **Update event types**: Modify which events trigger notifications
789
+ - **Enable/disable**: Temporarily pause delivery without deleting the subscription
790
+ - **Recover messages**: When re-enabling, optionally recover missed messages
791
+
792
+ Only include the fields you want to change. Omitted fields will retain their
793
+ current values.
794
+
795
+ When re-enabling a subscription (`disabled: false`), you can optionally provide
796
+ `recover_since` to automatically retry all messages that were generated while
797
+ the subscription was disabled.
798
+
799
+ Parameters
800
+ ----------
801
+ subscription_id : str
802
+ The unique identifier of the subscription to update (UUID).
803
+
804
+ url : typing.Optional[str]
805
+ New URL for webhook delivery. Must be a publicly accessible HTTPS endpoint.
806
+
807
+ event_types : typing.Optional[typing.Sequence[EventType]]
808
+ New list of event types to subscribe to. This replaces the existing list entirely.
809
+
810
+ disabled : typing.Optional[bool]
811
+ Set to `true` to pause delivery to this subscription, or `false` to resume. Disabled subscriptions will not receive events.
812
+
813
+ recover_since : typing.Optional[dt.datetime]
814
+ When re-enabling a subscription (`disabled: false`), optionally recover failed messages from this timestamp. Only applies when enabling.
815
+
816
+ request_options : typing.Optional[RequestOptions]
817
+ Request-specific configuration.
818
+
819
+ Returns
820
+ -------
821
+ WebhookSubscription
822
+ Updated subscription
823
+
824
+ Examples
825
+ --------
826
+ import asyncio
827
+
828
+ from airweave import AsyncAirweaveSDK
829
+
830
+ client = AsyncAirweaveSDK(
831
+ api_key="YOUR_API_KEY",
832
+ )
833
+
834
+
835
+ async def main() -> None:
836
+ await client.events.patch_subscription(
837
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
838
+ )
839
+
840
+
841
+ asyncio.run(main())
842
+ """
843
+ _response = await self._raw_client.patch_subscription(
844
+ subscription_id,
845
+ url=url,
846
+ event_types=event_types,
847
+ disabled=disabled,
848
+ recover_since=recover_since,
849
+ request_options=request_options,
850
+ )
851
+ return _response.data
852
+
853
+ async def recover_failed_messages(
854
+ self,
855
+ subscription_id: str,
856
+ *,
857
+ since: dt.datetime,
858
+ until: typing.Optional[dt.datetime] = OMIT,
859
+ request_options: typing.Optional[RequestOptions] = None,
860
+ ) -> RecoveryTask:
861
+ """
862
+ Retry failed message deliveries for a webhook subscription.
863
+
864
+ Triggers a recovery process that replays all failed messages within the
865
+ specified time window. This is useful when:
866
+
867
+ - Your endpoint was temporarily down and you want to catch up
868
+ - You've fixed a bug in your webhook handler
869
+ - You want to reprocess events after re-enabling a disabled subscription
870
+
871
+ Messages are retried in chronological order. Successfully delivered messages
872
+ are skipped; only failed or pending messages are retried.
873
+
874
+ Parameters
875
+ ----------
876
+ subscription_id : str
877
+ The unique identifier of the subscription to recover messages for (UUID).
878
+
879
+ since : dt.datetime
880
+ Start of the recovery time window (inclusive). All failed messages from this time onward will be retried.
881
+
882
+ until : typing.Optional[dt.datetime]
883
+ End of the recovery time window (exclusive). If not specified, recovers all failed messages up to now.
884
+
885
+ request_options : typing.Optional[RequestOptions]
886
+ Request-specific configuration.
887
+
888
+ Returns
889
+ -------
890
+ RecoveryTask
891
+ Recovery task information
892
+
893
+ Examples
894
+ --------
895
+ import asyncio
896
+ import datetime
897
+
898
+ from airweave import AsyncAirweaveSDK
899
+
900
+ client = AsyncAirweaveSDK(
901
+ api_key="YOUR_API_KEY",
902
+ )
903
+
904
+
905
+ async def main() -> None:
906
+ await client.events.recover_failed_messages(
907
+ subscription_id="550e8400-e29b-41d4-a716-446655440000",
908
+ since=datetime.datetime.fromisoformat(
909
+ "2024-03-14 00:00:00+00:00",
910
+ ),
911
+ )
912
+
913
+
914
+ asyncio.run(main())
915
+ """
916
+ _response = await self._raw_client.recover_failed_messages(
917
+ subscription_id, since=since, until=until, request_options=request_options
918
+ )
919
+ return _response.data