EstateHub

API Integration

This guide covers behavior shared across API domains. Use the API Directory for endpoint-specific request and response contracts.

Request Flow

sequenceDiagram
participant Client
participant View as Role-specific APIView
participant Selector
participant Service
participant Database
Client->>View: HTTP request and optional Bearer JWT
View->>View: Authenticate, authorize, validate
View->>Selector: Load scoped records
View->>Service: Execute mutation
Service->>Database: Transactional read/write
Service-->>View: Domain result
View-->>Client: JSON response

Client Configuration

  • Set NEXT_PUBLIC_API_BASE_URL to a URL ending in /api/v1.
  • Append relative paths such as /accounts/customers/login/ or /sellers/properties/.
  • Send Authorization: Bearer <access-token> for protected endpoints.
  • Refresh tokens through the matching customer, seller, or administrator namespace.
  • Treat 401 as missing or invalid authentication and 403 as insufficient permission.
  • Preserve field-level errors from the custom DRF exception handler.

Token Refresh

The frontend base client should attach the current access token, attempt one coordinated refresh after a 401, store the replacement access token, and retry the original request. If refresh fails, clear local credentials and return the user to the appropriate login flow.

Messaging and WebSockets

REST loads conversation lists, conversation state, and message history. WebSockets deliver active-conversation messages, read receipts, and typing events.

See Messaging API and WebSocket Integration for connection authentication, event payloads, optimistic sending, reconnect behavior, and delivery behavior.

Managed Uploads

1

Prepare

POST upload metadata to /uploads/prepare/.
2

Transfer

Send the file directly to the configured storage provider using the returned instruction.
3

Complete

POST /uploads/{upload_id}/complete/ after provider transfer succeeds.
4

Attach

Send the completed upload identifier through the owning workflow.

See Uploads API for supported purposes, roles, file limits, document types, access, deletion, and errors.

File Field Contract

  • Send upload identifiers such as avatar_upload_id, payment_proof_upload_id, attachment_upload_id, or upload_id.
  • Treat generated *_url, file_url, and thumbnail_url fields as response-only delivery URLs.
  • Use external_url only where the owning request explicitly permits an external resource.
  • Store upload identifiers rather than generated delivery URLs.

Generated API Discovery

The backend exposes /api/schema/, /api/docs/, and /api/redoc/. Use these tools alongside the detailed API reference when developing an integration.