Document Attachments Realtime-enabled
GETPOSTTable: Document Attachment
Attach a file to almost any record. It writes to Business Central's standard Document Attachment table, so the file shows up in the Attachments factbox on the record and flows to posted documents like any manually added attachment.
Identify the parent record
Send a parentType (the kind of record) plus one of two keys:
- integrationId (the eOne external key already stamped on the record)
parentNumber(the Business Central number). TheintegrationIdtakes precedence if you send both.
parentType also carries the document type (e.g. salesOrder vs salesInvoice) so it lands on the right document.Receipts on staged documents
Staged ledger documents and expenses are attachable too, which is how an expense report arrives with the receipt that justifies it. Use stagedLedgerDocument for anything on the eOne Ledger Documents list, and stagedExpense for an expense report. The file shows up in the Attachments factbox on the eOne Expense Card and the eOne Ledger Document Card, so the person approving the document sees the receipt beside the amounts.
POST/documentAttachments
{
"parentType": "stagedExpense",
"integrationId": "EXPENSIFY-88214",
"fileName": "receipt.jpg",
"fileContent": "/9j/4AAQSkZJRgABA… (base64)"
}These documents have no Business Central number of their own, so parentNumber is their entry no. Send the integrationId instead wherever you can: it is the key you already have, and it is the one key that survives processing.
Supply the file: base64 or a public URL
Send the content one of two ways (only use one at a time):
- Inline base64 in
fileContent - A public
fileUrlthe service downloads server-side.
fileName (with its extension) is always required, as it drives the stored file name, extension, and file type.
POST/documentAttachments
{
"parentType": "salesOrder",
"integrationId": "SHOPIFY-1001",
"fileName": "packing-slip.pdf",
"fileContent": "JVBERi0xLjcKJ… (base64)"
}{
"parentType": "item",
"parentNumber": "1000",
"fileName": "spec-sheet.pdf",
"fileUrl": "https://cdn.example.com/specs/1000.pdf"
}As a child collection of the parent
documentAttachments is also exposed as an $expand child on the records it attaches to so you can pull a record together with its files in one call:
GET /customers(<id>)?$expand=documentAttachments
GET /salesOrders(<id>)?$expand=documentAttachmentsThe child is read + delete only: list a parent's attachments, or DELETE one. You cannot attach a file inline while creating the parent. POST to the top-level documentAttachments endpoint instead.
Reading a file back
GET echoes the resolved parentType and integrationId and returns the stored file as base64 in fileContent, alongside fileName, fileExtension, and fileType.
id (or use $select to omit fileContent) rather than listing the whole set with content.Immutable: delete and re-create to change
Attachments cannot be PATCHed. To replace one, DELETE and recreate it.
How long a file is kept
A file lives as long as the record it hangs on.
For most records that is the whole story. Staged documents are different, because a staged document is temporary by design, and the rules are worth knowing before you attach anything to one:
- Processed. The staged document is consumed and replaced by a processed document. Its files and notes move with it. The attachment keeps its own
id, soGET /documentAttachments(<id>)still returns the file afterwards, now reportingparentTypeprocessedLedgerDocumentorprocessedExpenseagainst the sameintegrationId. The move happens inside the same transaction as the posting, so a run that fails leaves the file on the staged document, ready for the retry. - Discarded. Deleting a staged document deletes its files. There is no processed document to move them to and nothing else names them, so a file left behind would be unreachable rather than merely misfiled.
- Aged out. Processed documents are subject to Business Central's standard retention policies. When a processed document is removed, whether by a retention policy or by an administrator deleting it, its files go with it. If a receipt has to outlive the accounting record, keep it somewhere outside Business Central as well.
integrationId, the parent must already carry that key. Ledger-entry tables (G/L Entry, Item Ledger Entry) are not supported: Business Central's Document Attachment does not attach to them.