HomeDev guideRecipesAPI ReferenceGraphQL
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Manage webhooks

Describes how to register, get, or delete webhooks.

Optimizely Graph provides some endpoints to allow customers to manage their webhooks by the specific account.

πŸ“˜

Note

You can check the API Reference page for information on managing webhooks.

Register a webhook with notification filters

Use a REST client tool, for example, Postman or Insomnia to send a register request through the URL: https://cg.optimizely.com/api/webhooks with the HMAC key (generated by the app key and secret key you received when your account was created) by POST method with the body:

{
  "disabled": false,
  "request" : {
    "url" : <your_webhook_url>,
    "method": "post"
  },
  "topic": ["{subject}.{action}"],
  "filters": [ 
    { 
      [field]: { [operator]: {value} } 
    } 
  ]
}

Disabled property

A boolean value indicates whether the webhook is disabled or not. If set to true, the webhook will not be triggered.

Request property

The request property is an object that represents the HTTP request made to the webhook. It typically includes information such as the request method (GET, POST, and so on), headers, query parameters, and body.

Topic property

List of strings that are used to filter out events with respect to event 'subject' and 'action'. The asterisk symbol (*) can be used as a wildcard to filter any value that matches with part of the event. When a wildcard is not been provided, it will work as no-filter or match-all way.

Value structure : {subject}.{action}

Examples:

  • Filter all events – topics: ["*.*"]
  • Filter all 'doc' events – topics: ["doc.*"]
  • Filter all 'updated' events – topics: ["*.updated"]
  • Filter 'doc updated' events – topics: ["doc.updated"]
  • Filter 'doc updated' or 'bulk completed' events – topics: ["doc.updated", "bulk.completed"]

Filters property

Filters property is optional. Applying filters allows you to receive the notifications you want.

The filters property is an optional object that contains key-value pairs. Each key represents a filter name, and the corresponding value is an array of partial filter objects. Each partial filter object contains properties specific to that filter.

Filters are in object structure where keys are selectors for events and values define operators.

Examples:

  • Filters docs which has 'Published' status:
 {
   "request" : {
      "url" : <your_webhook_url>,
      "method": "post"
   },
   "filters": [
     { "status": { "eq": "Published" } }
   ],
 }
  • Filters docs which have 'Published' or 'Draft' status:
{
   "request" : {
      "url" : <your_webhook_url>,
      "method": "post"
   },
   "filters": [
     { "status": { "eq": "Published" } },
     { "status": { "eq": "Draft" } }
   ],
}
  • Filters docs which has 'Published' status and id '123':
 {
   "request" : {
      "url" : <your_webhook_url>,
      "method": "post"
   },
   "filters": [
     {
       "status": { "eq": "Published" },
       "id": { "eq": "123" }
     }
   ]
 }

List all registered webhooks

Use the REST client tool to send a request through the URL: https://cg.optimizely.com/api/webhooks with HMAC key by GET method.

The result looks like:

[
  {
    "id": <guid>,
    "request" : {
      "url" : <your_webhook_url>,
      "method": "post"
    },
    "filters": [
      {
        "status": { "eq": "Published" }
      }
    ]
  }
]

Delete a registered webhook

Use a REST client tool to list all webhooks and get the ID of the webhook you want to delete.

Use the REST client tool again to send a request through the URL https://cg.optimizely.com/api/webhooks/{guid} with HMAC key by DELETE method ( is ID of registered webhook).