This API allows you to manage documents, including uploading, querying, and deleting them.
All endpoints are relative to the base URL: http://127.0.0.1:5001
POST /documents
Uploads a new document to the main documents table.
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Required | The document file (multipart/form-data) |
property_id | String | Required | Property identifier |
uploaded_by | String | Required | Must be either "buyer" or "seller" |
document_tag | String | Required | Type or category of document |
buyer_id | String | Required if uploaded_by="buyer" | Buyer identifier |
seller_id | String | Required if uploaded_by="seller" | Seller identifier |
{ "message": "Document added successfully", "document_id": 123 }
POST /documents/buyer
Uploads a new document to the buyer documents table (for documents not associated with a property).
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Required | The document file (multipart/form-data) |
buyer_id | String | Required | Buyer identifier |
document_tag | String | Required | Type or category of document |
{ "message": "Document added successfully", "document_id": 123 }
GET /documents/query
Retrieves documents from the main documents table based on optional filters.
Parameter | Type | Required | Description |
---|---|---|---|
property_id | String | Optional | Filter by property identifier |
uploaded_by | String | Optional | Filter by uploader type ("buyer" or "seller") |
buyer_id | String | Optional | Filter by buyer identifier |
seller_id | String | Optional | Filter by seller identifier |
document_tag | String | Optional | Filter by document type/category |
{ "count": 2, "documents": [ { "document_id": 123, "filename": "contract.pdf", "file_type": "application/pdf", "image_url": "data:application/pdf;base64,JVBERi0xLjMKJcTl8uXrp...", "datetime_uploaded": "2023-05-15T14:30:45.123456", "property_id": "456", "buyer_id": "789", "seller_id": "101", "uploaded_by": "buyer", "document_tag": "contract" }, { "document_id": 124, "filename": "deed.pdf", "file_type": "application/pdf", "image_url": "data:application/pdf;base64,JVBERi0xLjQKJcOkw7zD...", "datetime_uploaded": "2023-05-14T10:15:22.654321", "property_id": "456", "buyer_id": "789", "seller_id": "101", "uploaded_by": "seller", "document_tag": "deed" } ] }
GET /documents/query/buyer
Retrieves documents from the buyer documents table.
Parameter | Type | Required | Description |
---|---|---|---|
buyer_id | String | Required | Filter by buyer identifier |
document_tag | String | Optional | Filter by document type/category |
{ "count": 1, "documents": [ { "document_id": 125, "filename": "id_verification.jpg", "file_type": "image/jpeg", "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD...", "datetime_uploaded": "2023-05-16T09:45:12.987654", "buyer_id": "789", "document_tag": "identification" } ] }
DELETE /documents/delete
Deletes a document from the main documents table based on provided criteria.
Parameter | Type | Required | Description |
---|---|---|---|
property_id | String | Required | Property identifier |
uploaded_by | String | Required | Must be either "buyer" or "seller" |
document_tag | String | Required | Type or category of document |
buyer_id | String | Required if uploaded_by="buyer" | Buyer identifier |
seller_id | String | Required if uploaded_by="seller" | Seller identifier |
{ "message": "Document deleted successfully" }
DELETE /documents/buyer/delete
Deletes a document from the buyer documents table.
Parameter | Type | Required | Description |
---|---|---|---|
buyer_id | String | Required | Buyer identifier |
document_tag | String | Required | Type or category of document |
{ "message": "Document deleted successfully" }
curl -X POST http://127.0.0.1:5001/documents \ -F "file=@/path/to/document.pdf" \ -F "property_id=456" \ -F "buyer_id=789" \ -F "uploaded_by=buyer" \ -F "document_tag=contract"
curl -X POST http://127.0.0.1:5001/documents/buyer \ -F "file=@/path/to/id.jpg" \ -F "buyer_id=789" \ -F "document_tag=identification"
curl "http://127.0.0.1:5001/documents/query?property_id=456&uploaded_by=buyer"
curl "http://127.0.0.1:5001/documents/query/buyer?buyer_id=789"
curl -X DELETE "http://127.0.0.1:5001/documents/delete?property_id=456&uploaded_by=buyer&document_tag=contract&buyer_id=789"
curl -X DELETE "http://127.0.0.1:5001/documents/buyer/delete?buyer_id=789&document_tag=identification"