or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

actors.mdbuilds.mdindex.mdlogging.mdrequest-queues.mdruns.mdschedules.mdstorage.mdstore.mdtasks.mdusers.mdwebhooks.md

webhooks.mddocs/

0

# Webhooks

1

2

Webhook configuration and management for real-time notifications and integrations. Webhooks provide event-driven notifications for Actor runs, builds, and other platform events.

3

4

## Capabilities

5

6

### Webhook Operations

7

8

```python { .api }

9

class WebhookClient:

10

def get(self) -> dict | None:

11

"""Get webhook information."""

12

13

def update(self, **kwargs) -> dict:

14

"""Update webhook configuration.

15

16

Args:

17

event_types (list[str], optional): List of event types to listen for

18

request_url (str, optional): URL to send webhook requests to

19

payload_template (str, optional): Custom payload template

20

headers_template (str, optional): Custom headers template

21

condition (dict, optional): Conditions for webhook firing

22

**kwargs: Additional webhook parameters

23

"""

24

25

def delete(self) -> None:

26

"""Delete webhook."""

27

28

def test(self) -> dict | None:

29

"""Test webhook by sending dummy payload."""

30

31

def dispatches(self) -> WebhookDispatchCollectionClient:

32

"""Get webhook dispatches collection."""

33

34

class WebhookClientAsync:

35

"""Async version of WebhookClient with identical methods."""

36

37

class WebhookCollectionClient:

38

def list(

39

self,

40

*,

41

limit: int | None = None,

42

offset: int | None = None,

43

desc: bool | None = None

44

) -> ListPage[dict]:

45

"""List webhooks.

46

47

Args:

48

limit: Maximum number of webhooks

49

offset: Pagination offset

50

desc: Sort in descending order

51

"""

52

53

def create(self, **kwargs) -> dict:

54

"""Create new webhook.

55

56

Args:

57

event_types (list[str]): Event types to listen for

58

request_url (str): Target URL for webhook requests

59

payload_template (str, optional): Custom payload template

60

headers_template (str, optional): Custom headers template

61

condition (dict, optional): Webhook conditions

62

**kwargs: Additional webhook configuration

63

"""

64

65

class WebhookCollectionClientAsync:

66

"""Async version of WebhookCollectionClient with identical methods."""

67

```

68

69

### Webhook Dispatch Management

70

71

```python { .api }

72

class WebhookDispatchClient:

73

def get(self) -> dict | None:

74

"""Get webhook dispatch information."""

75

76

class WebhookDispatchClientAsync:

77

"""Async version of WebhookDispatchClient with identical methods."""

78

79

class WebhookDispatchCollectionClient:

80

def list(

81

self,

82

*,

83

limit: int | None = None,

84

offset: int | None = None,

85

desc: bool | None = None

86

) -> ListPage[dict]:

87

"""List webhook dispatches.

88

89

Args:

90

limit: Maximum number of dispatches

91

offset: Pagination offset

92

desc: Sort in descending order

93

"""

94

95

class WebhookDispatchCollectionClientAsync:

96

"""Async version of WebhookDispatchCollectionClient with identical methods."""

97

```

98

99

## Usage Examples

100

101

```python

102

from apify_client import ApifyClient

103

104

client = ApifyClient('your-api-token')

105

106

# Create webhook for Actor run events

107

webhook = client.webhooks().create(

108

event_types=['ACTOR.RUN.SUCCEEDED', 'ACTOR.RUN.FAILED'],

109

request_url='https://myapp.com/webhook/apify',

110

payload_template='{"runId": "{{runId}}", "status": "{{status}}", "actorId": "{{actorId}}"}',

111

headers_template='{"Authorization": "Bearer {{myToken}}", "Content-Type": "application/json"}'

112

)

113

114

# Test webhook

115

webhook_client = client.webhook(webhook['id'])

116

test_result = webhook_client.test()

117

print(f"Webhook test result: {test_result}")

118

119

# Monitor webhook dispatches

120

dispatches = webhook_client.dispatches().list(limit=10)

121

for dispatch in dispatches.items:

122

print(f"Dispatch {dispatch['id']}: {dispatch['status']}")

123

```