api object that mirrors every HTTP endpoint — including endpoints added by plugins. You can call these as regular TypeScript functions on the server, or hit them as HTTP endpoints from any client.
Base path
All endpoints are mounted under/api/auth by default. You can change this with the basePath option.
| Endpoint | Method | Description |
|---|---|---|
/api/auth/sign-up/email | POST | Register with email & password |
/api/auth/sign-in/email | POST | Sign in with email & password |
/api/auth/sign-out | POST | Invalidate the current session |
/api/auth/get-session | GET | Return the current session |
/api/auth/sign-in/social | POST | Initiate social OAuth flow |
/api/auth/callback/:provider | GET | OAuth callback handler |
/api/auth/verify-email | GET | Verify email with token |
/api/auth/forget-password | POST | Request a password-reset email |
/api/auth/reset-password | POST | Complete password reset |
/api/auth/change-password | POST | Change password (authenticated) |
/api/auth/change-email | POST | Change email (authenticated) |
/api/auth/delete-user | POST | Delete the authenticated user |
/api/auth/list-sessions | GET | List sessions for the current user |
/api/auth/revoke-session | POST | Revoke a specific session |
/api/auth/revoke-other-sessions | POST | Revoke all sessions except current |
Plugins register additional endpoints under the same base path. All
plugin endpoints are automatically available on the
api object.Calling endpoints server-side
Import yourauth instance and call endpoints directly as functions. This skips HTTP entirely — useful in server components, API routes, and middleware.
server.ts
Body, headers, and query parameters
Unlike the browser client, the server API accepts values as a plain object:| Key | Purpose |
|---|---|
body | Request body (POST/PUT payloads) |
headers | Request headers (required for session lookup) |
query | URL query parameters |
server.ts
Better Auth’s API layer is built on
better-call, a tiny web framework
that lets REST endpoints be called as regular TypeScript functions with full
type inference.
Retrieving response headers
UsereturnHeaders: true to get back the response Headers object alongside
the data. This is useful when you need Set-Cookie headers.
server.ts
Retrieving the raw Response object
PassasResponse: true to receive a standard Response instead of the
deserialised data.
server.ts
Error handling
Server-side API calls throw anAPIError on failure. Use isAPIError to
narrow the error type.
server.ts