Overview
The Authentication API provides endpoints for user registration, login, email verification, password reset, and OAuth integration.Headers
For authenticated function invocations: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
csrfTokenis returned and the refresh token is stored in an httpOnly cookie. - For non-web clients (
mobile,desktop,server): ArefreshTokenis returned directly in the response. Store it securely in your client or server runtime. - Use
serverfor trusted server-side callers such as SSR apps, BFFs, or CLIs that cannot rely on browser cookies. - If
requireEmailVerificationistrue,accessTokenand tokens will benulland 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
csrfTokenis returned and the refresh token is stored in an httpOnly cookie. Include thecsrfTokenin theX-CSRF-Tokenheader when calling/api/auth/refresh. - For non-web clients (
mobile,desktop,server): ArefreshTokenis 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
csrfTokenthat must be used for subsequent refresh requests. - Non-web clients (
mobile,desktop,server): Each refresh returns a newrefreshToken. You must persist this new token and use it for the next refresh. Update theaccessTokenin 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/refreshwhen 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:
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 aresuccessorerror.insforge_type: Flow identifier. For verification links this is alwaysverify_email.insforge_error: Present only wheninsforge_status=error. Human-readable error message for display or logging.- Recommended handling: use your sign-in page as
redirectTo. Wheninsforge_status=success, show a confirmation message and ask the user to sign in with their email and password. - If
redirectTois not allowlisted, InsForge returns a400error whose message includes the rejected URL and whosenextActionstells you to add it toallowedRedirectUrls.
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
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 wheninsforge_status=ready. Pass this value toPOST /api/auth/email/reset-passwordasotp.insforge_status: Result of the browser link flow. For reset links, values arereadyorerror.insforge_type: Flow identifier. For reset links this is alwaysreset_password.insforge_error: Present only wheninsforge_status=error. Human-readable error message for display or logging.- Your app should only render the reset-password form when
insforge_status=readyandtokenis 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
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
googlegithubdiscordlinkedinfacebookapplemicrosoftxspotify- Any custom provider key returned by
GET /api/auth/public-configincustomOAuthProviders
Example
Response
OAuth Callback
After the user authenticates with the provider, they will be redirected to yourredirect_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
refreshTokenwill benulland acsrfTokenis returned instead. The refresh token is stored in an httpOnly cookie. - For non-web clients (
mobile,desktop,server): ArefreshTokenis 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 requireproject_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:/oauth2redirectormyapp://auth/callback. - If
allowedRedirectUrlsis 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-onlyinsforge_admin_refresh_token httpOnly cookie and does not share the app/user
refresh cookie.