Scopes API
The Scopes API lets you manage your app's access scopes at runtime. You can query which scopes are currently granted, request additional optional scopes from the merchant (which opens a permission grant modal), and revoke optional scopes you no longer need.
To learn more about declaring and requesting access scopes, as well as required vs. optional scopes, refer to manage access scopes.
To learn more about declaring and requesting access scopes, as well as required vs. optional scopes, refer to manage access scopes.
Anchor to Use casesUse cases
- Scope management: Query, request, and revoke optional access scopes dynamically within your app.
- Progressive permissions: Request additional scopes only when a merchant needs specific features.
- Scope verification: Check which scopes are currently granted before making API calls that require them.
- Merchant consent: Trigger the merchant consent flow for optional scopes directly from your app UI.
Anchor to MethodsMethods
The scopes API is available on the shopify global. All methods are asynchronous and return a Promise.
- Anchor to queryqueryquery() => Promise<ScopesDetail>() => Promise<ScopesDetail>requiredrequired
Returns the current access scopes for this app on this shop, including which are granted, required, and optional.
- Anchor to requestrequestrequest(scopes: string[]) => Promise<ScopesRequestResponse>(scopes: string[]) => Promise<ScopesRequestResponse>requiredrequired
Opens a permission grant modal asking the merchant to grant the specified scopes.
The scopes must be access scope handles (for example,
or) that are declared as optional in your app configuration.See the permission grant modal documentation for more details.
- Anchor to revokerevokerevoke(scopes: string[]) => Promise<ScopesRevokeResponse>(scopes: string[]) => Promise<ScopesRevokeResponse>requiredrequired
Revokes the specified optional scopes from this app on this shop.
The scopes must be access scope handles (for example,
or) that are currently granted and declared as optional. Required scopes cannot be revoked.
ScopesDetail
- granted
The scopes currently granted to this app on this shop. This includes both required and optional scopes.
string[] - optional
The scopes declared as optional in your app configuration. These may or may not be currently granted — check `granted` to see which are active.
string[] - required
The scopes declared as required in your app configuration. These are always granted at install time and cannot be revoked by the app.
string[]
ScopesRequestResponse
- detail
The updated scopes for this app on this shop after the merchant's response.
ScopesDetail - result
The merchant's response: `'granted-all'` if they accepted all requested scopes, or `'declined-all'` if they declined.
UserResult
UserResult
The merchant's response to a scopes request: `'granted-all'` if they accepted all requested scopes, or `'declined-all'` if they declined.
'granted-all' | 'declined-all'ScopesRevokeResponse
- detail
The updated scopes for this app on this shop after the revocation.
ScopesDetail