Uploads API
Base URL: http://localhost:8000/api/v1
API prefix: /uploads
Authenticated endpoints use:
Authorization: Bearer <access_token>
Content-Type: application/jsonUploads use a three-step flow:
-
Prepare the upload.
-
Upload the file directly to the storage provider.
-
Complete the upload and attach its ID to the related resource.
1. Prepare Upload
Creates a pending upload and returns provider-specific upload instructions.
/uploads/prepare/Auth: Required
Auth: Required
Content-Type: application/json
Request Body
{
"original_name": "passport-front.jpg",
"content_type": "image/jpeg",
"size": 245760,
"purpose": "kyc",
"document_type": "identity_front"
}Success Example
Status: 201 Created
{
"success": true,
"message": "Upload prepared successfully.",
"data": {
"upload": {
"id": "59ed7663-357f-402f-b414-27d7f3b12e87",
"provider": "s3",
"purpose": "kyc",
"document_type": "identity_front",
"original_name": "passport-front.jpg",
"content_type": "image/jpeg",
"declared_size": 245760,
"size": null,
"is_private": true,
"status": "pending",
"url": "",
"expires_at": "2026-09-23T11:15:00+06:00",
"completed_at": null,
"created_at": "2026-09-23T11:00:00+06:00"
},
"request": {
"method": "POST",
"url": "https://storage-provider.example.com/",
"headers": {},
"fields": {
"key": "provider-generated-key",
"Content-Type": "image/jpeg",
"policy": "provider-generated-policy",
"x-provider-signature": "provider-generated-signature"
}
}
}
}Supported purposes
| Purpose | Allowed role | Maximum size | Private |
|---|---|---|---|
branding | Administrator | 5 MB | No |
avatar | Authenticated user | 5 MB | No |
general | Authenticated user | 20 MB | Yes |
message | Authenticated user | 8 MB | Yes |
payment_proof | Customer | 10 MB | Yes |
kyc | Customer | 10 MB | Yes |
kyb | Seller | 10 MB | Yes |
property_media | Verified seller or administrator | 100 MB | No |
document | Authenticated user | 25 MB | Yes |
Verification document types
For kyc:
identity_front
identity_back
selfieFor kyb:
registration_certificate
trade_license
tax_document
representative_identity_front
representative_identity_back
representative_selfiedocument_type is required for KYC and KYB uploads. It must be omitted for other purposes unless explicitly supported by the owning workflow.
Upload instructions
-
The file is not uploaded to the EstateHub backend.
-
Upload directly to
data.request.url. -
Use the returned HTTP method, headers, and form fields exactly as provided.
-
Do not modify provider-generated fields.
-
Call the complete endpoint only after the provider upload succeeds.
-
The preparation request expires after 15 minutes by default.
-
sizemust be the exact file size in bytes. -
content_typemust match the file uploaded to the provider. -
The frontend should use
upload.idfor the complete request and later domain submission.
Error Responses
-
400 Bad Request— invalid purpose, document type, MIME type, file size, role, or storage configuration. -
401 Unauthorized— missing or invalid access token. -
415 Unsupported Media Type— request is not JSON.
2. Complete Upload
Verifies the uploaded object and marks it as ready for attachment.
/uploads/{upload_id}/complete/Auth: Required
Auth: Required
Content-Type: application/json
Request Body
{}Success Example
Status: 200 OK
{
"success": true,
"message": "Upload completed successfully.",
"data": {
"upload": {
"id": "59ed7663-357f-402f-b414-27d7f3b12e87",
"provider": "s3",
"purpose": "kyc",
"document_type": "identity_front",
"original_name": "passport-front.jpg",
"content_type": "image/jpeg",
"declared_size": 245760,
"size": 245760,
"is_private": true,
"status": "uploaded",
"url": "http://localhost:8000/api/v1/uploads/59ed7663-357f-402f-b414-27d7f3b12e87/content/?token=signed-delivery-token",
"expires_at": "2026-09-23T11:15:00+06:00",
"completed_at": "2026-09-23T11:03:42+06:00",
"created_at": "2026-09-23T11:00:00+06:00"
}
}
}Notes
-
The authenticated user must own the upload.
-
The upload must still be pending and must not be expired.
-
EstateHub verifies the object’s existence, size, and content type.
-
A successful upload changes status from
pendingtouploaded. -
Submit the returned upload ID to the owning domain endpoint.
-
The upload purpose must match the target field.
-
KYC/KYB document types must also match the target field.
-
Completed uploads become
attachedwhen claimed by a domain record.
Error Responses
-
400 Bad Request— expired preparation, provider verification failure, metadata mismatch, or completion failure. -
401 Unauthorized— missing or invalid access token. -
404 Not Found— upload does not exist or does not belong to the authenticated user. -
415 Unsupported Media Type— request is not JSON.
3. Access Uploaded Content
Redirects to a temporary provider delivery URL.
/uploads/{upload_id}/content/?token={delivery_token}Auth: Signed query token
Auth: Not required
Success Example
Status: 302 Found
Location: https://storage-provider.example.com/temporary-signed-file-urlNotes
-
Use the complete
urlreturned by the upload or owning domain API. -
Private files require a valid delivery token.
-
Public files may not require a token.
-
Private delivery tokens expire after 5 minutes by default.
-
The provider URL is also temporary.
-
Refetch the related API resource after the URL expires.
-
KYC, KYB, payment proofs, and general documents are private.
-
Never permanently store signed delivery URLs in the frontend.
-
Only uploads with status
uploadedorattachedcan be accessed.
Error Responses
404 Not Found— upload unavailable, deleted, invalid, expired, or missing a valid private token.
4. Delete Unattached Upload
Requests deletion of an uploaded file that has not been attached to another record.
/uploads/{upload_id}/Auth: Required
Auth: Required
Success Example
Status: 202 Accepted
{
"success": true,
"message": "Upload deletion requested successfully.",
"data": {}
}Notes
-
The authenticated user must own the upload.
-
Attached uploads cannot be deleted through this endpoint.
-
The upload changes to
deletion_pending. -
Provider deletion is asynchronous.
-
Attached files must be removed or replaced through their owning domain record.
-
Expired pending uploads and abandoned uploads are cleaned up by the cleanup command.
-
The request does not require a request body.
Error Responses
-
400 Bad Request— upload is attached to another record. -
401 Unauthorized— missing or invalid access token. -
404 Not Found— upload does not exist or belongs to another user.
Upload Statuses
pending
uploaded
attached
deletion_pending
deleted
expiredCommon Success Format
{
"success": true,
"message": "Operation completed successfully.",
"data": {}
}Common Error Format
{
"success": false,
"message": "Validation failed.",
"errors": {
"field_name": [
"Error message."
]
}
}Frontend Integration Flow
POST /uploads/prepare/
↓
Upload directly to data.request.url
↓
POST /uploads/<upload_id>/complete/
↓
Submit upload_id to KYC, KYB, messaging, payment, branding, or property APIFor previews, use the returned data.upload.url immediately. Signed delivery URLs are temporary and should not be persisted.