Skip to main content
Browse Documentation
HTTP - Management

Create a webhook subscription

Created by c.neale, last modified by t.broome on 15 Oct 2021

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

NameParameter typeTypeDescriptionExampleRequired
projectIdpathstringThe project identifier found in the project overview screen of the management consolemovieDbtrue

Example

Create a new webhook subscription for a specific project

POST: /api/management/projects/movies/events/webhooks/subscriptions/

{
    "name": "name",
    "description": "some description",
    // Urls can be templated
    "url": "https://external.mywebsite.com/handlewebhooks/{/resource/sys.id}",
    "enabled": true,
    "method": "POST",
    "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": {
			"value": "********",
            "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": "{\n\"event\": \"{/event/name}\",\n\"user\": \"{/user/firstname} {/user/lastname}\",\n\"id\": \"{/resource/sys/id}\",\n\"title\": \"{/resource/entryTitle}\",\n\"description\": \"{/resource/entryDescription}\",\n\"department\": \"{/resource/department}\"}",
 
 
        // A news specific template
        "entry.news": "{\n\"event\": \"{/event/name}\",\n\"id\": \"{/resource/sys/id}\",\n\"title\": \"{/resource/entryTitle}\",\n\"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
    }
}

Responses

HTTP status codeReasonModel
201CreatedWebhook Subscription
400An invalid payload was sent in the requestError
500Internal server errorError
Necessary Cookies
These cookies are necessary for this website to function correctly. They are set when you perform certain actions on the site, such as creating an account, logging in, changing your privacy preferences or submitting a form. You can block these cookies in your browser, but this will stop parts of the site from working properly.
Functional Cookies
These cookies allow the website to provide extra functionality and more personalised experiences. They may be set by us or by third party providers whose services we have added to our pages. If you choose not to allow these cookies, these services may not work correctly.
Analytical Cookies
These cookies record anonymous data on how visitors use our website to help us monitor how well our website works. This data includes how many people have looked at specific pages, how long visitors stay on the site, and what devices they use. We use this data to identify changes that we could make to improve your experience and make our website more efficient.
Marketing Cookies
We set some cookies so you are shown more relevant marketing content. These include cookies from third-party advertising networks to show you different adverts on their services if you have previously visited our site. If you choose not to allow these cookies, you may experience less relevant advertising on other sites.