Skip to main content

Overview

The Authentication API provides endpoints for user registration, login, email verification, password reset, and OAuth integration.

Headers

For authenticated function invocations:
For admin endpoints:

Register User

Create a new user account.

Query Parameters

Request Body

Example (Web Client)

Example (Non-Web Client)

Response (Web Client)

Response (Non-Web Client)

  • For web clients: A csrfToken is returned and the refresh token is stored in an httpOnly cookie.
  • For non-web clients (mobile, desktop, server): A refreshToken is returned directly in the response. Store it securely in your client or server runtime.
  • Use server for trusted server-side callers such as SSR apps, BFFs, or CLIs that cannot rely on browser cookies.
  • If requireEmailVerification is true, accessToken and tokens will be null and the user must verify their email before logging in.

Sign In

Authenticate user and get access token.

Query Parameters

Request Body

Example (Web Client)

Example (Non-Web Client)

Response (Web Client)

Response (Non-Web Client)

  • For web clients: A csrfToken is returned and the refresh token is stored in an httpOnly cookie. Include the csrfToken in the X-CSRF-Token header when calling /api/auth/refresh.
  • For non-web clients (mobile, desktop, server): A refreshToken is returned directly. Store it securely and include it in the request body when calling /api/auth/refresh.

Refresh Token

Refresh access token using refresh token.

Query Parameters

Headers (Web Client)

Request Body (Non-Web Client)

Example (Web Client)

Example (Non-Web Client)

Response (Web Client)

Response (Non-Web Client)

Token rotation is implemented for security:
  • Web clients: Each refresh returns a new csrfToken that must be used for subsequent refresh requests.
  • Non-web clients (mobile, desktop, server): Each refresh returns a new refreshToken. You must persist this new token and use it for the next refresh. Update the accessToken in memory.

Logout

Logout and clear refresh token cookie.

Example

Response


Get Current User

Get the currently authenticated user’s info from JWT token. This REST endpoint does not refresh expired access tokens by itself.
  • For raw REST clients, call POST /api/auth/refresh when needed.
  • For browser apps using the TypeScript SDK, call auth.getCurrentUser() during startup. The SDK will use the httpOnly refresh cookie automatically when it can refresh the session.
  • This automatic refresh behavior is browser-only. Server, mobile, and other non-browser clients should refresh explicitly.

Example

Response


Update Profile

Update the current user’s profile.

Request Body

Example

Response


Get User Profile

Get public profile information for a user by ID.

Example

Response


Email Verification

Send Verification Email

Request Body

Example

Response

Verify Email

Query Parameters

Request Body

For link-based verification, email clicks use:
That browser-oriented GET flow verifies the token on the backend and redirects to the stored redirectTo URL. POST /api/auth/email/verify is the JSON API for 6-digit code submission. Handle the browser redirect like this:
  • Success: ?insforge_status=success&insforge_type=verify_email
  • Error: ?insforge_status=error&insforge_type=verify_email&insforge_error=...
  • insforge_status: Result of the browser link flow. For verification, values are success or error.
  • insforge_type: Flow identifier. For verification links this is always verify_email.
  • insforge_error: Present only when insforge_status=error. Human-readable error message for display or logging.
  • Recommended handling: use your sign-in page as redirectTo. When insforge_status=success, show a confirmation message and ask the user to sign in with their email and password.
  • If redirectTo is not allowlisted, InsForge returns a 400 error whose message includes the rejected URL and whose nextActions tells you to add it to allowedRedirectUrls.

Example (Web Client)

Example (Non-Web Client)

Response (Web Client)

Response (Non-Web Client)


Password Reset

Send Reset Email

Request Body

Example

Exchange Code for Token (Code Method Only)

Request Body

Example

Response

Reset Password

For link-based password reset, email clicks use:
That browser-oriented GET flow validates the token on the backend and redirects to the stored redirectTo URL with the reset token in the query string. POST /api/auth/email/reset-password remains the JSON API that accepts the new password. Handle the browser redirect like this:
  • Ready to reset: ?token=...&insforge_status=ready&insforge_type=reset_password
  • Error: ?insforge_status=error&insforge_type=reset_password&insforge_error=...
  • token: Present only when insforge_status=ready. Pass this value to POST /api/auth/email/reset-password as otp.
  • insforge_status: Result of the browser link flow. For reset links, values are ready or error.
  • insforge_type: Flow identifier. For reset links this is always reset_password.
  • insforge_error: Present only when insforge_status=error. Human-readable error message for display or logging.
  • Your app should only render the reset-password form when insforge_status=ready and token is present.

Request Body

Example

Response


OAuth Authentication

OAuth authentication now uses the PKCE (Proof Key for Code Exchange) flow for enhanced security. Instead of returning tokens directly in the redirect URL, an authorization code is returned which must be exchanged for tokens.

Initiate OAuth Flow

For custom providers configured in the dashboard, use:

Query Parameters

Extra query params are forwarded as provider-specific hints only when they do not collide with server-owned OAuth fields. Do not pass client_id, redirect_uri, code_challenge, state, response_type, or scope; InsForge/provider-generated values win and colliding client values are ignored.

Supported Providers

  • google
  • github
  • discord
  • linkedin
  • facebook
  • apple
  • microsoft
  • x
  • spotify
  • Any custom provider key returned by GET /api/auth/public-config in customOAuthProviders

Example

Response

OAuth Callback

After the user authenticates with the provider, they will be redirected to your redirect_uri with an authorization code:
The insforge_code is a temporary authorization code that must be exchanged for tokens using the /api/auth/oauth/exchange endpoint.

Exchange Code for Tokens

Exchange the authorization code for access and refresh tokens.

Query Parameters

Request Body

Example

Response

  • For web clients: The refreshToken will be null and a csrfToken is returned instead. The refresh token is stored in an httpOnly cookie.
  • For non-web clients (mobile, desktop, server): A refreshToken is returned directly. Store it securely.

Complete OAuth Flow Example (Non-Web)


Public Configuration

Get public authentication settings (no auth required).

Example

Response


Admin Endpoints

These endpoints require project_admin role.

List All Users

Get User by ID

Delete Users

Generate Anonymous Token

Get Auth Configuration

Get current authentication settings (admin only).

Example

Response

allowedRedirectUrls entries are matched against the full redirectTo value, including scheme, host, optional port, and path.
  • Exact entries must match exactly, such as https://myapp.com/dashboard.
  • Wildcards are supported only in the host portion, such as https://*.myapp.com/callback.
  • Deep links are allowed when explicitly listed, such as com.example.app:/oauth2redirect or myapp://auth/callback.
  • If allowedRedirectUrls is empty, InsForge allows all redirects for developer convenience. This is insecure for production and should be avoided outside local development.

Update Auth Configuration

Update authentication settings (admin only).

Request Body

Example

Exchange Admin Session

Exchange a cloud provider authorization code for an admin session.

Request Body

Example

Response

Get Current Admin Session

Get the current dashboard admin session from a project admin access token.

Response

Refresh Admin Session

Refresh a dashboard admin access token. This endpoint uses the dashboard-only insforge_admin_refresh_token httpOnly cookie and does not share the app/user refresh cookie.

Logout Admin Session


Error Responses

Invalid Credentials (401)

User Already Exists (409)

Email Not Verified (403)