Developers

Webhook upon saving

Introduction

You can configure your Inbenta Knowledge module to send a POST request to an external service every time a content is published to “Editing”. Contents can be published to “Editing” using the Editor API or the Content Editor in a Knowledge instance.

A possible use case for using a webhook with the Editor API is to have the webhook trigger an automatic translation of contents whenever they are published to “Editing”.

Imagine you want to automatically call an external API to machine translate contents as soon as they are saved. To that end, you can configure a webhook to automatically send a POST request to the appropriate API endpoint every time a content is published to the Knowledge Base. The request payload will contain the content attributes defined in the saved content.

You configure this type of webhook in the Settings > General Settings screen of your Knowledge module. For more information on this configuration, see Executing a webhook upon creating or editing contents in the Help Center.

Payloads

Each time a content is published to “Editing”, Inbenta Knowledge will send a POST request to the target URL configured in Settings > General Settings. Such POST requests always have the following payload structure (with application/json encoding):

{ 
     "action": string ["add", "edit"],
     "date": timestamp, 
     "content": { 
         "id": integer, 
         "title": string, 
         "userTypes": {
             "Default": { 
                 attributeName: attributeValue // string or array if multiple 
             }, 
             userTypeName: { 
                 attributeName: attributeValue 
             }, 
         }, 
         "categories": { 
             categoryId: categoryName 
         } 
    }, 
    "currentContent": { 
       "id": integer, 
       "status": integer [1, 2], 
       "title": string, 
       "categories": [integer], 
       "userTypes": [ 
           { 
               "id": integer, 
               "name": string, 
               "active": boolean, 
               "attributes": [ 
                   { 
                        "id": integer, 
                        "name": string, 
                        "objects": [ 
                            { 
                                "id": integer, 
                                "value": string, 
                                "creationDate": date //in ISO format 
                                "createdBy": string, 
                                "modificationDate": date //in ISO format, 
                                "modifiedBy": string, 
                                "useDefault": boolean, 
                                "notShown": boolean, 
                            } 
                        ] 
                   } 
               ], 
               "publicationDate": date // in ISO format, 
               "expirationDate": date // in ISO format 
          }, 
       ], 
       "useForPopular": boolean, 
       "creationDate": date,// in ISO format 
       "createdBy": string, 
       "modificationDate": date, // in ISO format 
       "modifiedBy": string, 
    }, 
    "previousContent": [], // same format as currentContent. Empty when content is new 
}