Skip to main content
The AuthResource on figranium.auth handles server setup, session authentication, and user identity. Use it to initialize a fresh Figranium server, authenticate with email and password, and retrieve the currently logged in user. Session-based methods require new Figranium({ session: true }). For API key authentication details, see Authentication.

Methods

Checks whether the Figranium server has been initialized with a first-time admin account. This endpoint does not require authentication.
  • HTTP endpoint: GET /api/auth/check-setup
check-setup.ts
Creates the first admin account on a fresh Figranium server. Call this only when checkSetup returns { setupRequired: true }. No credentials are required for this call.
  • HTTP endpoint: POST /api/auth/setup
first-setup.ts
Authenticates with email and password and establishes a session cookie. This method requires a session-enabled client (new Figranium({ session: true })). In Node.js, supply a cookie-aware fetch implementation because the default fetch does not preserve cookies.
  • HTTP endpoint: POST /api/auth/login
session-login.ts
Session-only endpoints like login, logout, and me require session: true. API key clients should not call these methods.
Ends the current session and invalidates the session cookie. Requires a session-enabled client.
  • HTTP endpoint: POST /api/auth/logout
logout.ts
Returns the currently authenticated user. Requires a session-enabled client. The User type is { id?: string; name: string; email: string }.
  • HTTP endpoint: GET /api/auth/me
me.ts

Return types

  • checkSetup returns { setupRequired: boolean }
  • setup returns { success: boolean }
  • login returns { success: boolean }
  • logout returns { success: boolean }
  • me returns { user: User } where User = { id?: string; name: string; email: string }

Error handling

All methods throw FigraniumError on failure. Common cases include invalid credentials on login, missing session on me, and calling setup on an already-initialized server. See Errors for details on status codes, error codes, and retry behavior.