Skip to main content

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​

FieldTypeRequiredDescription
fileBinaryYesFile data (image, PDF, DOCX, CSV, etc.)
nameStringNoCustom display name (Defaults to uploaded filename)
companyIdUUID StringNoAssociated B2B Company ID
uploadByIdUUID StringNoUser 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"
}