GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

optional_permissions

<table class="fullwidth-table standard-table"> <tbody> <tr> <th scope="row">Type</th> <td><code>Array</code></td> </tr> <tr> <th scope="row">Mandatory</th> <td>No</td> </tr> <tr> <th scope="row">Manifest version</th> <td>2 or higher</td> </tr> <tr> <th scope="row">Example</th>

<table class="fullwidth-table standard-table">
<tbody>
<tr>
<th scope="row">Type</th>
<td><code>Array</code></td>
</tr>
<tr>
<th scope="row">Mandatory</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Manifest version</th>
<td>2 or higher</td>
</tr>
<tr>
<th scope="row">Example</th>
<td>
<pre class="brush: json">
"optional_permissions": [
"webRequest"
]</pre>
</td>
</tr>
</tbody>
</table>

Use the `optional_permissions` key to list permissions you want to ask for at runtime, after your extension has been installed.

The [`permissions`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) key lists permissions that your extension needs before it can be installed. In contrast, `optional_permissions` lists permissions that your extension doesn't need at install time but can ask for after installation. To ask for a permission, use the permissions.request() API. Asking for a permission presents the user with a dialog requesting them to grant the permission to your extension, unless all the permissions requested are granted silently.

For advice on designing your request for runtime permissions, to maximize the likelihood that users grant them, see [Request permissions at runtime](https://extensionworkshop.com/documentation/develop/request-the-right-permissions/#request_permissions_at_runtime).

> [!NOTE]
> Users can [manage optional permissions from the Firefox Add-ons Manager](https://support.mozilla.org/en-US/kb/manage-optional-permissions-extensions). Extensions that use optional permissions can check for the permissions granted by the user with permissions.getAll() and listen for permissions.onAdded and permissions.onRemoved to know when a user grants or revokes permissions.

The key can contain host permissions and API permissions.

## Host permissions

These are the same as the host permissions you can specify in the [`permissions`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions) key.

> [!NOTE]
> When using Manifest V3 or higher, optional host permissions should be specified using the [`optional_host_permissions`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_host_permissions) manifest key. Firefox introduced `optional_host_permissions` in release 128, see [bug 1766026](https://bugzil.la/1766026), and allows the continued use of `optional_permissions` to specify optional hosts. Use of `optional_host_permissions`, however, is recommended.

## API permissions

The optional API permissions are:

- [`activeTab`](/docs/Mozilla/Add-ons/WebExtensions/activeTab_permission)
- `background`
- `bookmarks`
- `browserSettings`
- `browsingData`
- `clipboardRead`
- `clipboardWrite`
- `contentSettings`
- `contextMenus`
- `cookies`
- `debugger`
- `declarativeNetRequest`
- `declarativeNetRequestFeedback`
- `declarativeNetRequestWithHostAccess`
- `devtools`
- `downloads`
- `downloads.open`
- `find`
- `geolocation`
- `history`
- `idle`
- `management`
- `nativeMessaging`
- `notifications`
- `pageCapture`
- `pkcs11`
- `privacy`
- `proxy`
- `publicSuffix`
- `scripting`
- `search`
- `sessions`
- `tabHide`
- `tabGroups`
- `tabs`
- `topSites`
- `userScripts` ([optional-only](#optional-only_permissions))
- `webNavigation`
- `webRequest`
- `webRequestBlocking`
- `webRequestFilterResponse`
- `webRequestFilterResponse.serviceWorkerScript`

Check the compatibility table for browser-specific support details.

These optional permissions are granted silently, without a user prompt:

- `activeTab`
- `cookies`
- `idle`
- `publicSuffix`
- `tabGroups`
- `webRequest`
- `webRequestBlocking`
- `webRequestFilterResponse`
- `webRequestFilterResponse.serviceWorkerScript`

### Optional-only permissions

Optional permissions are generally available for use in the [`permissions`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#api_permissions) key, so they can be requested at install time. However, some browsers support the concept of optional-only permissions, permissions that can only be requested at runtime. For example, in Firefox, optional-only permissions can be granted by the user from the [extension's options page](/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages) or using permissions.request(). Optional-only permissions must be requested individually and alone through the permissions.request() API.

The optional-only API permissions are:

- `userScripts` (see [userScripts permission](/docs/Mozilla/Add-ons/WebExtensions/API/userScripts#permissions))

## Examples

```json
"optional_permissions": ["*://developer.mozilla.org/*"]
```

In Manifest V2 only, enable the extension to ask for privileged access to pages under developer.mozilla.org.

```json
"optional_permissions": ["tabs"]
```

Enable the extension to ask for access to the privileged pieces of the `tabs` API.

```json
"optional_permissions": ["*://developer.mozilla.org/*", "tabs"]
```

In Manifest V2 only, enable the extension to ask for both of the above permissions.

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"optional_permissions". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·