ResourcesAPI Reference

Resources

API Calls

Files inside the src/app/api directory who are called route.ts are API routes.

In order to call these API routes, you can use axios. For instance, we have an API route / a folder called send-free-trial-email which contains a file called route.ts. This API route sends a free trial email to a user.

In order to call this API route, we can do the following.

await axios.post(`${process.env.NEXT_PUBLIC_SITE_URL}/api/send-free-trial-email`, {
    userEmail: user.user_metadata.email ?? "",
    userFirstName: user.user_metadata.full_name ?? "",
});

This SaaS boilerplate comes with a few API routes out of the box. You can find all of them inside the src/app/api directory.