HTTP - Management
Create A Webhook Subscription
Created by c.neale, last modified by zengenti on 27 Nov 2020
A webhook subscription resource can be created by POST'ing an Event Subscription Resource to the webhook subscriptions resource collection.
POST/api/management/projects/{projectId}/events/webhooks/subscriptions
Parameter
Name | Parameter type | Type | Description | Example | Required |
---|---|---|---|---|---|
projectId | path | string | The project identifier found in the project overview screen of the management console | movieDb | true |
Examples
Create a new webhook subscription for a specific project
POST: /api/management/projects/movies/events/webhooks/subscriptions/
{
"name": {
"en-GB": "name"
},
"description": {
"en-GB": "some description"
},
// Urls can be templated
"url": "https://external.mywebsite.com/handlewebhooks/{/resource/sys.id}",
"enabled": true,
"topics": [
{
"resourceType": "entry",
"event": ["updated", "created"],
"language": ["fr-fr"],
"contentTypeId": ["blog", "news"],
"owner": "t.durden"
},
{
"resourceType": "entry",
"event": ["published"],
"contentTypeId": ["news"],
"owner": "t.durden"
},
{
"resourceType": "contentType",
"event": ["created"]
},
{
"resourceType": "entry",
"event": ["workflowEventRaised"],
"contentTypeId": ["blog"],
"owner": "t.durden",
"workflowEvent" : ["contensisentrybasic.draft.submit", "contensisentryapproval.awaitingApproval.approve"]
},
{
"resourceType": "entry",
"event": ["workflowEventRaised"],
"contentTypeId": ["news"],
"owner": "t.durden",
"workflowEvent" : ["contensisentryapproval.awaitingApproval.declined"]
},
{
"resourceType": "entry",
"event": ["workflowStateChanged"],
"contentTypeId": ["blog"],
"owner": "t.durden",
"workflowState" : ["contensisentryapproval.awaitingApproval"]
}
],
"headers": {
"target": {
"value": "internal"
},
// Headers can be templated
"department": {
"value": "{/resource/department}"
},
// Headers can be specified as secret, which means that the value can be set but won't be returned
// Set
"secretHeaderSet": {
"secret": true,
"value": "cs7vdsdvj~8"
},
// Get
"secretHeaderGet": {
"secret": true
}
// NOTE: A header will not be returned if it has no value
},
"templates": {
// For entry events return a custom structure with specific pieces of data
"entry": {
"event": "{/event/name}",
"user": "{/user/firstname} {/user/lastname}",
"id": "{/resource/sys/id}",
"title": "{/resource/entryTitle}",
"description": "{/resource/entryDescription}",
"department": "{/resource/department}"
},
// A news specific template
"entry.news": {
"event": "{/event/name}",
"id": "{/resource/sys/id}",
"title": "{/resource/entryTitle}",
"headline": "{/resource/headline}"
},
// For content type events return the entire content type resource (root)
"contentType": "{/resource/}"
// For all other events if a template for a resource is not supplied then return the default webhook request structure
}
}
Example response
HTTP Status: 201 Created
{
"id": "3a7ce8e3-9c9f-4242-be20-35edb29c4a07",
"name": {
"en-GB": "name"
},
"description": {
"en-GB": "some description"
},
// Urls can be templated
"url": "https://external.mywebsite.com/handlewebhooks/{/resource/sys.id}",
"enabled": true,
"topics": [
{
"resourceType": "entry",
"event": ["updated", "created"],
"language": ["fr-fr"],
"contentTypeId": ["blog", "news"],
"owner": "t.durden"
},
{
"resourceType": "entry",
"event": ["published"],
"contentTypeId": ["news"],
"owner": "t.durden"
},
{
"resourceType": "contentType",
"event": ["created"]
},
{
"resourceType": "entry",
"event": ["workflowEventRaised"],
"contentTypeId": ["blog"],
"owner": "t.durden",
"workflowEvent" : ["contensisentrybasic.draft.submit", "contensisentryapproval.awaitingApproval.approve"]
},
{
"resourceType": "entry",
"event": ["workflowEventRaised"],
"contentTypeId": ["news"],
"owner": "t.durden",
"workflowEvent" : ["contensisentryapproval.awaitingApproval.declined"]
},
{
"resourceType": "entry",
"event": ["workflowStateChanged"],
"contentTypeId": ["blog"],
"owner": "t.durden",
"workflowState" : ["contensisentryapproval.awaitingApproval"]
}
],
"headers": {
"target": {
"value": "internal"
},
// Headers can be templated
"department": {
"value": "{/resource/department}"
},
// Headers can be specified as secret, which means that the value can be set but won't be returned
// Set
"secretHeaderSet": {
"secret": true,
"value": "cs7vdsdvj~8"
},
// Get
"secretHeaderGet": {
"secret": true
}
// NOTE: A header will not be returned if it has no value
},
"templates": {
// For entry events return a custom structure with specific pieces of data
"entry": {
"event": "{/event/name}",
"user": "{/user/firstname} {/user/lastname}",
"id": "{/resource/sys/id}",
"title": "{/resource/entryTitle}",
"description": "{/resource/entryDescription}",
"department": "{/resource/department}"
},
// A news specific template
"entry.news": {
"event": "{/event/name}",
"id": "{/resource/sys/id}",
"title": "{/resource/entryTitle}",
"headline": "{/resource/headline}"
},
// For content type events return the entire content type resource (root)
"contentType": "{/resource/}"
// For all other events if a template for a resource is not supplied then return the default webhook request structure
},
"version": {
"createdBy": "t.durden",
"created": "2020-09-01T08:59:49Z",
"modifiedBy": "m.singer",
"modified": "2020-09-05T08:59:49Z",
"versionNo": "1.0"
}
}
Responses
HTTP status code | Reason | Model |
---|---|---|
201 | Created | Webhook Subscription |
400 | An invalid payload was sent in the request | Error |
500 | Internal server error | Error |