Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/joaomonteir0/printheritage/llms.txt

Use this file to discover all available pages before exploring further.

PrintHeritage exposes a FastAPI-powered REST API that serves as the single backend entry point for the web application. All client interactions — from authenticating users and managing monitoring projects to uploading sensor datasets and handling team invitations — flow through this API. The sections below describe base connectivity, authentication conventions, CORS policy, and a complete endpoint reference organized by functional group.

Base URL

The API runs on port 8001 by default. The frontend resolves this address from the REACT_APP_API_URL environment variable at build time.
http://localhost:8001
When deploying to a remote server, set REACT_APP_API_URL to the public address of your API host before building the frontend (e.g. https://api.printheritage.example.com).

Interactive API Docs

Because the backend is built with FastAPI, a fully interactive OpenAPI UI is automatically generated and available at:
http://localhost:8001/docs
You can use the Swagger UI to inspect all schemas, try requests directly in the browser, and download the raw OpenAPI JSON from http://localhost:8001/openapi.json.

Authentication

PrintHeritage uses the OAuth2 password flow to issue JWT Bearer tokens. Submit credentials once to /login; every subsequent request must carry the returned token in the Authorization header.
StepDetail
Token endpointPOST /login
Request content typeapplication/x-www-form-urlencoded (OAuth2PasswordRequestForm)
Response{ "access_token": "...", "token_type": "bearer" }
Header for protected endpointsAuthorization: Bearer <access_token>
Token lifetime60 minutes (ACCESS_TOKEN_EXPIRE_MINUTES)
Signing algorithmHS256
Tokens expire after 60 minutes. The client must re-authenticate by calling POST /login again. There is no refresh-token endpoint; store credentials securely to allow silent re-login.

Content Type

EndpointRequest Content-Type
POST /loginapplication/x-www-form-urlencoded
All other endpointsapplication/json
All responses are returned as application/json.

CORS Policy

The API is configured with permissive CORS settings suitable for local and staging environments:
CORSMiddleware(
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
For production deployments, restrict allow_origins to your known frontend domain(s) to prevent unauthorized cross-origin access.

Role Hierarchy

Access to certain endpoints depends on the authenticated user’s global_role. Roles are ordered from most to least privileged:
RoleValue
Super AdminSUPER_ADMIN
General AdminGENERAL_ADMIN
Project AdminPROJECT_ADMIN
VisualizerVISUALIZER
SUPER_ADMIN bypasses all role checks. GENERAL_ADMIN has implicit access to all projects. PROJECT_ADMIN can manage datasets and members within projects they belong to. VISUALIZER has read-only project access.

Endpoint Reference

All endpoints except POST /login and POST /register require a valid Authorization: Bearer <token> header. The Min Role column shows the minimum global_role required; endpoints that only check project membership rather than a global role are marked as Any (member).

Autenticação

MethodPathAuth RequiredMin Role
POST/loginNo
POST/registerNo
GET/meYesAny
POST/change-passwordYesAny

Utilizadores

MethodPathAuth RequiredMin Role
GET/usersYesGENERAL_ADMIN
PATCH/users/{user_id}YesAny
DELETE/users/{user_id}YesAny
GET/users/searchYesAny
GET/users/{user_id}/profileYesAny
GET /users accepts an optional ?q= query parameter to filter results by email or full name. GET /users/search requires a minimum of 3 characters in the q parameter and searches by email only.

Projetos

MethodPathAuth RequiredMin Role
POST/projectsYesAny
GET/projectsYesAny
GET/projects/{project_id}YesAny (member)
PATCH/projects/{project_id}/dataYesAny (member)
DELETE/projects/{project_id}/datasets/{dataset_id}YesPROJECT_ADMIN
GET/projects/{project_id}/membersYesAny (member)
DELETE/projects/{project_id}/members/{user_id}YesAny (member)
PATCH/projects/{project_id}/favoriteYesAny
SUPER_ADMIN and GENERAL_ADMIN users have implicit access to all projects regardless of membership. All other roles must have an ACCEPTED permission entry for the project.

Convites

MethodPathAuth RequiredMin Role
GET/invitationsYesAny
POST/invitations/{id}/acceptYesAny
POST/invitations/{id}/rejectYesAny
POST/invitations/{id}/readYesAny
POST/projects/{project_id}/inviteYesAny (member)

Auditoria

MethodPathAuth RequiredMin Role
GET/audit-logsYesSUPER_ADMIN
The audit log records all significant actions — user creation, login, project creation, dataset uploads, invitations, and password changes. Only SUPER_ADMIN accounts can retrieve the full log. Results are returned in reverse-chronological order.

Build docs developers (and LLMs) love