Passa al contenuto principale

Auth API

Auto-generated from the OpenAPI spec. Run node docs-site/scripts/fetch-openapi.js to regenerate.

POST /api/v1/auth/register/client

Register Client

Register a new client account (mobile app). Auto-logs in and returns tokens.

Request body

FieldRequiredTypeDescription
emailYesstring
passwordYesstring
full_nameYesstring
phoneNostring
date_of_birthNostring

Responses

  • 201 — Successful Response
  • 422 — Validation Error

POST /api/v1/auth/bootstrap

Bootstrap Studio

One-time first-run setup: create the studio's StudioSettings row, its default Location(id=1), and its one and only manager account, then log them straight in.

Public and unauthenticated by design — on a fresh install there is no manager JWT yet, so nothing else can gate this endpoint (the classic chicken-and-egg problem). Two restrictions keep that safe:

  1. Loopback-only. The backend binds 0.0.0.0:8000 (reachable from the LAN so the mobile app can connect — see api/client.ts on desktop, which always calls http://localhost:8000 for this very endpoint). Without this check, another device on the same network could race to claim the studio before its real owner finishes onboarding, permanently locking them out afterward (the single-use guard below would then reject the legitimate owner's own later attempt).
  2. Single-use. Rejects with STUDIO_ALREADY_CONFIGURED once any User row exists. The count() > 0 check is the LAST thing evaluated before the db.add()/db.commit() sequence — no request-time gap between check and write — so it closes the same way the confirmed-bookings capacity check in bookings.py and the stock check in product_sale_service.py do: relying on SQLite's single-writer transaction serialization rather than row-level locking (which SQLite doesn't support cleanly).

Request body

FieldRequiredTypeDescription
studio_nameYesstring
timezoneNostring
manager_full_nameYesstring
manager_emailYesstring
manager_passwordYesstring

Responses

  • 201 — Successful Response
  • 422 — Validation Error

POST /api/v1/auth/login

Login

Login for managers, instructors, and clients. Tries users table first, then clients.

Request body

FieldRequiredTypeDescription
emailYesstring
passwordYesstring

Responses

  • 200 — Successful Response
  • 422 — Validation Error

POST /api/v1/auth/refresh

Refresh Token Endpoint

Issue a new access token from a valid refresh token.

The new access token's role is derived from the refresh token's own role claim, NOT by probing the users table first. User.id and Client.id overlap, so a "try users then clients" lookup would let a client refresh token mint a manager access token whenever the ids collide (privilege escalation).

Request body

FieldRequiredTypeDescription
refresh_tokenYesstring

Responses

  • 200 — Successful Response
  • 422 — Validation Error

POST /api/v1/auth/logout

Logout

Invalidate session (stateless — client should discard tokens).

Responses

  • 200 — Successful Response

POST /api/v1/auth/forgot-password

Forgot Password

Request a password reset email.

Request body

FieldRequiredTypeDescription
emailYesstring

Responses

  • 200 — Successful Response
  • 422 — Validation Error

POST /api/v1/auth/reset-password

Reset Password

Reset password using a token.

Request body

FieldRequiredTypeDescription
tokenYesstring
new_passwordYesstring

Responses

  • 200 — Successful Response
  • 422 — Validation Error

GET /api/v1/auth/invite/{token}

Validate Invite Token

Validate an invitation token and return basic client info.

Parameters

NameInRequiredTypeDescription
tokenpathYesstring

Responses

  • 200 — Successful Response
  • 422 — Validation Error

GET /api/v1/auth/me

Get Me

Return the current authenticated user or client profile.

Responses

  • 200 — Successful Response