Skip to main content

Documents API

Documents​

Attach a file to an existing invoice, sales order, quote, purchase bill, purchase order, expense, deposit, transfer, journal, or payment. The file is not sent to this API. Request a PUT URL, upload the bytes to that URL, then confirm. Branch is SelectedBranchId. Do not send branch_id.

Send rtype and record_id with the exact values below. record_id is the numeric id returned when you create or list that record.

rtype (exact value)Attaches torecord_id
invoiceInvoiceInvoice id
sales_orderSales orderSales order id
quoteQuoteQuote id
purchase_billPurchase billPurchase bill id
purchase_orderPurchase orderPurchase order id
expenseExpensejournals_id
incomeDepositjournals_id
transferTransferjournals_id
journalJournaljournals_id
customer_paymentCustomer paymentjournals_id
supplier_paymentSupplier paymentjournals_id

Use these strings as written. Do not send Expense, Income, Deposit, Customer_Payment, Supplier_Payment, or purchase. purchase_order is a purchase order, not a purchase bill. income is a deposit.

The caller needs edit access for that module. A retail invoice needs retail invoice edit access.

Get upload params​

GET https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document/upload-params
curl -X GET 'https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document/upload-params' \
-H 'Authorization: Bearer <personal_access_token>' \
-H 'SelectedBranchId: <numeric_branch_id>'

Any authenticated caller. Returns allowed file extensions and the size limit in megabytes.

Example response

{
"success": true,
"message": "Upload params fetched successfully",
"result": {
"extension": [
".doc",
".docx",
".jpeg",
".jpg",
".png",
".pdf",
".ppt",
".pptx",
".svg",
".xls",
".xlsx",
".csv",
".mov",
".avi",
".mp4",
".mkv",
".dwg",
".dxf",
".zip",
".rar",
".fig",
".ai",
".psd",
".skp",
".ifc",
".rvt",
".dae",
".3ds",
".obj",
".dxfx",
".ls11",
".ls12"
],
"size_limit": 10
}
}

size_limit is megabytes. extension values include the leading dot.

Create a document upload URL​

POST https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document/upload-url
curl -X POST 'https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document/upload-url' \
-H 'Authorization: Bearer <personal_access_token>' \
-H 'SelectedBranchId: <numeric_branch_id>' \
-H 'Content-Type: application/json' \
-d '{
"record_id": 4452,
"rtype": "invoice",
"file_name": "scan.pdf",
"file_size": 102400,
"extension": "pdf"
}'

Creates a draft document and a short-lived PUT URL. PUT the file bytes to upload_url before it expires. Do not send Authorization on that PUT.

Body

FieldRequiredTypeDescription
record_idYesnumberBill id or journals_id for the rtype
rtypeYesstringExact value from the Documents table above
file_nameYesstringOriginal file name. Maximum 200 characters
file_sizeYesnumberFile size in bytes. Must be greater than 0 and within size_limit
extensionYesstringFile extension with or without a leading dot. Must be in extension from Get upload params

Example request

{
"record_id": 4452,
"rtype": "invoice",
"file_name": "scan.pdf",
"file_size": 102400,
"extension": "pdf"
}

Example response

{
"success": true,
"message": "Upload URL generated",
"result": {
"file_id": 1025,
"upload_url": "https://...presigned-s3-put-url...",
"upload_method": "PUT",
"url_expires_at": "2026-10-19T10:35:00+00:00"
}
}

url_expires_at is five minutes after the URL is created.

Errors

  • record_id is Mandatory
  • rtype is Mandatory
  • file_name is Mandatory
  • file_size is Mandatory
  • extension is Mandatory
  • rtype must be invoice, sales_order, quote, purchase_bill, purchase_order, expense, income, transfer, journal, customer_payment, or supplier_payment
  • record_id is required
  • Invoice not found
  • Sales order not found
  • Quote not found
  • Purchase bill not found
  • Purchase order not found
  • Expense not found
  • Deposit not found
  • Transfer not found
  • Journal not found
  • Payment not found
  • Invalid file_size
  • Invalid file format
  • File exceeds upload size limit
  • Character limit of 200 exceeded for file_name
  • Unable to generate upload URL
  • Permission Denied

Confirm a document​

POST https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document
curl -X POST 'https://yoursite.ealsuite.com/?app=ealsuite_api/v1/document' \
-H 'Authorization: Bearer <personal_access_token>' \
-H 'SelectedBranchId: <numeric_branch_id>' \
-H 'Content-Type: application/json' \
-d '{
"title": "test data",
"file_id": 1025,
"record_id": 4452,
"rtype": "invoice"
}'

Publishes the draft from Create a document upload URL and attaches it to the record. Call this after the PUT to upload_url succeeds. file_id must be a draft created by the calling user in this branch.

Body

FieldRequiredTypeDescription
file_idYesnumberfile_id from the upload URL response
record_idYesnumberSame bill id or journals_id used to create the upload URL
rtypeYesstringSame rtype used to create the upload URL
titleNostringDisplay title. Must not contain special characters. When omitted or empty, the original file name without extension is used

Example request

{
"title": "test data",
"file_id": 1025,
"record_id": 4452,
"rtype": "invoice"
}

Example response

{
"success": true,
"message": "Document attached successfully",
"result": {
"id": 1025
}
}

Errors

  • file_id is Mandatory
  • record_id is Mandatory
  • rtype is Mandatory
  • rtype must be invoice, sales_order, quote, purchase_bill, purchase_order, expense, income, transfer, journal, customer_payment, or supplier_payment
  • record_id is required
  • Invoice not found
  • Sales order not found
  • Quote not found
  • Purchase bill not found
  • Purchase order not found
  • Expense not found
  • Deposit not found
  • Transfer not found
  • Journal not found
  • Payment not found
  • Document title should not contain special characters
  • Document not found
  • All Fields are Required
  • Permission Denied