Elevate API Call Permissions

Some SDK methods require elevated permissions to access sensitive data or perform privileged operations. For example, retrieving site properties or accessing business data often requires app-level authorization that site visitors, site members, and Wix users don't have. Without elevation, these calls return a 403 Forbidden error.

Note: To determine whether a method requires elevation, check that method's reference documentation.

To elevate API call permissions:

  1. Set up your project's backend code to handle elevated requests.
  2. Send a request from your frontend code to your project's backend.

Important: Exposed elevated API calls can create a security risk for privilege escalation attacks. Protect your exposed API calls with logic that validates who can call them and what operations they can perform.

Step 1 | Set up the endpoint in your project's backend

Set up your backend to handle requests for elevated API calls from your frontend.

To set up your backend:

  1. Create an HTTP endpoint. Do only Step 1 | Create the endpoint file from the linked article.

  2. In the file that defines your endpoint, import APIRoute from astro, the auth submodule from @wix/essentials, and the module containing the method you want to call with elevated permissions.

    Copy
  3. Expose an endpoint that calls the API method you need. Wrap the method with auth.elevate() before calling it.

    Copy

Step 2 | Call the endpoint from your frontend

Call your backend endpoint from your frontend code.

To call the endpoint:

  1. Import httpClient from @wix/essentials.

    Copy
  2. Retrieve the base URL from import.meta.url.

    Copy
  3. Call the endpoint using httpClient.fetchWithAuth() with this path: ${baseApiUrl}/api/<your-endpoint-name>.

    Copy

Examples

These examples show how to elevate Get Site Properties.

Backend code

Copy

Frontend code

Copy

See also

Did this help?