Upload Document API
Overview
Uploads a file to S3-compatible cloud storage (e.g. AWS S3 or DigitalOcean Spaces) and records metadata in the database.
- Endpoint:
/api/documents/upload - Method:
POST - Content-Type:
multipart/form-data
Request Form Fields Schema
| Field | Type | Required | Description |
|---|---|---|---|
file | Binary | Yes | File data (image, PDF, DOCX, CSV, etc.) |
name | String | No | Custom display name (Defaults to uploaded filename) |
companyId | UUID String | No | Associated B2B Company ID |
uploadById | UUID String | No | User ID of uploader |
Response Example (201 Created)
{
"success": true,
"data": {
"id": "d1234567-89ab-cdef-0123-456789abcdef",
"name": "Company Registration Certificate.pdf",
"path": "documents/companies/c1234567/2026-09-07/uuid_cert.pdf",
"mimeType": "application/pdf",
"size": 1048576,
"companyId": "c1234567-89ab-cdef-0123-456789abcdef",
"uploadById": null,
"active": true,
"createdAt": "2026-09-07T16:30:00.000Z",
"url": "http://localhost:4000/media/documents/companies/c1234567/2026-09-07/uuid_cert.pdf"
},
"message": "Document uploaded and metadata saved successfully"
}