Developers

Webhook transactions

Introduction

You can configure your Inbenta Knowledge module to send a POST request to an external service every time a specific change is made to your Knowledge Base. Contents and categories can be created, edited, moved or deleted using the Editor API or the Content Editor in a Knowledge instance.

Imagine you want to implement real-time change notifications using webhook events to trigger downstream services. To that end, you can configure a webhook to automatically send a POST request to the appropriate endpoint every time a content or category is created, updated, deleted, moved or (de)activated. The request payload will contain the changed attributes as well as the original content/category's state.

You configure the events that trigger the webhook in the Settings > General Settings screen of your Knowledge module. For more information on this configuration, see Configuring webhook triggers in the Help Center.

Payloads

Each time an action triggers a webhook request, the target URL configured in Settings > General Settings will receive a POST request. Below, you can find the payload structure that will be sent to the webhook for each type of action that triggers it (with application/json encoding).

Content editing

If the edit_content event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger"*: "edit_content",
  "date"*: date, // in ISO format, 
  "contentId"*: int, // ,
  "contentData"*: {
    "title": string, // cannot be deleted
    "categories": array, // cannot be deleted, the content will always have at least 1 category
    "isActive": boolean, // cannot be deleted
    "isPushContent": bool, // cannot be deleted
    "isConsiderForPopularContents": bool, // cannot be deleted
    "relatedContents": array, // ids of the related contents; if all related contents are deleted, an empty array will be sent [];  when one or more related contents are added or deleted, the whole array of related contents is sent, updated to include any new additions and exclude any deletions
    "decisionTree": { // to delete a decisionTree, set this to null
      "text": string,
      "children": [ // if all children are deleted, an empty array will be sent [];  when one or more children are added or deleted, the whole array is sent, updated to include any new additions and exclude any deletions
        {
          "contentId": int,
          "text": string
        }
      ]
    },
    "attributes": {
      "id": integer, 
      "name": string, 
      "objects": [ // when all of an attribute's are deleted, an empty array is sent [];  when one or more objects are added or deleted, the whole array of existing objects is sent, updated to include any new additions and exclude any deletions
          { 
              "id": integer, 
              "value": string,
              "creationDate": date //in ISO format 
              "createdBy": string, // name of the creator
              "modificationDate": date //in ISO format, 
              "modifiedBy": string, // name of the user who made the modification
              "useDefault": boolean, 
              "notShown": boolean, 
          } 
      ],
    },
    "publicationDate": date // in ISO format; NULL when a publication date is deleted
    "expirationDate": date // in ISO format; NULL when an expiration date is deleted
    "creationDate": date, // in ISO format
    "createdBy": string, // name of the content creator
    "modificationDate": date, // in ISO format; the date the webhook was triggered
    "modifiedBy": string, // name of the user who modified the content
    "userTypes": [
      "id": int, // user type id
      "name": string, // user type name
      "isActive": boolean,
      "attributes": 
      "publicationDate": date // in ISO format NULL when a publication date is deleted
      "expirationDate": date // in ISO format; NULL when an expiration date is deleted
      "relatedContents": array, // ds of the related contents; if all related contents are deleted, an empty array will be sent [];  when one or more related contents are added or deleted, the whole array of related contents is sent, updated to include any new additions and exclude any deletions
    ],
  },
  "contentPreviousData" :{
    ...
  }
}

Content creation

If the create_content event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "create_content",
  "date": date, // in ISO format,
  "contentId": ,
  "contentData": {
    ...
  }
}

       

Content activation/deactivation

If the change_content_status event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "change_content_status",
  "date": date, // in ISO format,
  "contentId": ,
  "contentData": {
    "isActive": boolean
  }
  "contentPreviousData" : {
    "isActive": boolean
  }
}
       

Content removal

If the delete_content event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "delete_content",
  "date": date, // in ISO format,
  "contentId": 
}
       

Category creation

If the create_category event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "create_category",
  "date": date, // in ISO format,
  "categoryId": 
  "categoryData": {
    "name": string,
    "parent": int // category parent Id, if applicable
    "order": int
  }
}
       

Category editing

If the edit_category event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "edit_category",
  "date": date, // in ISO format,
  "categoryId": 
  "categoryData": {
    "name": string,
  }
  "categoryPreviousData": {
      "name": string,
      "parent": integer,
      "order": integer
  }
}
       

Category removal

If the remove_category event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "remove_category",
  "date": date, // in ISO format,
  "categoryId": 
}      

Category tree change

If the moving_category_tree_item event is configured to trigger a webhook, the webhook receives the following information:

{
  "trigger": "moving_category_tree",
  "itemMovedType": "category"|"content",
  "id": int, // id of the moved category or content
  "categoryParentFrom": int // the id of the parent category the category was moved from
  "categoryParentTo": int // the id of the parent category the category was moved to
  "order": int, // new order number inside the current category
}