Skip to main content

Adding a Custom HTML Widget

1

Open the Widget Menu

In the Edit Mode tab of the Dashboards Building Interface, click the “add a widget” button.
2

Select the Custom HTML Widget

Choose the Custom HTML option from the widget list.
3

Rename the Widget

In the sidebar in the top left corner, double-click on Untitled widget and provide a name for the selected widget.
4

Add HTML Content

Enter your HTML content (including <script> and <styles> tag). The HTML you add will automatically appear in the HTML widget. Select the icon in the top-right corner of the custom HTML widget to view it in full screen.
Note:The HTML widget supports both static and dynamic HTML
If your HTML widget makes HTTP requests, see the next section, Making HTTP Requests in the Custom HTML Widget, to learn how it works.
When exporting an HTML widget that contains dynamic content (such as animations, delayed rendering, or asynchronously loaded elements), add the following code to your script once all content has fully loaded and finished rendering:parent.postMessage('html-widget:ready', '*');This signals that the widget is ready to be captured, helping ensure the exported screenshot includes the fully rendered content.

Making HTTP Requests in the Custom HTML Widget

The Custom HTML Widget lets you make HTTP requests directly from your dashboard, either to Blink’s APIs or to third-party vendor APIs. For example, you can add a button that fetches data from a vendor and displays the response inside the widget.
Note: To make HTTP requests, you must follow the configuration and syntax rules described below. Requests that don’t follow this exact format are ignored.
What’s Always Required and What Varies The exact configuration and syntax of your request varies depending on the HTTP request you want to send: the vendor, the api, the endpoint, and the method all determine which fields you need. Some parts, however, are the same for every request. Always required, for every request:
  • Preview mode: requests only run when the dashboard is in Preview mode.
  • A request message sent with window.parent.postMessage(), with:
    • type: 'html-widget:execute'
    • a unique requestId
    • a payload containing url and method
  • A message listener that checks for type: 'html-widget:execute-result' and the matching requestId, and handles both success and failure.
Varies by request (optional):
  • connection: when the request needs to authenticate through one of your workspace connections, for example, to call a vendor’s API or Blink’s API. The connection must also be selected in the widget’s ‘Allowed Connections’ field. Requests to APIs that don’t need authentication can leave it out.
  • Query parameters: when the endpoint accepts query parameters, such as filters, sorting, or paging, add them to the end of the url, for example ?sort=updated&per_page=10. There’s no separate field for query parameters.
  • headers: when the endpoint expects extra headers, such as a specific Accept or Content-Type value.
  • body: when the method sends data, typically POST, PUT, or PATCH. Always pass it as a JSON string.
To know which optional fields a request needs and what values they take, check the API documentation for the vendor and endpoint you are calling. How It Works
  1. Your widget sends a request message to Blink using window.parent.postMessage(), with the type html-widget:execute.
  2. Blink executes the HTTP request. If the request includes a connection, Blink uses that connection to authenticate.
  3. Blink sends the result back to your widget as a message with the type html-widget:execute-result.
  4. Your widget listens for that message, matches it to the original request using the requestId, and displays the result.
Important to Note:
  • HTTP requests only run in Preview mode. They don’t run in Edit Mode, so switch to Preview to test your widget’s requests.
  • Any user with the dashboard:view or dashboard:edit permission can trigger the widget’s HTTP requests. Requests that include a connection run through that connection.
If your request uses a connection, complete the following steps. Requests that don’t use a connection, such as calls to public APIs that don’t require authentication, can skip these steps and leave connection out of the payload.
1

Create a Connection

Create a connection for the vendor you want to call (for example, GitHub) in your workspace. The connection provides the authentication for every request made through it.
2

Select the Connection in the Widget

In the widget’s sidebar, below HTML Content, open the Allowed Connections dropdown and select the connection you want the widget to use. You can search for a connection, and select more than one if your widget calls several vendors.
Important: Whenever a request includes a connection, that connection must be selected in the Allowed Connections field. A widget can only use connections that are selected here, so requests that reference an unselected connection fail.
3

Reference the Connection in Your HTML

In your script, set the connection key value of the request payload to the connection’s name, for example, connection: 'my_blink_connection'.To find the name to use, hover over the connection in the Allowed Connections field. The tooltip shows the connection name. Always use the name from the tooltip, not the display name shown in the dropdown. For example, My Blink Connection is referenced as my_blink_connection. Copy it exactly as it appears in the tooltip.
Note: Selecting a connection in the Allowed Connections field authorizes the widget to use it. Only selected connections can be used in your HTML, so if a connection isn’t selected, any request that references its name fails.
Important: If a connection is renamed or deleted, the widget’s requests stop working. If it’s renamed, update the connection value in your HTML to the new name from the tooltip. If it’s deleted, select another connection in the Allowed Connections field and update the connection value to its name.

Sending a Request

To send a request, call window.parent.postMessage() with a request message:

Request Message Fields

The second argument of postMessage(), the target origin, must be '*'.

Payload Fields

Note: Query parameters are passed in the url, not as a separate payload field. If a value contains spaces or special characters, encode it with encodeURIComponent(), for example '?q=' + encodeURIComponent('status = "open"').

Examples by Request Type

The required fields are the same in every request. What changes is the method and the optional fields the endpoint needs.
A GET request with only the required fields:
Note: In your widget, store the requestId in a variable before sending the request (as in the full example), so your listener can match the result to it.

Making Requests to Blink’s APIs

You can also use the widget to call Blink’s REST API, for example, to read records from a table or to run a workflow. Requests to Blink’s APIs follow the same rules as any other request, with these specifics:
  • Connection: you need a Blink connection, selected in the widget’s Allowed Connections field. As with any connection, reference it by the name in its tooltip. For example, My Blink Connection is referenced as my_blink_connection.
  • URL: use your Blink environment’s API address followed by the endpoint path, in the format https://<your-blink-domain>/api/v1/<endpoint-path>. The default domain is app.blinkops.com. It must match the API address configured in your Blink connection.
  • IDs: endpoints usually include IDs, such as your workspace ID, a table name, or a workflow ID. See the API reference for each endpoint’s path, parameters, and body.
The following example shows a widget that reads records from a Blink table, with My Blink Connection selected in the widget’s Allowed Connections field and referenced in the HTML as my_blink_connection:
Lists records from a table, using the q query parameter in the URL to filter them with RQL. The RQL query is encoded with encodeURIComponent() because it can contain spaces and special characters. See List Records from Table.
Tip: To try a Blink API request, use the full example and replace its payload with one of the payloads above.

Receiving the Response

To receive the result, add a message event listener to the window:
The widget can receive messages from other sources too, so the listener’s first line is required: it ignores any message whose type isn’t 'html-widget:execute-result', or whose requestId doesn’t match the request you’re waiting for.

Result Message Fields

Syntax Rules

Follow these rules in every widget that makes HTTP requests:
  • Send requests with window.parent.postMessage(). This is how the widget passes the request to Blink to run, through your connection if the request includes one.
  • Use the exact message types. Send requests with type: 'html-widget:execute' and listen for type: 'html-widget:execute-result'.
  • Generate a new requestId for every request. Reusing an ID makes it impossible to tell which result belongs to which request.
  • Register the message listener before sending a request, so the widget is ready when the result arrives.
  • Always check both type and requestId at the start of your listener, and ignore any message that doesn’t match.
  • Handle both outcomes. Check msg.success, and display msg.data on success or msg.error on failure.
  • Pass body as a JSON string. Wrap it in single quotes, with double quotes inside, for example '{"key": "value"}'.
  • Never put credentials in your HTML. If the API requires authentication, use a connection instead.
Tip: To prevent duplicate requests, disable the button that triggers the request while it’s pending, and re-enable it when the result arrives, as shown in the example below.

Full Example

The following widget displays an Execute Request button. When clicked, it calls the GitHub API through the my_github_connection connection, shows the request status, and displays the response or error.

How the Example Works

To adapt the example, change the payload values: set connection to your connection’s name (or remove it if the request doesn’t need a connection), url to the endpoint you want to call, and method to the HTTP method the endpoint expects.

Troubleshooting

Tip: If you use an AI assistant to generate your widget’s HTML, include the rules on this page in your prompt, so the generated code uses the correct message format.

Editing a HTML Widget

Any changes made to the HTML, will be automatically applied to the HTML widget in real time.

Deleting a HTML Widget

1

Select the HTML Widget

In the left-hand sidebar, click the icon in the top-right corner and then select the delete button.

2

Delete the HTML Widget

The HTML widget will be removed from your Dashboard Building Interface.

Duplicate Widget

1

Select the HTML Widget

In the left-hand sidebar, click the icon in the top-right corner and then select the duplicate button.

2

Duplicate the HTML Widget

The HTML widget will be duplicated