Skip to content

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: SiftClient

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 list_.

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: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

get async

get(webhook_id: str) -> Webhook

Get a Webhook.

PARAMETER DESCRIPTION
webhook_id

The ID of the webhook.

TYPE: str

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: str | None DEFAULT: None

names

List of webhook names to filter by.

TYPE: list[str] | None DEFAULT: None

name_contains

Partial name of the webhook.

TYPE: str | None DEFAULT: None

name_regex

Regular expression to filter webhooks by name.

TYPE: str | Pattern | None DEFAULT: None

webhook_ids

Filter to webhooks with any of these IDs.

TYPE: list[str] | None DEFAULT: None

event_type

Filter to webhooks triggered by this event type.

TYPE: WebhookEventType | None DEFAULT: None

include_archived

If True, include archived webhooks in results.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query to filter webhooks.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by. Only created_date is supported, e.g. "created_date desc".

TYPE: str | None DEFAULT: None

limit

Maximum number of webhooks to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

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: int | None DEFAULT: None

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 list_.

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. http_headers accepts either a list of WebhookHttpHeader or a {name: value} mapping.

TYPE: WebhookCreate | dict

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: str | Webhook

update

Updates to apply to the Webhook.

TYPE: WebhookUpdate | dict

RETURNS DESCRIPTION
Webhook

The updated Webhook.

archive async

archive(webhook: str | Webhook) -> Webhook

Archive a webhook. Archived webhooks stop receiving events.

PARAMETER DESCRIPTION
webhook

The Webhook or webhook ID to archive.

TYPE: str | Webhook

RETURNS DESCRIPTION
Webhook

The archived Webhook.

unarchive async

unarchive(webhook: str | Webhook) -> Webhook

Unarchive a webhook.

PARAMETER DESCRIPTION
webhook

The Webhook or webhook ID to unarchive.

TYPE: str | Webhook

RETURNS DESCRIPTION
Webhook

The unarchived Webhook.

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: str | Webhook | None DEFAULT: None

create

An unsaved webhook definition to test.

TYPE: WebhookCreate | dict | None DEFAULT: None

RETURNS DESCRIPTION
WebhookTestResult

The response the target URL returned.

RAISES DESCRIPTION
ValueError

If neither or both arguments are provided.