> 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`).
> - 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/supported-extensions/backend-extensions/api/http-functions/add-http-function-extensions-with-the-cli.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/frameworks/wix-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/frameworks/wix-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/pages/api/<name>.ts`, and it's exposed at `/api/<name>`. For example, `src/pages/api/users.ts` becomes the route `/api/users`.

Endpoints are auto-discovered from the filesystem rather than registered like typical extensions.

<blockquote class="caution">

**Caution:** Because of this, and unlike HTTP functions and web methods in the legacy Wix CLI for Apps, HTTP endpoints aren't traditional extensions:

- They aren't generated by `npm run generate`.
- 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>

## 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.

Handlers use the `APIRoute` type from `astro`, the underlying framework that powers HTTP endpoints.

## 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/frameworks/wix-cli/project-development/environment-variables/about-environment-variables-in-the-cli.md), including secret server variables that aren't exposed to the client.
- 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/frameworks/wix-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. An endpoint is reachable by anyone who knows its URL, so enforcing access control is your responsibility.

To restrict access, inspect the caller's access token in your handler and decide whether to proceed:

- Frontend extensions send 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).
- 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`, for example, to allow only site members or admins.

Without `fetchWithAuth()` on the client, no token is sent and Get Token Info has nothing to inspect.

## 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/frameworks/wix-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/frameworks/wix-cli/project-development/elevate-api-call-permissions.md)
- [About Environment Variables](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-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/frameworks/wix-cli/supported-extensions/backend/http-endpoints/migrate/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/frameworks/wix-cli/supported-extensions/backend/http-endpoints/migrate/migrate-from-web-methods-to-http-endpoints.md)