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 and web methods from the legacy Wix CLI for Apps. See the migration guides for HTTP functions and web methods.
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.
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:
src/extensions.ts.You can create an endpoint file yourself, or generate one by running npm run generate and selecting HTTP Endpoint.
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.Endpoints run on the server, not in the browser. This means you can:
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 for operations the user can't perform directly.
For the full pattern, see Add HTTP Endpoints to Your Project.
Unlike web methods, 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().
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:
@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.Use HTTP endpoints when you need to:
Last updated: 11 November 2026