> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Fix 403 Errors

## Article: Fix 403 Errors

## Article Link: https://dev.wix.com/docs/go-headless/authentication/troubleshooting/fix-403-errors.md

## Article Content:

# Fix 403 Errors

Some Wix SDK methods return `403 Forbidden` when called with a visitor or member context. This usually happens when the method needs higher permissions than the current identity has.

For example, you have a function that returns the 403 error:

```ts
const createdItem = await items.insert("uploadedimages", {
  _id: crypto.randomUUID(),
  imageTitle: "Example title",
  uploaderName: "Example uploader"
});
```

In Wix-managed headless projects, fix this by moving the method call to an [HTTP endpoint](https://dev.wix.com/docs/go-headless/wix-managed-headless/full-integration-astro/extensions/backend/http-endpoints/add-http-endpoints-to-your-project.md) and wrapping the SDK method with [`auth.elevate()`](https://dev.wix.com/docs/sdk/core-modules/essentials/auth.md#elevate). This way the frontend calls the HTTP endpoint, and the endpoint calls the protected API on the backend.

> **Notes:** 
> - To determine whether a method requires elevation, check that method's [reference documentation](https://dev.wix.com/docs/api-reference?apiView=SDK.md).
> - In self-managed headless, use [client credentials](https://dev.wix.com/docs/go-headless/authentication/admin/make-admin-api-calls-with-client-credentials.md) for site-scoped admin calls, or an [API key](https://dev.wix.com/docs/go-headless/authentication/admin/generate-an-api-key.md) for account-level access.

## Step 1 | Create a backend endpoint

Create an [HTTP endpoint](https://dev.wix.com/docs/go-headless/wix-managed-headless/full-integration-astro/extensions/backend/http-endpoints/add-http-endpoints-to-your-project.md) in your project, for example:

- `src/pages/api/upload-image.ts`

## Step 2 | Import modules

In your endpoint file, import:

- `APIRoute` from `astro`
- `auth` from `@wix/essentials`
- The SDK module that contains the method you need

```ts
import type { APIRoute } from "astro";
import { auth } from "@wix/essentials";
import { items } from "@wix/data";
```

## Step 3 | Wrap the SDK method

Expose an endpoint that calls the API method you need:

```ts
export const POST: APIRoute = async () => {
  const createdItem = await items.insert("uploadedimages", {
    _id: crypto.randomUUID(),
    imageTitle: "Example title",
    uploaderName: "Example uploader",
  });
  return new Response(JSON.stringify(createdItem));
};
```

Wrap the method with `auth.elevate()` before calling it:

```ts
export const POST: APIRoute = async () => {
  const elevatedInsert = auth.elevate(items.insert);
  const createdItem = await elevatedInsert("uploadedimages", {
    _id: crypto.randomUUID(),
    imageTitle: "Example title",
    uploaderName: "Example uploader",
  });
  return new Response(JSON.stringify(createdItem));
};
```

## Step 4 | Call the endpoint from your frontend

From frontend code, send a request to your endpoint:

```ts
  async function uploadImage(payload) {
    const response = await fetch("/api/upload-image", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(payload),
    });

    const result = await response.json();
  }
```

>**Note:** This example is applicable for headless projects only. To call the endpoint in apps, see [Elevate API Call Permissions](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/elevate-api-call-permissions.md#step-2--call-the-endpoint-from-your-frontend).

## See also

- [Elevate API Call Permissions](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/elevate-api-call-permissions.md)
- [About Elevated Permissions](https://dev.wix.com/docs/overview/auth-permissions/elevation.md)
- [About HTTP Endpoints](https://dev.wix.com/docs/go-headless/wix-managed-headless/full-integration-astro/extensions/backend/http-endpoints/about-http-endpoints.md)