> 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: About HTTP Endpoints

## Article: About HTTP Endpoints

## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/about-http-endpoints.md

## Article Content:

# About HTTP Endpoints

Wix CLI projects support HTTP endpoints, which you use to build backend APIs for handling HTTP requests and coordinating frontend and backend logic. HTTP endpoints can serve any kind of data.

> **Note:** HTTP endpoints replace both [HTTP functions](https://dev.wix.com/docs/wix-cli/legacy-clis/legacy-wix-cli-for-apps/about-the-legacy-wix-cli-for-apps.md) and [web methods](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/apis/web-methods/about-web-method-extensions.md) from the legacy Wix CLI for Apps. See the migration guides for [HTTP functions](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/migrate/migrate-from-http-functions-to-http-endpoints.md) and [web methods](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/migrate/migrate-from-web-methods-to-http-endpoints.md).

## File-based routing

The location of an endpoint file in your project determines its URL. Place a file at `src/api/<name>.ts`, and it's exposed at `/<name>`, with no prefix. For example, `src/api/users.ts` becomes the route `/users`. A dynamic segment in square brackets becomes a route parameter. For example, `src/api/users/[id].ts` serves `/users/42`, and the handler reads `42` as `params.id`.

> **Note:** Routes that start with `_wix` are reserved for Wix. Don't add an endpoint file whose route starts with `_wix`.

<blockquote class="caution">

**Caution:** The CLI discovers HTTP endpoints from your project's files. Unlike HTTP functions and web methods in the legacy Wix CLI for Apps, HTTP endpoints aren't registered as extensions:

- They aren't registered in [`src/extensions.ts`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/about-the-extensions-ts-file.md).
- They don't appear on the **Extensions** page in the app dashboard.

</blockquote>

You can create an endpoint file yourself, or generate one by running `npm run generate` and selecting **HTTP Endpoint**.

## HTTP method handlers

Each endpoint file exports one or more HTTP method handlers, such as `GET` or `POST`. A handler receives the standard web `Request` and returns a standard `Response`, so you can return any content type, including JSON, plain text, images, and RSS feeds.

Type your handlers with the `APIRoute` type from `@wix/custom-extensions/types`. A handler receives a context object that includes the following properties:

- `request`: The incoming `Request`.
- `url`: The request URL, as a `URL` object.
- `params`: The route parameters from dynamic segments in the file path.

## Server-side runtime

Endpoints run on the server, not in the browser. This means you can:

- Read [environment variables](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/environment-variables/about-environment-variables-in-the-cli.md), including sensitive values such as API keys. Frontend code can't read the environment variables you define.
- Call external services without exposing credentials in your frontend bundle.

## Calling endpoints from frontend extensions

Frontend extensions, like dashboard pages and site widgets, call endpoints using `httpClient.fetchWithAuth()` from `@wix/essentials`. This attaches the current user's access token to the request as an `Authorization` header, which the endpoint can then use to make [elevated SDK calls](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/project-development/elevate-api-call-permissions.md) for operations the user can't perform directly.

For the full pattern, see [Add HTTP Endpoints to Your Project](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/add-http-endpoints-to-your-project.md).

## Permissions and security

Unlike [web methods](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/apis/web-methods/about-web-method-extensions.md), HTTP endpoints don't have a built-in permissions model. A request that doesn't include a Wix access token gets a `401` response. Frontend extensions add the current user's token when they call your endpoint with [`httpClient.fetchWithAuth()`](https://dev.wix.com/docs/sdk/core-modules/essentials/http-client.md#fetchwithauth).

A valid token doesn't tell you whether the caller is allowed to perform an operation. Before you make an elevated call or return sensitive data, check the caller and validate the input:

- In the handler, use [Get Token Info](https://dev.wix.com/docs/sdk/core-modules/essentials/auth.md#gettokeninfo) from `@wix/essentials` to read the token's `subjectType` and allow only the callers you expect. For example, a call from a dashboard page has the `subjectType` `USER`.
- Validate the request body and route parameters before you use them.

## Use cases

Use HTTP endpoints when you need to:

- Integrate with external APIs or services that require HTTP requests.
- Handle complex form submissions or file uploads.
- Serve dynamic content like images, RSS feeds, or personalized data.
- Build REST APIs with multiple HTTP methods.
- Access runtime data or server-side databases.

## See also

- [Add HTTP Endpoints to Your Project](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/add-http-endpoints-to-your-project.md)
- [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 Environment Variables](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/environment-variables/about-environment-variables-in-the-cli.md)
- [Migrate from HTTP Functions to HTTP Endpoints](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/migrate-an-app-to-the-new-cli/migrate-an-app-from-the-legacy-cli/migrate-from-http-functions-to-http-endpoints.md)
- [Migrate from Web Methods to HTTP Endpoints](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/migrate-an-app-to-the-new-cli/migrate-an-app-from-the-legacy-cli/migrate-from-web-methods-to-http-endpoints.md)