Skip to main content

Create Document (Upload)

Uploads a document and attaches it to a specific banking entity.

Command Name

CreateDocumentCommand

Endpoint

POST /api/core/cmd

Request Parameters

ParameterTypeRequiredDescription
entityTypestringYesEntity type: "Client", "Loan", "Deposit", or "Policy"
entityIdlongYesID of the entity (clientId, loanId, depositId, or policyId)
fileNamestringYesOriginal file name with extension
fileContentBase64stringYesBase64-encoded file content
titlestringNoDocument title
descriptionstringNoDocument description
documentNumberstringNoDocument number (e.g., ID card number)
documentTypeintegerNoDocument type enum value
documentTypeDescriptionstringNoDocument type description
issueDatestringNoDocument issue date (YYYY-MM-DD)
expiryDatestringNoDocument expiry date (YYYY-MM-DD)

Request Example

{
"Cmd": "CreateDocumentCommand",
"Data": {
"entityType": "Client",
"clientId": 12345,
"fileName": "passport.pdf",
"fileContentBase64": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYX...",
"title": "International Passport",
"description": "Valid passport for KYC verification",
"documentNumber": "A12345678",
"documentType": 2,
"documentTypeDescription": "Passport",
"issueDate": "2020-01-15",
"expiryDate": "2030-01-14"
}
}

Response Structure

{
"IsSuccessful": true,
"StatusCode": "00",
"Message": "Document uploaded successfully.",
"Data": {
"Identifier": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"FilePath": "documents/clients/12345/passport_3fa85f64.pdf",
"FileExtension": ".pdf",
"OriginalFileName": "passport.pdf",
"UploadedAt": "2024-01-20T14:30:00",
"UploadedBy": "admin@banklingo.com",
"StorageProvider": "MinIO"
}
}

Validation Rules

  1. Entity Must Exist: The specified entity ID must exist in the system
  2. Valid Base64: File content must be valid base64-encoded string
  3. File Size: Maximum file size limits apply (configured in system settings)
  4. Supported Formats: PDF, PNG, JPG, JPEG, DOC, DOCX, XLS, XLSX typically supported
  5. Unique Document Number: Optional but should be unique if provided

Error Responses

{
"IsSuccessful": false,
"StatusCode": "01",
"Message": "Invalid client ID.",
"Data": null
}

Use Case Example

Upload KYC documents during client onboarding:

{
"Cmd": "CreateDocumentCommand",
"Data": {
"entityType": "Client",
"clientId": 12345,
"fileName": "national_id.pdf",
"fileContentBase64": "...",
"documentType": 1,
"documentTypeDescription": "National ID",
"documentNumber": "NIN-12345678",
"issueDate": "2015-06-20",
"expiryDate": "2025-06-19"
}
}