Skip to content

Server API

The back end is an HTTP/JSON API in FastAPI. Locally it runs at http://localhost:8090; the interactive documentation generated by FastAPI is at /docs.

Authentication

  • POST /auth/login returns an opaque session token.
  • Every other route requires the Authorization: Bearer <token> header.
  • Sessions last 30 days. An invalid or expired token gets 401.

Conventions

  • Isolation between companies: a resource from another company responds 404 (never 403), so its existence isn’t revealed. A member without permission for the action gets 403.
  • Optimistic concurrency: project scenes and module documents carry a version number. A PUT with an outdated version responds 409 with code: "version_conflict".
  • Maximum body size: 20 MB.
  • Localised errors: error messages follow the client’s language (pt-BR / en).
  • Deletions of projects and modules are logical (soft delete).

Health

Method Route Description
GET /health The process is up.
GET /ready Ready to serve (includes the database).

Authentication (/auth)

Method Route Description Limit
POST /auth/signup Sign-up. Exactly one of: company_id (chosen company), invite_token or company (create a company — development only). 5 / 15 min / IP
POST /auth/login Sign in with email and password. 10 / min / IP
POST /auth/logout Ends the current session.
GET /auth/me The signed-in user and their companies/roles.
POST /auth/password/change Change password (current + new).
POST /auth/password/forgot Sends a reset link (valid for 1 h). Always responds with success. 5 / 15 min / IP
POST /auth/password/reset Sets a new password with the token; ends every session. 10 / 15 min / IP
POST /auth/verify-email Confirms the email with the token (valid for 7 days). 10 / 15 min / IP

Modules (/modules)

Method Route Description Permission
GET /modules Lists the visible modules, newest first. module:read
POST /modules Creates a module from a .module document. module:write
POST /modules/blank Creates an empty module (“Untitled N”). module:write
GET /modules/{id} The module’s full document. module:read
PUT /modules/{id} Replaces the document (autosave). module:write
PATCH /modules/{id} Renames. module:write
DELETE /modules/{id} Deletes; 409 if the module is in use. module:delete
PUT /modules/{id}/thumbnail Updates the thumbnail. module:write
PUT /modules/{id}/starred Stars/unstars. module:write
POST /modules/{id}/publish Publishes your own draft to the company library. module:write + author
POST /modules/{id}/unpublish Hands it back to the author as a draft; 409 if there is no author. module:unpublish

Versions (/modules/{id}/versions)

Method Route Description
GET /modules/{id}/versions History (without the content).
POST /modules/{id}/versions Creates the next version from the current state (with an optional label).
GET /modules/{id}/versions/{n} The rebuild chain for version n (keyframe + deltas).

Deltas are computed and applied on the client (jsondiffpatch); the server stores them as JSONB.

Projects (/projects)

Method Route Description Permission
GET /projects Lists the company’s projects. project:read
POST /projects Creates a project (name, description). project:write
GET /projects/{id} The project’s metadata. project:read
PATCH /projects/{id} Changes the name and description. project:write
DELETE /projects/{id} Deletes. project:delete
GET /projects/{id}/scene The scene (document + version). project:read
PUT /projects/{id}/scene Saves the scene; 409 version_conflict if outdated. project:write
PUT /projects/{id}/thumbnail Updates the thumbnail. project:write
PUT /projects/{id}/starred Stars/unstars. project:write

Quotes (/projects/{id}/quotes)

Method Route Description Permission
GET /projects/{id}/quotes Lists the quotes, newest first. project:read
POST /projects/{id}/quotes Stores a quote (a snapshot computed by the client). quote:generate
GET /projects/{id}/quotes/{qid} The full quote. project:read
PATCH /projects/{id}/quotes/{qid} Edits only hardware and markup. quote:generate
PUT /projects/{id}/quotes/{qid}/cut-plan Saves manual edits to the cut plan. project:write
DELETE /projects/{id}/quotes/{qid}/cut-plan Returns to the quoted plan. project:write

The server validates the snapshot’s shape and the consistency of the totals, but doesn’t recompute geometry.

Companies (/companies)

Method Route Description Permission
GET /companies Public list of companies (for sign-up). Public
GET /companies/{id}/settings Markup, logo, machine and the user’s role. price_catalog:read
PATCH /companies/{id}/settings Changes the default markup and machine parameters. price_catalog:edit
PUT /companies/{id}/logo Sets the logo. price_catalog:edit
DELETE /companies/{id}/logo Removes the logo. price_catalog:edit
GET /companies/{id}/price-catalog The catalog rows. price_catalog:read
POST /companies/{id}/price-catalog Adds a material. price_catalog:edit
PATCH /companies/{id}/price-catalog/{item_id} Edits a material. price_catalog:edit
DELETE /companies/{id}/price-catalog/{item_id} Removes a material. price_catalog:edit

Libraries (/libraries)

It exists in the API, but is not used by the app — modules go to the company’s default library. Explicit per-library permissions only grant access to the library record, not to its modules (ADR-0004).

Method Route Description
GET /libraries Accessible libraries.
POST /libraries Creates a library.
GET /libraries/{id} Detail.
PATCH /libraries/{id} Renames / changes the description.
DELETE /libraries/{id} Deletes.
GET /libraries/{id}/members Explicit permissions.
POST /libraries/{id}/members Grants permission (company members).
DELETE /libraries/{id}/members/{user_id} Revokes permission.

AI (/ai)

Method Route Description
POST /ai/generate One chat turn. Receives the history, the mode (module or project), the company, a scene summary and the environment context. Responds with a message and at most one kind of payload: generated furniture (parts + mates + parametric), reuse of a library module, or edits — plus, optionally, a view command and the estimate flag.

Specific errors: 503 ai_disabled (no key configured), 429 (rate limit), 422 (message too long, history too long, scene with more than 80 parts), 403 ai_company_forbidden.

The full technical document for the AI subsystem is in services/api/app/ai/README.md.