Quickstart
Authentication
The FairePlace API uses JWT (JSON Web Tokens) with RS256 signing for authentication and tenant-scoped access control.
Getting a token
Authenticate with your credentials to receive a JWT token:
Code
Code
Using the token
Include the token in the Authorization header of every request:
Code
Token contents
The JWT payload contains:
Code
tenant_id— Your organization ID. All API operations are scoped to this tenant.permissions— The actions this token can perform.exp— Token expiration (Unix timestamp).
Permissions
| Permission | Allows |
|---|---|
properties:read | List and view places, estates, rooms, equipment |
properties:write | Create, update, and delete properties |
leases:read | List and view leases, charges, amendments |
leases:write | Create, update leases; generate PDFs; manage charges |
leases:delete | Delete leases and related resources |
lessees:read | List and view tenants and guarantors |
lessees:write | Create and update tenant records |
lessees:delete | Delete tenant records |
owners:read | List and view property owners |
owners:write | Create and update owner records |
contacts:read | List and view contacts |
contacts:write | Create and update contacts |
signatures:read | View signature status and proof |
signatures:write | Initiate and manage signature workflows |
credits:read | View credit balance |
credits:write | Purchase credits |
media:read | View and download media files |
media:write | Upload media files |
Multi-tenant isolation
FairePlace enforces strict data isolation between organizations:
- Every request is scoped to the
tenant_idembedded in your JWT - You can only access resources belonging to your organization
- Cross-tenant access is impossible — the API returns
404 Not Found(not403) for resources outside your tenant, preventing information leakage - Database queries are automatically filtered by
tenant_id
Code
Token lifecycle
| Event | Duration | Action |
|---|---|---|
| Token issued | — | Store securely, use in Authorization header |
| Token active | Up to 24 hours | Normal API usage |
| Token expired | After exp timestamp | Re-authenticate with POST /auth/login |
| Token revoked | Immediate | Re-authenticate |
Refresh strategy
Tokens are valid for 24 hours. Recommended approach:
- Store the
expires_atvalue from the login response - Before making a request, check if the token expires within the next 5 minutes
- If so, re-authenticate to get a fresh token
- Retry the original request with the new token
Code
Common authentication errors
401 Unauthorized — Missing or invalid token
Code
Causes:
- No
Authorizationheader - Malformed token (not a valid JWT)
- Expired token (check
expclaim) - Token signed with wrong key
Fix: Re-authenticate with POST /auth/login.
403 Forbidden — Insufficient permissions
Code
Causes:
- Your token doesn't include the required permission for this endpoint
- Your user role doesn't have access to this operation
Fix: Request the appropriate permissions from your organization admin.
Security best practices
- Never expose tokens in URLs, logs, or client-side code
- Use HTTPS for all API calls (HTTP requests are rejected)
- Rotate credentials regularly
- Scope permissions to the minimum required for your integration
- Handle 401 errors gracefully by re-authenticating automatically
Last modified on