API Integration
This guide covers behavior shared across API domains. Use the API Directory for endpoint-specific request and response contracts.
Request Flow
Client Configuration
- Set
NEXT_PUBLIC_API_BASE_URLto 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
401as missing or invalid authentication and403as 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
Prepare
/uploads/prepare/.Transfer
Complete
/uploads/{upload_id}/complete/ after provider transfer succeeds.Attach
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, orupload_id. - Treat generated
*_url,file_url, andthumbnail_urlfields as response-only delivery URLs. - Use
external_urlonly 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.