sift_client.resources.webhooks
¶
| CLASS | DESCRIPTION |
|---|---|
WebhooksAPIAsync |
High-level API for interacting with webhooks. |
WebhooksAPIAsync
¶
WebhooksAPIAsync(sift_client: SiftClient)
Bases: ResourceBase
High-level API for interacting with webhooks.
A webhook registers an HTTP endpoint that Sift calls when an event occurs, such as a rule violation. This class provides a Pythonic, notebook-friendly interface for interacting with the WebhooksAPI. It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the Webhook class from the low-level wrapper, which is a user-friendly representation of a webhook using standard Python data structures and types.
Initialize the WebhooksAPI.
| PARAMETER | DESCRIPTION |
|---|---|
sift_client
|
The Sift client to use.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
get |
Get a Webhook. |
list_ |
List webhooks with optional filtering. |
find |
Find a single webhook matching the given query. Takes the same arguments as |
create |
Create a new webhook. |
update |
Update a Webhook. |
archive |
Archive a webhook. Archived webhooks stop receiving events. |
unarchive |
Unarchive a webhook. |
test |
Send a live request to a webhook's target URL and return its response. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
client |
TYPE:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
get
async
¶
get(webhook_id: str) -> Webhook
Get a Webhook.
| PARAMETER | DESCRIPTION |
|---|---|
webhook_id
|
The ID of the webhook.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Webhook
|
The Webhook. |
list_
async
¶
list_(
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | Pattern | None = None,
webhook_ids: list[str] | None = None,
event_type: WebhookEventType | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
page_size: int | None = None,
) -> list[Webhook]
List webhooks with optional filtering.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Exact name of the webhook.
TYPE:
|
names
|
List of webhook names to filter by.
TYPE:
|
name_contains
|
Partial name of the webhook.
TYPE:
|
name_regex
|
Regular expression to filter webhooks by name.
TYPE:
|
webhook_ids
|
Filter to webhooks with any of these IDs.
TYPE:
|
event_type
|
Filter to webhooks triggered by this event type.
TYPE:
|
include_archived
|
If True, include archived webhooks in results.
TYPE:
|
filter_query
|
Explicit CEL query to filter webhooks.
TYPE:
|
order_by
|
Field and direction to order results by. Only
TYPE:
|
limit
|
Maximum number of webhooks to return. If None, returns all matches.
TYPE:
|
page_size
|
Number of results to fetch per request. Lower this if you hit gRPC message size limits on responses. If None, uses the server default.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Webhook]
|
A list of Webhook objects that match the filter criteria. |
find
async
¶
find(**kwargs) -> Webhook | None
Find a single webhook matching the given query. Takes the same arguments as list_.
If more than one webhook is found, raises an error.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Keyword arguments to pass to
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Webhook | None
|
The Webhook found or None. |
create
async
¶
create(create: WebhookCreate | dict) -> Webhook
Create a new webhook.
| PARAMETER | DESCRIPTION |
|---|---|
create
|
The webhook definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Webhook
|
The created Webhook. |
update
async
¶
update(
webhook: str | Webhook, update: WebhookUpdate | dict
) -> Webhook
Update a Webhook.
Note that http_headers is replaced wholesale, not merged.
| PARAMETER | DESCRIPTION |
|---|---|
webhook
|
The Webhook or webhook ID to update.
TYPE:
|
update
|
Updates to apply to the Webhook.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Webhook
|
The updated Webhook. |
archive
async
¶
unarchive
async
¶
test
async
¶
test(
webhook: str | Webhook | None = None,
*,
create: WebhookCreate | dict | None = None,
) -> WebhookTestResult
Send a live request to a webhook's target URL and return its response.
This performs a real HTTP request against the target URL. Exactly one of webhook
or create must be provided. Use create to check an endpoint before saving it.
| PARAMETER | DESCRIPTION |
|---|---|
webhook
|
The Webhook or webhook ID to test.
TYPE:
|
create
|
An unsaved webhook definition to test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WebhookTestResult
|
The response the target URL returned. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither or both arguments are provided. |