EstateHub

Uploads API

Base URL: http://localhost:8000/api/v1
API prefix: /uploads

Authenticated endpoints use:

HTTP
Authorization: Bearer <access_token>
Content-Type: application/json

Uploads use a three-step flow:

  1. Prepare the upload.

  2. Upload the file directly to the storage provider.

  3. Complete the upload and attach its ID to the related resource.

1. Prepare Upload

Creates a pending upload and returns provider-specific upload instructions.

POST/uploads/prepare/

Auth: Required

Auth: Required
Content-Type: application/json

Request Body

JSON
{
  "original_name": "passport-front.jpg",
  "content_type": "image/jpeg",
  "size": 245760,
  "purpose": "kyc",
  "document_type": "identity_front"
}

Success Example

Status: 201 Created

JSON
{
  "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

PurposeAllowed roleMaximum sizePrivate
brandingAdministrator5 MBNo
avatarAuthenticated user5 MBNo
generalAuthenticated user20 MBYes
messageAuthenticated user8 MBYes
payment_proofCustomer10 MBYes
kycCustomer10 MBYes
kybSeller10 MBYes
property_mediaVerified seller or administrator100 MBNo
documentAuthenticated user25 MBYes

Verification document types

For kyc:

TEXT
identity_front
identity_back
selfie

For kyb:

TEXT
registration_certificate
trade_license
tax_document
representative_identity_front
representative_identity_back
representative_selfie

document_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.

  • size must be the exact file size in bytes.

  • content_type must match the file uploaded to the provider.

  • The frontend should use upload.id for 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.

POST/uploads/{upload_id}/complete/

Auth: Required

Auth: Required
Content-Type: application/json

Request Body

JSON
{}

Success Example

Status: 200 OK

JSON
{
  "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 pending to uploaded.

  • 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 attached when 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.

GET/uploads/{upload_id}/content/?token={delivery_token}

Auth: Signed query token

Auth: Not required

Success Example

Status: 302 Found

HTTP
Location: https://storage-provider.example.com/temporary-signed-file-url

Notes

  • Use the complete url returned 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 uploaded or attached can 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.

DELETE/uploads/{upload_id}/

Auth: Required

Auth: Required

Success Example

Status: 202 Accepted

JSON
{
  "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

TEXT
pending
uploaded
attached
deletion_pending
deleted
expired

Common Success Format

JSON
{
  "success": true,
  "message": "Operation completed successfully.",
  "data": {}
}

Common Error Format

JSON
{
  "success": false,
  "message": "Validation failed.",
  "errors": {
    "field_name": [
      "Error message."
    ]
  }
}

Frontend Integration Flow

TEXT
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 API

For previews, use the returned data.upload.url immediately. Signed delivery URLs are temporary and should not be persisted.