> For the complete documentation index, see [llms.txt](https://dev.ubidots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ubidots.com/dashboards-and-widgets/html-canvas/built-in-library/methods.md).

# Methods

This page describes the available methods within the HTML Canvas class

## HTML Canvas methods

| Method                  | Description                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| `getHeaders`            | Returns the appropriate authentication headers for public or private dashboards.                      |
| `openDrawer`            | Embeds a URL in a drawer and displays it.                                                             |
| `setDashboardDevices`   | Changes the currently selected device or devices in single-device or multi-device dynamic dashboards. |
| `setDashboardDateRange` | Changes the selected time range in a dashboard.                                                       |
| `setRealTime`           | Turns the dashboard's real-time updates on or off.                                                    |
| `refreshDashboard`      | Refreshes dashboard data in all widgets.                                                              |
| `setDashboardLayer`     | Navigates to a different layer.                                                                       |

### `getHeaders` <a href="#getheaders" id="getheaders"></a>

**Arguments:** None

**Signature:** `ubidots.getHeaders()`

**Return:**

{% tabs %}
{% tab title="Public dashboard" %}

```json
{
  Authorization: "Bearer receivedJWTToken",
  Content-type: "application/json"
}
```

{% endtab %}

{% tab title="Private dashboard" %}

```json
{
  X-Auth-Token: "BBFF-xxyyzz",
  Content-type: "application/json"
}
```

{% endtab %}
{% endtabs %}

### `openDrawer` <a href="#opendrawer" id="opendrawer"></a>

**Arguments:** `options`: `Object` \[Mandatory] => An object containing the content's URL and the drawer's width in pixels:

```
{
    url: "https://url.com",
    width: 500 // Read as 500px
}
```

**Signature:**

```
ubidots.openDrawer(
    {
        url: "https://some-url",
        width: <width>
    }
);
```

**Return:** None

### `setDashboardDevices` <a href="#setdashboarddevice" id="setdashboarddevice"></a>

**Arguments:** `deviceIds`: `string` \[Mandatory] ⇒ Comma-separated string with the IDs of the devices you want to set.

```
"<device-1-id>,~<device-2-label>,<...>"
```

**Signature:** `ubidots.setDashboardDevices(<deviceIds>)`

**Return:** None

### `setDashboardDateRange` <a href="#setdashboarddaterange" id="setdashboarddaterange"></a>

**Arguments:** `timeframe`: `Object` \[Mandatory] => An object containing the start and end timestamps:

```
{
    "startTime": 1642282088000,
    "endTime": 1673818088000
}
```

**Signature:** `ubidots.setDashboardDateRange(<timeframe>)`

**Return:** None

### `setRealTime` <a href="#setrealtime" id="setrealtime"></a>

**Arguments:** `rt`: `Bool` \[Mandatory] => A boolean indicating whether real-time updates are enabled.

**Signature:** `ubidots.setRealTime(<rt>)`

**Return:** None

### `refreshDashboard` <a href="#refreshdashboard" id="refreshdashboard"></a>

**Arguments:** None

**Signature:** `ubidots.refreshDashboard()`

**Return:** None

### `setFullScreen` <a href="#setfullscreen" id="setfullscreen"></a>

**Arguments:** `screenSetting`: `string(toggle | enable | disabled)` \[Mandatory] => A string representing the full-screen setting.

**Signature:** `ubidots.setFullScreen(<screenSetting>)`

**Return:** None

### `setDashboardLayer` <a href="#setfullscreen" id="setfullscreen"></a>

**Arguments:**

* `layer`: `string` \[Mandatory] ⇒ layer ID or label.
  * Use ID as a plain string: `"6926000dcb198b4d10067b58"`
  * Use label prefixed with `~`: `"~Layer-2"`
* `queryParams`: `Object` \[Optional] ⇒ An object where each key/value pair will be added as a query param.
  * Allowed value types: `string | number | boolean`
  * Arrays are NOT allowed. If you need multiple values, pass a comma-separated string, e.g. `"id1,id2,id3"`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dev.ubidots.com/dashboards-and-widgets/html-canvas/built-in-library/methods.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
