Webhooks

Webhooks are a Pro feature of Castor that allow you to push data directly to Castor. It's a developer-friendly, advanced feature, that will help you integrate Castor with your existing backend.

Webhooks can simplify edition of widgets content, as you can edit just one particular line of a file using Edition Modes.

Webhook-compatibles widgets

Webhooks can be used to push data to the following widget types:

  • Text Widgets: set the text value
  • Custom Tables: set the content or remote content URL
  • Custom Charts: set the content or remote content URL
  • Custom Frame: set the frame URL

Get the Webhook URL

Each widget has its own webhook URL where data can be sent to. To get the the webhook URL for a specific widget, click on the webhook icon, next to the Edit button.

radio

Copy the webhook URL: that's the URL where you'll send JSON payloads.

Webhook Payload Specification

You must POST JSON payloads to your Webhook URL according to the following specification:

Attribute Description
(string) value (required) New value for target widget. Optional if mode = 'addline'
(string) type (optional) Value from list: text, frame, table or graph. If specified, the Castor API will check the webhooks aplies to the specified widget type. Use to avoid typing errors.
(string) mode (required) Edition mode, see Edition Modes.
(int) line (optional) Required if mode is either addline, editline or removeline. The line number to edit.

Edition Mode

The mode attribute is a required attribute in every webhook payload sent to Castor. It allows you to select how the widget content should be edited, and takes one of the following values:

  • Specific to local CSV content (Custom Tables and Charts):

    • addline: value will be inserted in the file at the line described by line.
      • Example: If mode = 'addline' and line = 2, the content from value will be the new line 2 and former line 2 will become line 3.
    • removeline: line described by line argument will be deleted from target widget content.
    • editline: line described by line argument will be replaced by value.
  • Available to every type of content

    • append: add value prior to existing content
    • prepend: add value after existing content
    • replace: replace old value with value.