Skip to main content
Any file named route.ts in the /apps/web/app/api is an API Route. Hereโ€™s an example of an API Route that perform a Hello World:

Protected API Route

To create a protected api route, you need to decorate the example above with the withSession helper:

Project-based Protected API Route

To create an api route that refers to a given project and not the authenticated user, use the withAuth helper:

Role Protection

withAuth accepts a second optional argument with the following structure:
We can add it to an api route to make it available only to the owner of the project: