Upload files associated with entities using multipart/form-data.
Authentication
This endpoint requires authentication via Bearer token and organization context.
Required Headers:
Authorization: Bearer <jwt-token>
X-Organization-ID: <organization-id>
The file to upload (any type supported)
ID of the entity to associate the document with
ID of the document category (UBO, Legal Representative, Corporate, etc.)
Request Example
curl -X POST https://api.gu1.ai/documents/upload \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "X-Organization-ID: YOUR_ORG_ID" \
-F "file=@/path/to/document.pdf" \
-F "entityId=bb0c2d24-b519-40ec-b765-86de831ca0af" \
-F "categoryId=c5e9a3f2-1234-5678-9abc-def012345678"
Response
Unique identifier for the document
Display name of the document
Original filename of the uploaded file
Path where the file is stored (S3 key or local path)
Storage provider used (‘s3’ or ‘local’)
ID of the document category (if assigned)
ID of the organization that owns the document
When the document was created
Response Example
{
"id": "d7f8e9c0-1234-5678-9abc-def012345678",
"name": "document.pdf",
"description": "Documento subido: document.pdf",
"type": "other",
"fileName": "1730649606123_document.pdf",
"originalFileName": "document.pdf",
"fileSize": 245678,
"mimeType": "application/pdf",
"fileExtension": "pdf",
"storagePath": "/uploads/1730649606123_document.pdf",
"storageProvider": "local",
"securityLevel": "internal",
"categoryId": "c5e9a3f2-1234-5678-9abc-def012345678",
"organizationId": "24236b0a-e34d-4218-b3d2-76b101ce8aa9",
"createdBy": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
"createdAt": "2025-11-03T15:30:45.123Z",
"updatedAt": "2025-11-03T15:30:45.123Z"
}
What Happens After Upload
- Storage: File is uploaded to S3 (if enabled) or local storage
- Database Record: Document record is created in the database
- Versioning: Initial version (v1) is automatically created
- Entity Relationship: If
entityId is provided, a relationship is created automatically
- Risk Analysis: Automatic risk analysis is triggered if rules are configured
Supported File Types
- Documents: PDF, DOC, DOCX, TXT
- Images: PNG, JPG, JPEG, GIF
- Spreadsheets: XLS, XLSX, CSV
- Others: Any file type
Document Categories
To get available categories, use:
GET /documents/categories
Common categories include:
- UBO (Ultimate Beneficial Owner)
- Legal Representative
- Corporate Documents
- Enhanced Due Diligence
Error Responses
Bad Request - Missing file or authentication{
"error": "No file provided"
}
Unauthorized - Invalid token{
"error": "Unauthorized - No token provided"
}
Internal Server Error{
"error": "Error interno del servidor",
"details": "Error message here"
}
The system automatically detects if S3 storage is configured and uses it, otherwise falls back to local storage.
Maximum file size depends on server configuration (typically 50MB).
Even if entityId or categoryId don’t exist, the document will still be created. The relationship or category assignment will simply be skipped.