> For the complete documentation index, see [llms.txt](https://docs.blynk.io/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blynk.io/en/html-widget-developer-guide/user-and-organization.md).

# User & Organization

### Check a permission

> Tells whether the current user holds a permission, so you can hide or disable controls they can't use.

```js
bridge.isPermissionAllowed(permission)  // → Promise<boolean>
```

**Parameters**

| Name         | Type     | Required | Description                            |
| ------------ | -------- | -------- | -------------------------------------- |
| `permission` | `string` | yes      | One of the names below. Case-sensitive |

| Permission             | Scope        | Web | Mobile | Gates                                  |
| ---------------------- | ------------ | --- | ------ | -------------------------------------- |
| `VIEW_EVENTS`          | Bound device | ✅   | ✅      | Events, `openDeviceEvents`             |
| `EDIT_EVENTS`          | Bound device | ✅   | ✅      | Comment, resolve, archive, notes       |
| `QUERY_DATA_ENGINE`    | Organization | ✅   | ✅      | `executeDataEngineQuery`               |
| `VIEW_DEVICE_INFO`     | Bound device | ✅   | ✅      | `openDeviceInfo`                       |
| `VIEW_AUTOMATIONS`     | Organization | ✅   | ✅      | `openAutomations`                      |
| `VIEW_DEVICE_TAGS`     | Bound device | ✅   | ✅      | `getDeviceTags`                        |
| `VIEW_DEVICE_FILES`    | Bound device | ✅   | ✅      | Device file lists and content          |
| `EDIT_DEVICE_FILES`    | Bound device | ✅   | ✅      | `uploadDeviceFile`, `deleteDeviceFile` |
| `VIEW_ASSETS`          | Organization | ✅   | ✅      | Assets                                 |
| `CONTROL_DEVICE`       | Bound device | ❌   | ✅      | Writing datastream values              |
| `EDIT_DEVICE_METADATA` | Bound device | ❌   | ✅      | `updateDeviceMetadata`                 |

**Resolves with** `true` or `false`.

**Rejects with** `invalid_request` for a name the host doesn't accept — on web that includes `CONTROL_DEVICE` and `EDIT_DEVICE_METADATA` — `request_timeout` (web, 10 seconds), and `device_unavailable` when the host has no permission bridge. Never let a failed check hard-block your UI:

```js
const may = (permission, fallback = true) =>
  bridge.isPermissionAllowed(permission).catch(() => fallback);

const canControl = await may('CONTROL_DEVICE');   // true on web, the real answer on mobile
```

A permission check is a UI hint. The server stays authoritative for every read and write.

***

### Get unit systems

> Returns the unit systems chosen by the organization and the user.

```js
bridge.getUnitSystems()  // → Promise<{ orgUnitSystem, userUnitSystem }>
```

**Parameters:** none.

**Resolves with**

| Field            | Type             | Description                                                                       |
| ---------------- | ---------------- | --------------------------------------------------------------------------------- |
| `orgUnitSystem`  | `string \| null` | `'METRIC'` or `'IMPERIAL'`; `null` when the organization never set one            |
| `userUnitSystem` | `string \| null` | `'METRIC'` or `'IMPERIAL'`; `null` when the user follows the organization default |

**Rejects with** `request_timeout` (web, 10 seconds), `device_unavailable`, `bridge_destroyed`.

```js
const { orgUnitSystem, userUnitSystem } = await bridge.getUnitSystems();
const unitSystem = userUnitSystem ?? orgUnitSystem ?? 'METRIC';
```

Individual datastreams also carry their own `unitSystem` field.


---

# 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://docs.blynk.io/en/html-widget-developer-guide/user-and-organization.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.
