ObjectStackObjectStack

Auth schema — API Protocol property reference

Defines the standard API contracts for Identity, Session Management, and Access Control.

Authentication Service Protocol

Defines the standard API contracts for Identity, Session Management, and Access Control.

Source: packages/spec/src/api/auth.zod.ts

TypeScript Usage

import { AuthProvider, LoginRequestSchema, LoginType, RefreshTokenRequestSchema, RegisterRequestSchema, SessionSchema, SessionResponseSchema, SessionUserSchema, UserProfileResponseSchema } from '@objectstack/spec/api';
import type { AuthProvider, LoginRequest, LoginType, RefreshTokenRequest, RegisterRequest, Session, SessionResponse, SessionUser, UserProfileResponse } from '@objectstack/spec/api';

// Validate data
const result = AuthProvider.parse(data);

AuthProvider

Allowed Values

  • local
  • google
  • github
  • microsoft
  • ldap
  • saml

LoginRequest

Properties

PropertyTypeRequiredDescription
typeEnum<'email' | 'username' | 'phone' | 'magic-link' | 'social'>optional (default: "email")Login method
emailstringoptionalRequired for email/magic-link
usernamestringoptionalRequired for username login
passwordstringoptionalRequired for password login
providerstringoptionalRequired for social (google, github)
redirectTostringoptionalRedirect URL after successful login

LoginType

Allowed Values

  • email
  • username
  • phone
  • magic-link
  • social

RefreshTokenRequest

Properties

PropertyTypeRequiredDescription
refreshTokenstring✅Refresh token

RegisterRequest

Properties

PropertyTypeRequiredDescription
emailstring✅
passwordstring✅
namestring✅
imagestringoptional

Session

Properties

PropertyTypeRequiredDescription
idstring✅
expiresAtstring✅
tokenstringoptional
ipAddressstringoptional
userAgentstringoptional
userIdstring✅

SessionResponse

Properties

PropertyTypeRequiredDescription
successboolean✅Operation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: integer; requestId?: string; traceId?: string }optionalResponse metadata
data{ session: object; user: object; token?: string }✅

Nested Shape: SessionResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>✅Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestring✅Readable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
refusaltrueoptionalProducer-declared: the 5xx this envelope carries is a deliberate refusal whose message is authored for the caller, so a boundary that reads the declaration keeps it verbatim (until the withhold arms read it, a declared refusal is still withheld). Absent (the default) on a declared fault, whose message is withheld from the body and logged for the operator; redundant on a 4xx. Presence is the declaration — true is the only value.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: SessionResponse.meta

PropertyTypeRequiredDescription
timestampstring✅
durationintegeroptionalServer-side processing duration in milliseconds
requestIdstringoptional
traceIdstringoptional

Nested Shape: SessionResponse.data

PropertyTypeRequiredDescription
session{ id: string; expiresAt: string; token?: string; ipAddress?: string; … }✅Active Session Info
user{ id: string; email: string; emailVerified?: boolean; name: string; … }✅Current User Details
tokenstringoptionalBearer token if not using cookies

SessionUser

Properties

PropertyTypeRequiredDescription
idstring✅User ID
emailstring✅Email address
emailVerifiedbooleanoptional (default: false)Is email verified?
namestring✅Display name
imagestring | nulloptionalAvatar URL
usernamestringoptionalUsername (optional)
rolesstring[]optional (default: [])Assigned role IDs
tenantIdstringoptionalCurrent tenant ID
languageneveroptional[REMOVED] SessionUser.language was removed in @objectstack/spec 17.4.0 (ADR-0049 enforce-or-remove) — it was declared with a permanent default of 'en' and never produced by any session endpoint nor read by any client, so a reader keying on it saw a constant, not the user's language. Delete the key. Read the signed-in user's language from GET /auth/me/localization (locale: the user's own sys_user.locale when set → the request's Accept-Language → the deployment default).
timezonestringoptionalPreferred timezone
createdAtstringoptional
updatedAtstringoptional

UserProfileResponse

Properties

PropertyTypeRequiredDescription
successboolean✅Operation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: integer; requestId?: string; traceId?: string }optionalResponse metadata
data{ id: string; email: string; emailVerified?: boolean; name: string; … }✅

Nested Shape: UserProfileResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>✅Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestring✅Readable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
refusaltrueoptionalProducer-declared: the 5xx this envelope carries is a deliberate refusal whose message is authored for the caller, so a boundary that reads the declaration keeps it verbatim (until the withhold arms read it, a declared refusal is still withheld). Absent (the default) on a declared fault, whose message is withheld from the body and logged for the operator; redundant on a 4xx. Presence is the declaration — true is the only value.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: UserProfileResponse.meta

PropertyTypeRequiredDescription
timestampstring✅
durationintegeroptionalServer-side processing duration in milliseconds
requestIdstringoptional
traceIdstringoptional

Nested Shape: UserProfileResponse.data

PropertyTypeRequiredDescription
idstring✅User ID
emailstring✅Email address
emailVerifiedbooleanoptional (default: false)Is email verified?
namestring✅Display name
imagestring | nulloptionalAvatar URL
usernamestringoptionalUsername (optional)
rolesstring[]optional (default: [])Assigned role IDs
tenantIdstringoptionalCurrent tenant ID
languageneveroptional[REMOVED] SessionUser.language was removed in @objectstack/spec 17.4.0 (ADR-0049 enforce-or-remove) — it was declared with a permanent default of 'en' and never produced by any session endpoint nor read by any client, so a reader keying on it saw a constant, not the user's language. Delete the key. Read the signed-in user's language from GET /auth/me/localization (locale: the user's own sys_user.locale when set → the request's Accept-Language → the deployment default).
timezonestringoptionalPreferred timezone
createdAtstringoptional
updatedAtstringoptional

On this page