> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
> Use this file to discover all available pages before exploring further.

# hasPermission

> Check whether the plugin already has a specific permission.

```ts theme={null}
hasPermission(permission: string): Promise<number>;
```

**Parameters**

| Parameter    | Type     | Description                                                                                                                                                     |
| ------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `permission` | `string` | Permission name. Supported values: `plugin.permission.FILE:READ`, `plugin.permission.FILE:WRITE`, `plugin.permission.FILE:DELETE`, `plugin.permission.INTERNET` |

<Note>
  Regarding file access permissions:

  1. The plugin has read, write, and delete access to its private directory by default: `/data/data/com.ratta.supernote.pluginhost/files/plugins/<pluginID>`.
  2. None of the read, write, or delete permissions are granted by default for the `Document`, `EXPORT`, `INBOX`, `MyStyle`, `Note`, and `SCREENSHOT` directories under shared storage (`sdcard`); each must be requested separately via `plugin.permission.FILE:READ`, `plugin.permission.FILE:WRITE`, and `plugin.permission.FILE:DELETE`. External SD cards, OTG storage, and other removable storage are likewise governed by these same permissions. Any other directory cannot be read, written, or deleted regardless of whether the corresponding permission is requested.
</Note>

**Returns**

* `Promise<number>`: returns the permission status, where `0` means the permission is not granted and cannot be used; `1` means the permission is granted and can be used

**Throws**

* Throws a parameter validation error when `permission` is not a non-empty string
* Throws an error when `permission` is not in the supported list (error code `1502`)

See [Plugin Permissions](/en/plugin-base/permission) for an overview of the permission system and which APIs depend on each permission.

## Example

```ts wrap theme={null}
import { PluginManager } from 'sn-plugin-lib';

/**
 * Example: check the write-file permission status.
 */
export async function exampleHasPermission() {
  const permission = 'plugin.permission.FILE:WRITE';
  const status = await PluginManager.hasPermission(permission);
  return status;
}
```
