- Source:
A webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account. Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens. Read more about Webhooks.
Methods
(static) update() → {Promise.<Webhook.Webhook>}
- Source:
The Update Webhook call lets you update the name and description of an existing Webhook.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').fetch()
.then((webhook) => {
webhook.title = 'My New Webhook'
webhook.description = 'Webhook description'
return webhook.update()
})
.then((webhook) => console.log(webhook))
Returns:
Promise for Webhook instance
- Type
- Promise.<Webhook.Webhook>
(static) delete() → {Object}
- Source:
The Delete Webhook call is used to delete an existing Webhook permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
- Type
- Object
(static) fetch(version) → {Promise.<Webhook.Webhook>}
- Source:
The fetch Webhook call fetches Webhook details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').fetch()
.then((webhook) => console.log(webhook))
Parameters:
Name | Type | Description |
---|---|---|
version |
Int | Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. |
Returns:
Promise for Webhook instance
- Type
- Promise.<Webhook.Webhook>
(static) executions() → {Promise.<JSON.JSON>}
- Source:
The Get executions of a webhook call will provide the execution details of a specific webhook, which includes the execution UID.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').executions()
.then((webhook) => console.log(webhook))
Parameters:
Name | Type | Description |
---|---|---|
param.skip |
* | to skip number of data |
Returns:
JSON response for webhook execution
- Type
- Promise.<JSON.JSON>
retry(executionUid)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
executionUid |
String | execution UID that you receive when you execute the 'Get executions of webhooks' call. |
(static) create() → {Promise.<Webhook.Webhook>}
- Source:
The Create a webhook request allows you to create a new webhook in a specific stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const webhook = {
name: 'Test',
destinations: [{
target_url: 'http://example.com',
http_basic_auth: 'basic',
http_basic_password: 'test',
custom_header: [{
header_name: 'Custom',
value: 'testing'
}]
}],
channels: [
'assets.create'
],
retry_policy: 'manual',
disabled: false
}
client.stack().webhook().create({ webhook })
.then((webhook) => console.log(webhook))
Returns:
Promise for Webhook instance
- Type
- Promise.<Webhook.Webhook>
(static) fetchAll(limit, skip, asc, desc, include_count) → {ContentstackCollection}
- Source:
The Get all Webhook call lists all Webhooks from Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook().fetchAll()
.then((collection) => console.log(collection))
Parameters:
Name | Type | Description |
---|---|---|
limit |
Int | The limit parameter will return a specific number of webhooks in the output. |
skip |
Int | The skip parameter will skip a specific number of webhooks in the output. |
asc |
String | When fetching webhooks, you can sort them in the ascending order with respect to the value of a specific field in the response body. |
desc |
String | When fetching webhooks, you can sort them in the decending order with respect to the value of a specific field in the response body. |
include_count |
Boolean | To retrieve the count of webhooks. |
Returns:
Result collection of content of specified module.
- Type
- ContentstackCollection
(static) import()
- Source:
The 'Import Webhook' section consists of the following two requests that will help you to import new Webhooks or update existing ones by uploading JSON files.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const data = {
webhook: 'path/to/file.png',
}
// Import a Webhook
client.stack({ api_key: 'api_key'}).webhook().import(data)
.then((webhook) => console.log(webhook))
// Import an Existing Webhook
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').import(data)
.then((webhook) => console.log(webhook))
Parameters:
Name | Type | Description |
---|---|---|
data.webhook |
String | path to file |