@agility/management-sdk 0.1.35 → 0.1.37

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 (261) hide show
  1. package/README.md +371 -317
  2. package/dist/apiMethods/clientInstance.d.ts +2 -0
  3. package/dist/apiMethods/clientInstance.js +11 -2
  4. package/dist/apiMethods/containerMethods.d.ts +3 -0
  5. package/dist/apiMethods/containerMethods.js +43 -9
  6. package/dist/apiMethods/contentMethods.d.ts +12 -0
  7. package/dist/apiMethods/contentMethods.js +119 -48
  8. package/dist/apiMethods/pageMethods.d.ts +12 -0
  9. package/dist/apiMethods/pageMethods.js +88 -34
  10. package/dist/enums/contentViewType.d.ts +6 -0
  11. package/dist/enums/contentViewType.js +10 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +2 -0
  14. package/dist/models/pagedResult.d.ts +4 -0
  15. package/dist/models/pagedResult.js +2 -0
  16. package/dist/util/queryString.d.ts +8 -0
  17. package/dist/util/queryString.js +27 -0
  18. package/docs/asset-methods.md +381 -381
  19. package/docs/auth-component.md +360 -360
  20. package/docs/auth.md +593 -593
  21. package/docs/batch-methods.md +243 -243
  22. package/docs/cicd.md +606 -606
  23. package/docs/container-methods.md +267 -267
  24. package/docs/content-methods.md +491 -422
  25. package/docs/instance-methods.md +104 -104
  26. package/docs/instance-user-methods.md +230 -230
  27. package/docs/model-methods.md +433 -433
  28. package/docs/multi-instance-operations.md +191 -191
  29. package/docs/page-methods.md +737 -670
  30. package/docs/server-user-methods.md +279 -279
  31. package/docs/webhook-methods.md +451 -451
  32. package/license.txt +20 -20
  33. package/package.json +40 -40
  34. package/tsconfig.json +14 -14
  35. package/.cursor/api-coverage.md +0 -217
  36. package/.cursor/api-documentation-manifest.md +0 -275
  37. package/.cursor/api-functions-analysis.md +0 -111
  38. package/.cursor/breakout-manifest.md +0 -278
  39. package/.cursor/docs-final-check.md +0 -269
  40. package/.cursor/github-actions-improvements.md +0 -76
  41. package/.cursor/hardening.md +0 -271
  42. package/.cursor/linting-fix.md +0 -160
  43. package/.cursor/manifest.md +0 -243
  44. package/.cursor/mocks.md +0 -100
  45. package/.cursor/test-coverage.md +0 -841
  46. package/.env +0 -92
  47. package/coverage/base.css +0 -224
  48. package/coverage/block-navigation.js +0 -87
  49. package/coverage/coverage-summary.json +0 -43
  50. package/coverage/favicon.png +0 -0
  51. package/coverage/index.html +0 -161
  52. package/coverage/lcov-report/base.css +0 -224
  53. package/coverage/lcov-report/block-navigation.js +0 -87
  54. package/coverage/lcov-report/favicon.png +0 -0
  55. package/coverage/lcov-report/index.html +0 -161
  56. package/coverage/lcov-report/prettify.css +0 -1
  57. package/coverage/lcov-report/prettify.js +0 -2
  58. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  59. package/coverage/lcov-report/sorter.js +0 -210
  60. package/coverage/lcov-report/src/apiClient.ts.html +0 -199
  61. package/coverage/lcov-report/src/apiMethods/assetMethods.ts.html +0 -682
  62. package/coverage/lcov-report/src/apiMethods/batchMethods.ts.html +0 -736
  63. package/coverage/lcov-report/src/apiMethods/clientInstance.ts.html +0 -403
  64. package/coverage/lcov-report/src/apiMethods/containerMethods.ts.html +0 -460
  65. package/coverage/lcov-report/src/apiMethods/contentMethods.ts.html +0 -1183
  66. package/coverage/lcov-report/src/apiMethods/index.html +0 -266
  67. package/coverage/lcov-report/src/apiMethods/instanceMethods.ts.html +0 -160
  68. package/coverage/lcov-report/src/apiMethods/instanceUserMethods.ts.html +0 -268
  69. package/coverage/lcov-report/src/apiMethods/modelMethods.ts.html +0 -352
  70. package/coverage/lcov-report/src/apiMethods/pageMethods.ts.html +0 -1276
  71. package/coverage/lcov-report/src/apiMethods/serverUserMethods.ts.html +0 -196
  72. package/coverage/lcov-report/src/apiMethods/webhookMethods.ts.html +0 -271
  73. package/coverage/lcov-report/src/enums/batchItemType.ts.html +0 -106
  74. package/coverage/lcov-report/src/enums/batchOperationType.ts.html +0 -142
  75. package/coverage/lcov-report/src/enums/batchState..ts.html +0 -106
  76. package/coverage/lcov-report/src/enums/index.html +0 -161
  77. package/coverage/lcov-report/src/enums/workflowOperationType.ts.html +0 -175
  78. package/coverage/lcov-report/src/index.html +0 -116
  79. package/coverage/lcov-report/src/models/assetContainer.ts.html +0 -106
  80. package/coverage/lcov-report/src/models/assetGalleries.ts.html +0 -103
  81. package/coverage/lcov-report/src/models/assetMediaGrouping.ts.html +0 -136
  82. package/coverage/lcov-report/src/models/assetMediaGroupingMetaData.ts.html +0 -97
  83. package/coverage/lcov-report/src/models/batch.ts.html +0 -178
  84. package/coverage/lcov-report/src/models/batchItem.ts.html +0 -127
  85. package/coverage/lcov-report/src/models/container.ts.html +0 -232
  86. package/coverage/lcov-report/src/models/contentDefinitionTypeID.ts.html +0 -142
  87. package/coverage/lcov-report/src/models/contentItem.ts.html +0 -202
  88. package/coverage/lcov-report/src/models/contentSectionDefaultModule.ts.html +0 -106
  89. package/coverage/lcov-report/src/models/contentSectionDefinition.ts.html +0 -196
  90. package/coverage/lcov-report/src/models/contentViewColumn.ts.html +0 -109
  91. package/coverage/lcov-report/src/models/exception.ts.html +0 -109
  92. package/coverage/lcov-report/src/models/index.html +0 -476
  93. package/coverage/lcov-report/src/models/instanceRole.ts.html +0 -106
  94. package/coverage/lcov-report/src/models/instanceUser.ts.html +0 -130
  95. package/coverage/lcov-report/src/models/locales.ts.html +0 -100
  96. package/coverage/lcov-report/src/models/media.ts.html +0 -178
  97. package/coverage/lcov-report/src/models/model.ts.html +0 -172
  98. package/coverage/lcov-report/src/models/notification.ts.html +0 -124
  99. package/coverage/lcov-report/src/models/options.ts.html +0 -109
  100. package/coverage/lcov-report/src/models/pageItem.ts.html +0 -268
  101. package/coverage/lcov-report/src/models/pageModel.ts.html +0 -130
  102. package/coverage/lcov-report/src/models/sharedModule.ts.html +0 -106
  103. package/coverage/lcov-report/src/models/sitemap.ts.html +0 -148
  104. package/coverage/lcov-report/src/models/websiteUser.ts.html +0 -157
  105. package/coverage/lcov.info +0 -1459
  106. package/coverage/prettify.css +0 -1
  107. package/coverage/prettify.js +0 -2
  108. package/coverage/sort-arrow-sprite.png +0 -0
  109. package/coverage/sorter.js +0 -210
  110. package/coverage/src/apiClient.ts.html +0 -199
  111. package/coverage/src/apiMethods/assetMethods.ts.html +0 -682
  112. package/coverage/src/apiMethods/batchMethods.ts.html +0 -736
  113. package/coverage/src/apiMethods/clientInstance.ts.html +0 -403
  114. package/coverage/src/apiMethods/containerMethods.ts.html +0 -460
  115. package/coverage/src/apiMethods/contentMethods.ts.html +0 -1183
  116. package/coverage/src/apiMethods/index.html +0 -266
  117. package/coverage/src/apiMethods/instanceMethods.ts.html +0 -160
  118. package/coverage/src/apiMethods/instanceUserMethods.ts.html +0 -268
  119. package/coverage/src/apiMethods/modelMethods.ts.html +0 -352
  120. package/coverage/src/apiMethods/pageMethods.ts.html +0 -1276
  121. package/coverage/src/apiMethods/serverUserMethods.ts.html +0 -196
  122. package/coverage/src/apiMethods/webhookMethods.ts.html +0 -271
  123. package/coverage/src/enums/batchItemType.ts.html +0 -106
  124. package/coverage/src/enums/batchOperationType.ts.html +0 -142
  125. package/coverage/src/enums/batchState..ts.html +0 -106
  126. package/coverage/src/enums/index.html +0 -161
  127. package/coverage/src/enums/workflowOperationType.ts.html +0 -175
  128. package/coverage/src/index.html +0 -116
  129. package/coverage/src/models/assetContainer.ts.html +0 -106
  130. package/coverage/src/models/assetGalleries.ts.html +0 -103
  131. package/coverage/src/models/assetMediaGrouping.ts.html +0 -136
  132. package/coverage/src/models/assetMediaGroupingMetaData.ts.html +0 -97
  133. package/coverage/src/models/batch.ts.html +0 -178
  134. package/coverage/src/models/batchItem.ts.html +0 -127
  135. package/coverage/src/models/container.ts.html +0 -232
  136. package/coverage/src/models/contentDefinitionTypeID.ts.html +0 -142
  137. package/coverage/src/models/contentItem.ts.html +0 -202
  138. package/coverage/src/models/contentSectionDefaultModule.ts.html +0 -106
  139. package/coverage/src/models/contentSectionDefinition.ts.html +0 -196
  140. package/coverage/src/models/contentViewColumn.ts.html +0 -109
  141. package/coverage/src/models/exception.ts.html +0 -109
  142. package/coverage/src/models/index.html +0 -476
  143. package/coverage/src/models/instanceRole.ts.html +0 -106
  144. package/coverage/src/models/instanceUser.ts.html +0 -130
  145. package/coverage/src/models/locales.ts.html +0 -100
  146. package/coverage/src/models/media.ts.html +0 -178
  147. package/coverage/src/models/model.ts.html +0 -172
  148. package/coverage/src/models/notification.ts.html +0 -124
  149. package/coverage/src/models/options.ts.html +0 -109
  150. package/coverage/src/models/pageItem.ts.html +0 -268
  151. package/coverage/src/models/pageModel.ts.html +0 -130
  152. package/coverage/src/models/sharedModule.ts.html +0 -106
  153. package/coverage/src/models/sitemap.ts.html +0 -148
  154. package/coverage/src/models/websiteUser.ts.html +0 -157
  155. package/dist/.tsbuildinfo +0 -1
  156. package/dist/apiClient.d.ts.map +0 -1
  157. package/dist/apiClient.js.map +0 -1
  158. package/dist/apiMethods/assetMethods.d.ts.map +0 -1
  159. package/dist/apiMethods/assetMethods.js.map +0 -1
  160. package/dist/apiMethods/batchMethods.d.ts.map +0 -1
  161. package/dist/apiMethods/batchMethods.js.map +0 -1
  162. package/dist/apiMethods/clientInstance.d.ts.map +0 -1
  163. package/dist/apiMethods/clientInstance.js.map +0 -1
  164. package/dist/apiMethods/containerMethods.d.ts.map +0 -1
  165. package/dist/apiMethods/containerMethods.js.map +0 -1
  166. package/dist/apiMethods/contentMethods.d.ts.map +0 -1
  167. package/dist/apiMethods/contentMethods.js.map +0 -1
  168. package/dist/apiMethods/instanceMethods.d.ts.map +0 -1
  169. package/dist/apiMethods/instanceMethods.js.map +0 -1
  170. package/dist/apiMethods/instanceUserMethods.d.ts.map +0 -1
  171. package/dist/apiMethods/instanceUserMethods.js.map +0 -1
  172. package/dist/apiMethods/modelMethods.d.ts.map +0 -1
  173. package/dist/apiMethods/modelMethods.js.map +0 -1
  174. package/dist/apiMethods/pageMethods.d.ts.map +0 -1
  175. package/dist/apiMethods/pageMethods.js.map +0 -1
  176. package/dist/apiMethods/serverUserMethods.d.ts.map +0 -1
  177. package/dist/apiMethods/serverUserMethods.js.map +0 -1
  178. package/dist/apiMethods/webhookMethods.d.ts.map +0 -1
  179. package/dist/apiMethods/webhookMethods.js.map +0 -1
  180. package/dist/enums/assetGroupingType.d.ts.map +0 -1
  181. package/dist/enums/assetGroupingType.js.map +0 -1
  182. package/dist/enums/batchItemType.d.ts.map +0 -1
  183. package/dist/enums/batchItemType.js.map +0 -1
  184. package/dist/enums/batchOperationType.d.ts.map +0 -1
  185. package/dist/enums/batchOperationType.js.map +0 -1
  186. package/dist/enums/batchState..d.ts.map +0 -1
  187. package/dist/enums/batchState..js.map +0 -1
  188. package/dist/enums/pageItemTemplateType.d.ts.map +0 -1
  189. package/dist/enums/pageItemTemplateType.js.map +0 -1
  190. package/dist/enums/workflowOperationType.d.ts.map +0 -1
  191. package/dist/enums/workflowOperationType.js.map +0 -1
  192. package/dist/index.d.ts.map +0 -1
  193. package/dist/index.js.map +0 -1
  194. package/dist/models/assetContainer.d.ts.map +0 -1
  195. package/dist/models/assetContainer.js.map +0 -1
  196. package/dist/models/assetGalleries.d.ts.map +0 -1
  197. package/dist/models/assetGalleries.js.map +0 -1
  198. package/dist/models/assetMediaGrouping.d.ts.map +0 -1
  199. package/dist/models/assetMediaGrouping.js.map +0 -1
  200. package/dist/models/assetMediaGroupingMetaData.d.ts.map +0 -1
  201. package/dist/models/assetMediaGroupingMetaData.js.map +0 -1
  202. package/dist/models/batch.d.ts.map +0 -1
  203. package/dist/models/batch.js.map +0 -1
  204. package/dist/models/batchItem.d.ts.map +0 -1
  205. package/dist/models/batchItem.js.map +0 -1
  206. package/dist/models/batchTypes.d.ts.map +0 -1
  207. package/dist/models/batchTypes.js.map +0 -1
  208. package/dist/models/container.d.ts.map +0 -1
  209. package/dist/models/container.js.map +0 -1
  210. package/dist/models/contentDefinitionTypeID.d.ts.map +0 -1
  211. package/dist/models/contentDefinitionTypeID.js.map +0 -1
  212. package/dist/models/contentItem.d.ts.map +0 -1
  213. package/dist/models/contentItem.js.map +0 -1
  214. package/dist/models/contentItemHistory.d.ts.map +0 -1
  215. package/dist/models/contentItemHistory.js.map +0 -1
  216. package/dist/models/contentListFilterModel.d.ts.map +0 -1
  217. package/dist/models/contentListFilterModel.js.map +0 -1
  218. package/dist/models/contentSectionDefaultModule.d.ts.map +0 -1
  219. package/dist/models/contentSectionDefaultModule.js.map +0 -1
  220. package/dist/models/contentSectionDefinition.d.ts.map +0 -1
  221. package/dist/models/contentSectionDefinition.js.map +0 -1
  222. package/dist/models/contentViewColumn.d.ts.map +0 -1
  223. package/dist/models/contentViewColumn.js.map +0 -1
  224. package/dist/models/exception.d.ts.map +0 -1
  225. package/dist/models/exception.js.map +0 -1
  226. package/dist/models/instanceRole.d.ts.map +0 -1
  227. package/dist/models/instanceRole.js.map +0 -1
  228. package/dist/models/instanceUser.d.ts.map +0 -1
  229. package/dist/models/instanceUser.js.map +0 -1
  230. package/dist/models/itemComments.d.ts.map +0 -1
  231. package/dist/models/itemComments.js.map +0 -1
  232. package/dist/models/listParams.d.ts.map +0 -1
  233. package/dist/models/listParams.js.map +0 -1
  234. package/dist/models/locales.d.ts.map +0 -1
  235. package/dist/models/locales.js.map +0 -1
  236. package/dist/models/media.d.ts.map +0 -1
  237. package/dist/models/media.js.map +0 -1
  238. package/dist/models/model.d.ts.map +0 -1
  239. package/dist/models/model.js.map +0 -1
  240. package/dist/models/notification.d.ts.map +0 -1
  241. package/dist/models/notification.js.map +0 -1
  242. package/dist/models/options.d.ts.map +0 -1
  243. package/dist/models/options.js.map +0 -1
  244. package/dist/models/pageHistory.d.ts.map +0 -1
  245. package/dist/models/pageHistory.js.map +0 -1
  246. package/dist/models/pageItem.d.ts.map +0 -1
  247. package/dist/models/pageItem.js.map +0 -1
  248. package/dist/models/pageModel.d.ts.map +0 -1
  249. package/dist/models/pageModel.js.map +0 -1
  250. package/dist/models/serverUser.d.ts.map +0 -1
  251. package/dist/models/serverUser.js.map +0 -1
  252. package/dist/models/sharedModule.d.ts.map +0 -1
  253. package/dist/models/sharedModule.js.map +0 -1
  254. package/dist/models/sitemap.d.ts.map +0 -1
  255. package/dist/models/sitemap.js.map +0 -1
  256. package/dist/models/webhook.d.ts.map +0 -1
  257. package/dist/models/webhook.js.map +0 -1
  258. package/dist/models/websiteListing.d.ts.map +0 -1
  259. package/dist/models/websiteListing.js.map +0 -1
  260. package/dist/models/websiteUser.d.ts.map +0 -1
  261. package/dist/models/websiteUser.js.map +0 -1
@@ -1,452 +1,452 @@
1
- # Agility CMS & Management API TypeScript SDK
2
-
3
- ## WebhookMethods
4
-
5
- This class provides comprehensive webhook management operations for Agility CMS. Webhooks allow you to receive real-time notifications when specific events occur in your CMS, enabling integration with external systems and automated workflows.
6
-
7
- **Important Notes:**
8
- - Webhooks provide real-time event notifications to external endpoints
9
- - Each webhook can be configured to trigger on specific events
10
- - Webhooks support various event types (content changes, page updates, etc.)
11
- - Webhook URLs must be accessible and return appropriate HTTP status codes
12
- - Failed webhook deliveries are automatically retried with exponential backoff
13
- - Webhooks can be secured with authentication headers or signatures
14
-
15
- ### Function List
16
- - [getWebhook](#getwebhook) - Retrieves a specific webhook by ID
17
- - [webhookList](#webhooklist) - Retrieves list of all webhooks
18
- - [saveWebhook](#savewebhook) - Creates or updates a webhook
19
- - [deleteWebhook](#deletewebhook) - Deletes a webhook by ID
20
-
21
- ---
22
-
23
- ### getWebhook
24
-
25
- Retrieves a specific webhook by its unique ID.
26
-
27
- | Parameter | Type | Required | Description |
28
- |-----------|------|----------|-------------|
29
- | `webhookID` | `number` | Yes | The webhook ID to retrieve |
30
- | `guid` | `string` | Yes | Current website GUID |
31
-
32
- **Returns:** `Webhook` - Complete webhook object with configuration and statistics
33
-
34
- **Usage Example:**
35
- ```typescript
36
- const webhook = await apiClient.webhookMethods.getWebhook(123, guid);
37
- console.log('Webhook name:', webhook.name);
38
- console.log('Webhook URL:', webhook.url);
39
- console.log('Events:', webhook.events);
40
- console.log('Active:', webhook.isActive);
41
- console.log('Created:', webhook.createdDate);
42
- console.log('Last triggered:', webhook.lastTriggered);
43
-
44
- // Display webhook statistics
45
- if (webhook.statistics) {
46
- console.log('Statistics:');
47
- console.log(` Total deliveries: ${webhook.statistics.totalDeliveries}`);
48
- console.log(` Successful deliveries: ${webhook.statistics.successfulDeliveries}`);
49
- console.log(` Failed deliveries: ${webhook.statistics.failedDeliveries}`);
50
- console.log(` Success rate: ${webhook.statistics.successRate}%`);
51
- }
52
-
53
- // Display webhook configuration
54
- console.log('Configuration:');
55
- console.log(` Method: ${webhook.method}`);
56
- console.log(` Content Type: ${webhook.contentType}`);
57
- console.log(` Timeout: ${webhook.timeout}ms`);
58
- console.log(` Retry count: ${webhook.retryCount}`);
59
-
60
- // Check authentication
61
- if (webhook.authentication) {
62
- console.log('Authentication enabled:');
63
- console.log(` Type: ${webhook.authentication.type}`);
64
- console.log(` Headers: ${Object.keys(webhook.authentication.headers).join(', ')}`);
65
- } else {
66
- console.log('No authentication configured');
67
- }
68
- ```
69
-
70
- **Response Properties:**
71
- The `Webhook` object includes:
72
- - `webhookID`: Unique identifier for the webhook
73
- - `name`: Human-readable name for the webhook
74
- - `url`: Target URL for webhook deliveries
75
- - `events`: Array of events that trigger the webhook
76
- - `isActive`: Whether the webhook is active
77
- - `method`: HTTP method (GET, POST, PUT, etc.)
78
- - `contentType`: Content type for webhook payload
79
- - `timeout`: Request timeout in milliseconds
80
- - `retryCount`: Number of retry attempts for failed deliveries
81
- - `authentication`: Authentication configuration
82
- - `statistics`: Delivery statistics and metrics
83
-
84
- **Error Handling:**
85
- - Throws `Exception` when webhook not found
86
-
87
- ### webhookList
88
-
89
- Retrieves a list of all webhooks in the current website.
90
-
91
- | Parameter | Type | Required | Description |
92
- |-----------|------|----------|-------------|
93
- | `guid` | `string` | Yes | Current website GUID |
94
- | `take` | `number` | No | Number of records to take (default: 20) |
95
- | `token` | `string` | No | Token parameter (default: null) |
96
-
97
- **Returns:** `any` - Array of all webhooks
98
-
99
- **Usage Example:**
100
- ```typescript
101
- const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
102
- console.log(`Total webhooks: ${webhooks.length}`);
103
-
104
- // Display webhook summary
105
- webhooks.forEach(webhook => {
106
- console.log(`Webhook: ${webhook.name}`);
107
- console.log(` URL: ${webhook.url}`);
108
- console.log(` Events: ${webhook.events.join(', ')}`);
109
- console.log(` Active: ${webhook.isActive ? 'Yes' : 'No'}`);
110
- console.log(` Last triggered: ${webhook.lastTriggered || 'Never'}`);
111
- console.log('---');
112
- });
113
-
114
- // Filter active webhooks
115
- const activeWebhooks = webhooks.filter(w => w.isActive);
116
- const inactiveWebhooks = webhooks.filter(w => !w.isActive);
117
- console.log(`Active webhooks: ${activeWebhooks.length}`);
118
- console.log(`Inactive webhooks: ${inactiveWebhooks.length}`);
119
-
120
- // Group webhooks by event type
121
- const webhooksByEvent = webhooks.reduce((acc, webhook) => {
122
- webhook.events.forEach(event => {
123
- if (!acc[event]) acc[event] = [];
124
- acc[event].push(webhook);
125
- });
126
- return acc;
127
- }, {});
128
-
129
- console.log('Webhooks by event:');
130
- Object.entries(webhooksByEvent).forEach(([event, eventWebhooks]) => {
131
- console.log(` ${event}: ${eventWebhooks.length} webhooks`);
132
- });
133
-
134
- // Find webhooks with high failure rates
135
- const failingWebhooks = webhooks.filter(webhook =>
136
- webhook.statistics && webhook.statistics.successRate < 90
137
- );
138
- console.log(`Webhooks with high failure rate: ${failingWebhooks.length}`);
139
-
140
- // Create webhook dropdown options
141
- const webhookOptions = webhooks.map(webhook => ({
142
- value: webhook.webhookID,
143
- label: webhook.name,
144
- url: webhook.url,
145
- active: webhook.isActive
146
- }));
147
- ```
148
-
149
- **Common Webhook Events:**
150
- - `content.created`: New content item created
151
- - `content.updated`: Content item updated
152
- - `content.deleted`: Content item deleted
153
- - `content.published`: Content item published
154
- - `content.unpublished`: Content item unpublished
155
- - `page.created`: New page created
156
- - `page.updated`: Page updated
157
- - `page.deleted`: Page deleted
158
- - `page.published`: Page published
159
- - `page.unpublished`: Page unpublished
160
- - `model.created`: Content model created
161
- - `model.updated`: Content model updated
162
- - `asset.uploaded`: Asset uploaded
163
- - `asset.updated`: Asset updated
164
-
165
- **Error Handling:**
166
- - Throws `Exception` when retrieval fails
167
-
168
- ### saveWebhook
169
-
170
- Creates a new webhook or updates an existing one.
171
-
172
- | Parameter | Type | Required | Description |
173
- |-----------|------|----------|-------------|
174
- | `webhook` | `Webhook` | Yes | Webhook object to save |
175
- | `guid` | `string` | Yes | Current website GUID |
176
-
177
- **Returns:** `Webhook` - Saved webhook object with updated metadata
178
-
179
- **Usage Example:**
180
- ```typescript
181
- // Create a new webhook
182
- const newWebhook = {
183
- name: 'Content Update Notification',
184
- url: 'https://api.example.com/webhooks/agility-content',
185
- events: [
186
- 'content.created',
187
- 'content.updated',
188
- 'content.published'
189
- ],
190
- isActive: true,
191
- method: 'POST',
192
- contentType: 'application/json',
193
- timeout: 30000,
194
- retryCount: 3,
195
- authentication: {
196
- type: 'header',
197
- headers: {
198
- 'Authorization': 'Bearer your-api-token',
199
- 'X-API-Key': 'your-api-key'
200
- }
201
- }
202
- };
203
-
204
- const savedWebhook = await apiClient.webhookMethods.saveWebhook(newWebhook, guid);
205
- console.log('Webhook created with ID:', savedWebhook.webhookID);
206
-
207
- // Update existing webhook
208
- const existingWebhook = await apiClient.webhookMethods.getWebhook(123, guid);
209
- existingWebhook.name = 'Updated Webhook Name';
210
- existingWebhook.url = 'https://api.example.com/webhooks/updated-endpoint';
211
- existingWebhook.events.push('page.published');
212
-
213
- const updatedWebhook = await apiClient.webhookMethods.saveWebhook(existingWebhook, guid);
214
- console.log('Webhook updated:', updatedWebhook.name);
215
-
216
- // Create webhook with custom payload template
217
- const customWebhook = {
218
- name: 'Custom Payload Webhook',
219
- url: 'https://api.example.com/webhooks/custom',
220
- events: ['content.published'],
221
- isActive: true,
222
- method: 'POST',
223
- contentType: 'application/json',
224
- timeout: 15000,
225
- retryCount: 2,
226
- payloadTemplate: {
227
- eventType: '{{event}}',
228
- timestamp: '{{timestamp}}',
229
- contentData: {
230
- id: '{{content.id}}',
231
- title: '{{content.title}}',
232
- referenceName: '{{content.referenceName}}'
233
- },
234
- customField: 'custom value'
235
- }
236
- };
237
-
238
- // Create webhook with signature verification
239
- const secureWebhook = {
240
- name: 'Secure Webhook',
241
- url: 'https://api.example.com/webhooks/secure',
242
- events: ['content.created', 'content.updated'],
243
- isActive: true,
244
- method: 'POST',
245
- contentType: 'application/json',
246
- timeout: 30000,
247
- retryCount: 3,
248
- authentication: {
249
- type: 'signature',
250
- secret: 'your-webhook-secret',
251
- algorithm: 'sha256',
252
- headerName: 'X-Agility-Signature'
253
- }
254
- };
255
-
256
- // Bulk webhook operations
257
- const createContentWebhooks = async (endpoints) => {
258
- const webhooks = [];
259
- for (const endpoint of endpoints) {
260
- const webhook = {
261
- name: `Content Webhook - ${endpoint.name}`,
262
- url: endpoint.url,
263
- events: ['content.created', 'content.updated', 'content.published'],
264
- isActive: true,
265
- method: 'POST',
266
- contentType: 'application/json',
267
- timeout: 30000,
268
- retryCount: 3
269
- };
270
-
271
- const saved = await apiClient.webhookMethods.saveWebhook(webhook, guid);
272
- webhooks.push(saved);
273
- }
274
- return webhooks;
275
- };
276
- ```
277
-
278
- **Webhook Structure:**
279
- ```typescript
280
- interface Webhook {
281
- webhookID?: number; // Auto-generated for new webhooks
282
- name: string; // Human-readable name (required)
283
- url: string; // Target URL (required)
284
- events: string[]; // Array of event types (required)
285
- isActive: boolean; // Whether webhook is active
286
- method: string; // HTTP method (GET, POST, PUT, etc.)
287
- contentType: string; // Content type for payload
288
- timeout: number; // Request timeout in milliseconds
289
- retryCount: number; // Number of retry attempts
290
- authentication?: WebhookAuth; // Authentication configuration
291
- payloadTemplate?: any; // Custom payload template
292
- statistics?: WebhookStats; // Delivery statistics (read-only)
293
- createdDate?: string; // Auto-generated
294
- lastTriggered?: string; // Auto-generated
295
- }
296
-
297
- interface WebhookAuth {
298
- type: string; // 'header', 'signature', 'basic', etc.
299
- headers?: { [key: string]: string }; // Custom headers
300
- secret?: string; // Secret for signature authentication
301
- algorithm?: string; // Algorithm for signature (sha256, etc.)
302
- headerName?: string; // Header name for signature
303
- }
304
-
305
- interface WebhookStats {
306
- totalDeliveries: number; // Total delivery attempts
307
- successfulDeliveries: number; // Successful deliveries
308
- failedDeliveries: number; // Failed deliveries
309
- successRate: number; // Success rate percentage
310
- lastDeliveryDate: string; // Last delivery attempt date
311
- lastSuccessDate: string; // Last successful delivery date
312
- }
313
- ```
314
-
315
- **Authentication Types:**
316
- - `header`: Custom headers for authentication
317
- - `signature`: HMAC signature verification
318
- - `basic`: Basic authentication
319
- - `bearer`: Bearer token authentication
320
- - `custom`: Custom authentication scheme
321
-
322
- **Error Handling:**
323
- - Throws `Exception` when validation fails (invalid URL, unsupported events, etc.)
324
- - Throws `Exception` when save operation fails
325
- - Throws `Exception` when authentication configuration is invalid
326
-
327
- ### deleteWebhook
328
-
329
- Deletes a webhook by its ID.
330
-
331
- | Parameter | Type | Required | Description |
332
- |-----------|------|----------|-------------|
333
- | `webhookID` | `number` | Yes | The webhook ID to delete |
334
- | `guid` | `string` | Yes | Current website GUID |
335
-
336
- **Returns:** `string` - Confirmation message of successful deletion
337
-
338
- **Usage Example:**
339
- ```typescript
340
- try {
341
- const result = await apiClient.webhookMethods.deleteWebhook(123, guid);
342
- console.log(result); // "Webhook deleted successfully"
343
- } catch (error) {
344
- console.error('Failed to delete webhook:', error.message);
345
- }
346
-
347
- // Safe webhook deletion with confirmation
348
- const safeDeleteWebhook = async (webhookID) => {
349
- try {
350
- // Get webhook details first
351
- const webhook = await apiClient.webhookMethods.getWebhook(webhookID, guid);
352
- console.log(`About to delete webhook: ${webhook.name}`);
353
- console.log(`URL: ${webhook.url}`);
354
- console.log(`Events: ${webhook.events.join(', ')}`);
355
-
356
- // Check if webhook is active
357
- if (webhook.isActive) {
358
- console.log('Warning: Deleting active webhook');
359
- }
360
-
361
- // Perform deletion
362
- const result = await apiClient.webhookMethods.deleteWebhook(webhookID, guid);
363
- console.log('Webhook deleted successfully');
364
- return result;
365
- } catch (error) {
366
- console.error('Failed to delete webhook:', error.message);
367
- throw error;
368
- }
369
- };
370
-
371
- // Bulk cleanup of inactive webhooks
372
- const cleanupInactiveWebhooks = async () => {
373
- const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
374
- const inactiveWebhooks = webhooks.filter(w => !w.isActive);
375
-
376
- console.log(`Found ${inactiveWebhooks.length} inactive webhooks`);
377
-
378
- for (const webhook of inactiveWebhooks) {
379
- const shouldDelete = confirm(
380
- `Delete inactive webhook "${webhook.name}"? (${webhook.url})`
381
- );
382
-
383
- if (shouldDelete) {
384
- await apiClient.webhookMethods.deleteWebhook(webhook.webhookID, guid);
385
- console.log(`Deleted webhook: ${webhook.name}`);
386
- }
387
- }
388
- };
389
-
390
- // Delete webhooks with high failure rates
391
- const cleanupFailingWebhooks = async (maxFailureRate = 50) => {
392
- const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
393
-
394
- const failingWebhooks = webhooks.filter(webhook =>
395
- webhook.statistics &&
396
- webhook.statistics.successRate < maxFailureRate &&
397
- webhook.statistics.totalDeliveries > 10 // Only consider webhooks with sufficient data
398
- );
399
-
400
- console.log(`Found ${failingWebhooks.length} webhooks with high failure rate`);
401
-
402
- for (const webhook of failingWebhooks) {
403
- console.log(`Webhook "${webhook.name}" has ${webhook.statistics.successRate}% success rate`);
404
-
405
- const shouldDelete = confirm(
406
- `Delete failing webhook "${webhook.name}"? (Success rate: ${webhook.statistics.successRate}%)`
407
- );
408
-
409
- if (shouldDelete) {
410
- await apiClient.webhookMethods.deleteWebhook(webhook.webhookID, guid);
411
- console.log(`Deleted failing webhook: ${webhook.name}`);
412
- }
413
- }
414
- };
415
- ```
416
-
417
- **Deletion Considerations:**
418
- - Deleting a webhook immediately stops all future event deliveries
419
- - Pending webhook deliveries may still be processed
420
- - Webhook statistics and history are permanently lost
421
- - Consider deactivating instead of deleting for temporary suspension
422
-
423
- **Best Practices:**
424
- - Test webhook endpoints before creating webhooks
425
- - Use appropriate authentication to secure webhook endpoints
426
- - Monitor webhook statistics and success rates
427
- - Implement proper error handling in webhook receivers
428
- - Use webhook signatures to verify authenticity
429
- - Set reasonable timeout values to avoid blocking
430
- - Consider implementing idempotency in webhook receivers
431
-
432
- **Error Handling:**
433
- - Throws `Exception` when webhook not found
434
- - Throws `Exception` when deletion fails
435
- - Throws `Exception` when insufficient permissions to delete webhooks
436
-
437
- ---
438
-
439
- ## Navigation
440
- - [← Back to Main Documentation](../README.md)
441
- - [Authentication & Setup](./auth.md)
442
- - [AssetMethods](./asset-methods.md)
443
- - [BatchMethods](./batch-methods.md)
444
- - [ContainerMethods](./container-methods.md)
445
- - [ContentMethods](./content-methods.md)
446
- - [InstanceMethods](./instance-methods.md)
447
- - [InstanceUserMethods](./instance-user-methods.md)
448
- - [ModelMethods](./model-methods.md)
449
- - [PageMethods](./page-methods.md)
450
- - [ServerUserMethods](./server-user-methods.md)
451
- - [ServerUserMethods](./server-user-methods.md)
1
+ # Agility CMS & Management API TypeScript SDK
2
+
3
+ ## WebhookMethods
4
+
5
+ This class provides comprehensive webhook management operations for Agility CMS. Webhooks allow you to receive real-time notifications when specific events occur in your CMS, enabling integration with external systems and automated workflows.
6
+
7
+ **Important Notes:**
8
+ - Webhooks provide real-time event notifications to external endpoints
9
+ - Each webhook can be configured to trigger on specific events
10
+ - Webhooks support various event types (content changes, page updates, etc.)
11
+ - Webhook URLs must be accessible and return appropriate HTTP status codes
12
+ - Failed webhook deliveries are automatically retried with exponential backoff
13
+ - Webhooks can be secured with authentication headers or signatures
14
+
15
+ ### Function List
16
+ - [getWebhook](#getwebhook) - Retrieves a specific webhook by ID
17
+ - [webhookList](#webhooklist) - Retrieves list of all webhooks
18
+ - [saveWebhook](#savewebhook) - Creates or updates a webhook
19
+ - [deleteWebhook](#deletewebhook) - Deletes a webhook by ID
20
+
21
+ ---
22
+
23
+ ### getWebhook
24
+
25
+ Retrieves a specific webhook by its unique ID.
26
+
27
+ | Parameter | Type | Required | Description |
28
+ |-----------|------|----------|-------------|
29
+ | `webhookID` | `number` | Yes | The webhook ID to retrieve |
30
+ | `guid` | `string` | Yes | Current website GUID |
31
+
32
+ **Returns:** `Webhook` - Complete webhook object with configuration and statistics
33
+
34
+ **Usage Example:**
35
+ ```typescript
36
+ const webhook = await apiClient.webhookMethods.getWebhook(123, guid);
37
+ console.log('Webhook name:', webhook.name);
38
+ console.log('Webhook URL:', webhook.url);
39
+ console.log('Events:', webhook.events);
40
+ console.log('Active:', webhook.isActive);
41
+ console.log('Created:', webhook.createdDate);
42
+ console.log('Last triggered:', webhook.lastTriggered);
43
+
44
+ // Display webhook statistics
45
+ if (webhook.statistics) {
46
+ console.log('Statistics:');
47
+ console.log(` Total deliveries: ${webhook.statistics.totalDeliveries}`);
48
+ console.log(` Successful deliveries: ${webhook.statistics.successfulDeliveries}`);
49
+ console.log(` Failed deliveries: ${webhook.statistics.failedDeliveries}`);
50
+ console.log(` Success rate: ${webhook.statistics.successRate}%`);
51
+ }
52
+
53
+ // Display webhook configuration
54
+ console.log('Configuration:');
55
+ console.log(` Method: ${webhook.method}`);
56
+ console.log(` Content Type: ${webhook.contentType}`);
57
+ console.log(` Timeout: ${webhook.timeout}ms`);
58
+ console.log(` Retry count: ${webhook.retryCount}`);
59
+
60
+ // Check authentication
61
+ if (webhook.authentication) {
62
+ console.log('Authentication enabled:');
63
+ console.log(` Type: ${webhook.authentication.type}`);
64
+ console.log(` Headers: ${Object.keys(webhook.authentication.headers).join(', ')}`);
65
+ } else {
66
+ console.log('No authentication configured');
67
+ }
68
+ ```
69
+
70
+ **Response Properties:**
71
+ The `Webhook` object includes:
72
+ - `webhookID`: Unique identifier for the webhook
73
+ - `name`: Human-readable name for the webhook
74
+ - `url`: Target URL for webhook deliveries
75
+ - `events`: Array of events that trigger the webhook
76
+ - `isActive`: Whether the webhook is active
77
+ - `method`: HTTP method (GET, POST, PUT, etc.)
78
+ - `contentType`: Content type for webhook payload
79
+ - `timeout`: Request timeout in milliseconds
80
+ - `retryCount`: Number of retry attempts for failed deliveries
81
+ - `authentication`: Authentication configuration
82
+ - `statistics`: Delivery statistics and metrics
83
+
84
+ **Error Handling:**
85
+ - Throws `Exception` when webhook not found
86
+
87
+ ### webhookList
88
+
89
+ Retrieves a list of all webhooks in the current website.
90
+
91
+ | Parameter | Type | Required | Description |
92
+ |-----------|------|----------|-------------|
93
+ | `guid` | `string` | Yes | Current website GUID |
94
+ | `take` | `number` | No | Number of records to take (default: 20) |
95
+ | `token` | `string` | No | Token parameter (default: null) |
96
+
97
+ **Returns:** `any` - Array of all webhooks
98
+
99
+ **Usage Example:**
100
+ ```typescript
101
+ const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
102
+ console.log(`Total webhooks: ${webhooks.length}`);
103
+
104
+ // Display webhook summary
105
+ webhooks.forEach(webhook => {
106
+ console.log(`Webhook: ${webhook.name}`);
107
+ console.log(` URL: ${webhook.url}`);
108
+ console.log(` Events: ${webhook.events.join(', ')}`);
109
+ console.log(` Active: ${webhook.isActive ? 'Yes' : 'No'}`);
110
+ console.log(` Last triggered: ${webhook.lastTriggered || 'Never'}`);
111
+ console.log('---');
112
+ });
113
+
114
+ // Filter active webhooks
115
+ const activeWebhooks = webhooks.filter(w => w.isActive);
116
+ const inactiveWebhooks = webhooks.filter(w => !w.isActive);
117
+ console.log(`Active webhooks: ${activeWebhooks.length}`);
118
+ console.log(`Inactive webhooks: ${inactiveWebhooks.length}`);
119
+
120
+ // Group webhooks by event type
121
+ const webhooksByEvent = webhooks.reduce((acc, webhook) => {
122
+ webhook.events.forEach(event => {
123
+ if (!acc[event]) acc[event] = [];
124
+ acc[event].push(webhook);
125
+ });
126
+ return acc;
127
+ }, {});
128
+
129
+ console.log('Webhooks by event:');
130
+ Object.entries(webhooksByEvent).forEach(([event, eventWebhooks]) => {
131
+ console.log(` ${event}: ${eventWebhooks.length} webhooks`);
132
+ });
133
+
134
+ // Find webhooks with high failure rates
135
+ const failingWebhooks = webhooks.filter(webhook =>
136
+ webhook.statistics && webhook.statistics.successRate < 90
137
+ );
138
+ console.log(`Webhooks with high failure rate: ${failingWebhooks.length}`);
139
+
140
+ // Create webhook dropdown options
141
+ const webhookOptions = webhooks.map(webhook => ({
142
+ value: webhook.webhookID,
143
+ label: webhook.name,
144
+ url: webhook.url,
145
+ active: webhook.isActive
146
+ }));
147
+ ```
148
+
149
+ **Common Webhook Events:**
150
+ - `content.created`: New content item created
151
+ - `content.updated`: Content item updated
152
+ - `content.deleted`: Content item deleted
153
+ - `content.published`: Content item published
154
+ - `content.unpublished`: Content item unpublished
155
+ - `page.created`: New page created
156
+ - `page.updated`: Page updated
157
+ - `page.deleted`: Page deleted
158
+ - `page.published`: Page published
159
+ - `page.unpublished`: Page unpublished
160
+ - `model.created`: Content model created
161
+ - `model.updated`: Content model updated
162
+ - `asset.uploaded`: Asset uploaded
163
+ - `asset.updated`: Asset updated
164
+
165
+ **Error Handling:**
166
+ - Throws `Exception` when retrieval fails
167
+
168
+ ### saveWebhook
169
+
170
+ Creates a new webhook or updates an existing one.
171
+
172
+ | Parameter | Type | Required | Description |
173
+ |-----------|------|----------|-------------|
174
+ | `webhook` | `Webhook` | Yes | Webhook object to save |
175
+ | `guid` | `string` | Yes | Current website GUID |
176
+
177
+ **Returns:** `Webhook` - Saved webhook object with updated metadata
178
+
179
+ **Usage Example:**
180
+ ```typescript
181
+ // Create a new webhook
182
+ const newWebhook = {
183
+ name: 'Content Update Notification',
184
+ url: 'https://api.example.com/webhooks/agility-content',
185
+ events: [
186
+ 'content.created',
187
+ 'content.updated',
188
+ 'content.published'
189
+ ],
190
+ isActive: true,
191
+ method: 'POST',
192
+ contentType: 'application/json',
193
+ timeout: 30000,
194
+ retryCount: 3,
195
+ authentication: {
196
+ type: 'header',
197
+ headers: {
198
+ 'Authorization': 'Bearer your-api-token',
199
+ 'X-API-Key': 'your-api-key'
200
+ }
201
+ }
202
+ };
203
+
204
+ const savedWebhook = await apiClient.webhookMethods.saveWebhook(newWebhook, guid);
205
+ console.log('Webhook created with ID:', savedWebhook.webhookID);
206
+
207
+ // Update existing webhook
208
+ const existingWebhook = await apiClient.webhookMethods.getWebhook(123, guid);
209
+ existingWebhook.name = 'Updated Webhook Name';
210
+ existingWebhook.url = 'https://api.example.com/webhooks/updated-endpoint';
211
+ existingWebhook.events.push('page.published');
212
+
213
+ const updatedWebhook = await apiClient.webhookMethods.saveWebhook(existingWebhook, guid);
214
+ console.log('Webhook updated:', updatedWebhook.name);
215
+
216
+ // Create webhook with custom payload template
217
+ const customWebhook = {
218
+ name: 'Custom Payload Webhook',
219
+ url: 'https://api.example.com/webhooks/custom',
220
+ events: ['content.published'],
221
+ isActive: true,
222
+ method: 'POST',
223
+ contentType: 'application/json',
224
+ timeout: 15000,
225
+ retryCount: 2,
226
+ payloadTemplate: {
227
+ eventType: '{{event}}',
228
+ timestamp: '{{timestamp}}',
229
+ contentData: {
230
+ id: '{{content.id}}',
231
+ title: '{{content.title}}',
232
+ referenceName: '{{content.referenceName}}'
233
+ },
234
+ customField: 'custom value'
235
+ }
236
+ };
237
+
238
+ // Create webhook with signature verification
239
+ const secureWebhook = {
240
+ name: 'Secure Webhook',
241
+ url: 'https://api.example.com/webhooks/secure',
242
+ events: ['content.created', 'content.updated'],
243
+ isActive: true,
244
+ method: 'POST',
245
+ contentType: 'application/json',
246
+ timeout: 30000,
247
+ retryCount: 3,
248
+ authentication: {
249
+ type: 'signature',
250
+ secret: 'your-webhook-secret',
251
+ algorithm: 'sha256',
252
+ headerName: 'X-Agility-Signature'
253
+ }
254
+ };
255
+
256
+ // Bulk webhook operations
257
+ const createContentWebhooks = async (endpoints) => {
258
+ const webhooks = [];
259
+ for (const endpoint of endpoints) {
260
+ const webhook = {
261
+ name: `Content Webhook - ${endpoint.name}`,
262
+ url: endpoint.url,
263
+ events: ['content.created', 'content.updated', 'content.published'],
264
+ isActive: true,
265
+ method: 'POST',
266
+ contentType: 'application/json',
267
+ timeout: 30000,
268
+ retryCount: 3
269
+ };
270
+
271
+ const saved = await apiClient.webhookMethods.saveWebhook(webhook, guid);
272
+ webhooks.push(saved);
273
+ }
274
+ return webhooks;
275
+ };
276
+ ```
277
+
278
+ **Webhook Structure:**
279
+ ```typescript
280
+ interface Webhook {
281
+ webhookID?: number; // Auto-generated for new webhooks
282
+ name: string; // Human-readable name (required)
283
+ url: string; // Target URL (required)
284
+ events: string[]; // Array of event types (required)
285
+ isActive: boolean; // Whether webhook is active
286
+ method: string; // HTTP method (GET, POST, PUT, etc.)
287
+ contentType: string; // Content type for payload
288
+ timeout: number; // Request timeout in milliseconds
289
+ retryCount: number; // Number of retry attempts
290
+ authentication?: WebhookAuth; // Authentication configuration
291
+ payloadTemplate?: any; // Custom payload template
292
+ statistics?: WebhookStats; // Delivery statistics (read-only)
293
+ createdDate?: string; // Auto-generated
294
+ lastTriggered?: string; // Auto-generated
295
+ }
296
+
297
+ interface WebhookAuth {
298
+ type: string; // 'header', 'signature', 'basic', etc.
299
+ headers?: { [key: string]: string }; // Custom headers
300
+ secret?: string; // Secret for signature authentication
301
+ algorithm?: string; // Algorithm for signature (sha256, etc.)
302
+ headerName?: string; // Header name for signature
303
+ }
304
+
305
+ interface WebhookStats {
306
+ totalDeliveries: number; // Total delivery attempts
307
+ successfulDeliveries: number; // Successful deliveries
308
+ failedDeliveries: number; // Failed deliveries
309
+ successRate: number; // Success rate percentage
310
+ lastDeliveryDate: string; // Last delivery attempt date
311
+ lastSuccessDate: string; // Last successful delivery date
312
+ }
313
+ ```
314
+
315
+ **Authentication Types:**
316
+ - `header`: Custom headers for authentication
317
+ - `signature`: HMAC signature verification
318
+ - `basic`: Basic authentication
319
+ - `bearer`: Bearer token authentication
320
+ - `custom`: Custom authentication scheme
321
+
322
+ **Error Handling:**
323
+ - Throws `Exception` when validation fails (invalid URL, unsupported events, etc.)
324
+ - Throws `Exception` when save operation fails
325
+ - Throws `Exception` when authentication configuration is invalid
326
+
327
+ ### deleteWebhook
328
+
329
+ Deletes a webhook by its ID.
330
+
331
+ | Parameter | Type | Required | Description |
332
+ |-----------|------|----------|-------------|
333
+ | `webhookID` | `number` | Yes | The webhook ID to delete |
334
+ | `guid` | `string` | Yes | Current website GUID |
335
+
336
+ **Returns:** `string` - Confirmation message of successful deletion
337
+
338
+ **Usage Example:**
339
+ ```typescript
340
+ try {
341
+ const result = await apiClient.webhookMethods.deleteWebhook(123, guid);
342
+ console.log(result); // "Webhook deleted successfully"
343
+ } catch (error) {
344
+ console.error('Failed to delete webhook:', error.message);
345
+ }
346
+
347
+ // Safe webhook deletion with confirmation
348
+ const safeDeleteWebhook = async (webhookID) => {
349
+ try {
350
+ // Get webhook details first
351
+ const webhook = await apiClient.webhookMethods.getWebhook(webhookID, guid);
352
+ console.log(`About to delete webhook: ${webhook.name}`);
353
+ console.log(`URL: ${webhook.url}`);
354
+ console.log(`Events: ${webhook.events.join(', ')}`);
355
+
356
+ // Check if webhook is active
357
+ if (webhook.isActive) {
358
+ console.log('Warning: Deleting active webhook');
359
+ }
360
+
361
+ // Perform deletion
362
+ const result = await apiClient.webhookMethods.deleteWebhook(webhookID, guid);
363
+ console.log('Webhook deleted successfully');
364
+ return result;
365
+ } catch (error) {
366
+ console.error('Failed to delete webhook:', error.message);
367
+ throw error;
368
+ }
369
+ };
370
+
371
+ // Bulk cleanup of inactive webhooks
372
+ const cleanupInactiveWebhooks = async () => {
373
+ const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
374
+ const inactiveWebhooks = webhooks.filter(w => !w.isActive);
375
+
376
+ console.log(`Found ${inactiveWebhooks.length} inactive webhooks`);
377
+
378
+ for (const webhook of inactiveWebhooks) {
379
+ const shouldDelete = confirm(
380
+ `Delete inactive webhook "${webhook.name}"? (${webhook.url})`
381
+ );
382
+
383
+ if (shouldDelete) {
384
+ await apiClient.webhookMethods.deleteWebhook(webhook.webhookID, guid);
385
+ console.log(`Deleted webhook: ${webhook.name}`);
386
+ }
387
+ }
388
+ };
389
+
390
+ // Delete webhooks with high failure rates
391
+ const cleanupFailingWebhooks = async (maxFailureRate = 50) => {
392
+ const webhooks = await apiClient.webhookMethods.getWebhookList(guid);
393
+
394
+ const failingWebhooks = webhooks.filter(webhook =>
395
+ webhook.statistics &&
396
+ webhook.statistics.successRate < maxFailureRate &&
397
+ webhook.statistics.totalDeliveries > 10 // Only consider webhooks with sufficient data
398
+ );
399
+
400
+ console.log(`Found ${failingWebhooks.length} webhooks with high failure rate`);
401
+
402
+ for (const webhook of failingWebhooks) {
403
+ console.log(`Webhook "${webhook.name}" has ${webhook.statistics.successRate}% success rate`);
404
+
405
+ const shouldDelete = confirm(
406
+ `Delete failing webhook "${webhook.name}"? (Success rate: ${webhook.statistics.successRate}%)`
407
+ );
408
+
409
+ if (shouldDelete) {
410
+ await apiClient.webhookMethods.deleteWebhook(webhook.webhookID, guid);
411
+ console.log(`Deleted failing webhook: ${webhook.name}`);
412
+ }
413
+ }
414
+ };
415
+ ```
416
+
417
+ **Deletion Considerations:**
418
+ - Deleting a webhook immediately stops all future event deliveries
419
+ - Pending webhook deliveries may still be processed
420
+ - Webhook statistics and history are permanently lost
421
+ - Consider deactivating instead of deleting for temporary suspension
422
+
423
+ **Best Practices:**
424
+ - Test webhook endpoints before creating webhooks
425
+ - Use appropriate authentication to secure webhook endpoints
426
+ - Monitor webhook statistics and success rates
427
+ - Implement proper error handling in webhook receivers
428
+ - Use webhook signatures to verify authenticity
429
+ - Set reasonable timeout values to avoid blocking
430
+ - Consider implementing idempotency in webhook receivers
431
+
432
+ **Error Handling:**
433
+ - Throws `Exception` when webhook not found
434
+ - Throws `Exception` when deletion fails
435
+ - Throws `Exception` when insufficient permissions to delete webhooks
436
+
437
+ ---
438
+
439
+ ## Navigation
440
+ - [← Back to Main Documentation](../README.md)
441
+ - [Authentication & Setup](./auth.md)
442
+ - [AssetMethods](./asset-methods.md)
443
+ - [BatchMethods](./batch-methods.md)
444
+ - [ContainerMethods](./container-methods.md)
445
+ - [ContentMethods](./content-methods.md)
446
+ - [InstanceMethods](./instance-methods.md)
447
+ - [InstanceUserMethods](./instance-user-methods.md)
448
+ - [ModelMethods](./model-methods.md)
449
+ - [PageMethods](./page-methods.md)
450
+ - [ServerUserMethods](./server-user-methods.md)
451
+ - [ServerUserMethods](./server-user-methods.md)
452
452
  - **WebhookMethods** *(current)*