Incoming Document Message Types

Parent Document: API_Reference.md Implementation Folder: app/src/Message Type/Implementations/IncomingDocument/


Overview

This document describes the Incoming Document message types in the Cloud Events API. These message types cover the full lifecycle of an Incoming Document in Business Central — from receiving a file, through optional additional attachments, processing into a purchase or journal document, to querying the document and its attachments.

Message TypeDirectionPurposeRelated Table(s)
Incoming.Document.CreateInboundCreate a new Incoming Document with a main attachmentIncoming Document (130), Incoming Document Attachment (133)
Incoming.Document.AttachInboundAdd supplemental attachments to an existing Incoming DocumentIncoming Document Attachment (133)
Incoming.Document.ProcessInboundProcess an Incoming Document to create a purchase invoice or journal lineIncoming Document (130)
Incoming.Document.GetOutboundRetrieve an Incoming Document with header fields and all attachmentsIncoming Document (130), Incoming Document Attachment (133)
Incoming.Document.SetDefaultInboundSet the default (main) attachment on an Incoming DocumentIncoming Document (130), Incoming Document Attachment (133)

Typical workflow:

  1. Call Incoming.Document.Create to upload the main file and create the Incoming Document.
  2. Optionally call Incoming.Document.Attach one or more times to add supplemental files.
  3. Call Incoming.Document.Process to create a purchase invoice or journal entry from the document.
  4. Call Incoming.Document.Get at any point to retrieve the current document state and all attachments.
  5. Call Incoming.Document.SetDefault to change which attachment is the main (default) attachment.

Incoming.Document.Create

Direction: Inbound Object IDs: Codeunit 65419 (IncomingDoc Create Impl), Codeunit 65423 (IncomingDoc Create Help)

Purpose

Creates a new Incoming Document in Business Central with a main attachment. The file content must be provided as a Base64-encoded string together with the file name.

Request Format

{
  "specversion": "1.0",
  "type": "Incoming.Document.Create",
  "source": "MyApp v1.0",
  "data": "{\"fileName\":\"invoice.pdf\",\"fileContent\":\"<base64-encoded content>\"}"
}

Request Fields

FieldTypeRequiredDescription
fileNameTextYesFile name including extension
fileContentTextYesBase64-encoded file content

Response Format

{
  "status": "Success",
  "entryNo": 1001,
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "lineNo": 10000,
  "description": "Purchase from Fabrikam",
  "documentDate": "2026-04-01",
  "dueDate": "",
  "vendorNo": "V10000",
  "vendorName": "Fabrikam Inc.",
  "documentStatus": "New",
  "dataExchangeType": "",
  "processed": false,
  "posted": false,
  "record": {},
  "error": []
}

Response Fields

FieldTypeDescription
statusText"Success" on success, "Error" on failure
entryNoIntegerEntry No. of the created Incoming Document
idTextSystemId (GUID without braces) of the created Incoming Document
lineNoIntegerLine No. of the main attachment
descriptionTextDescription of the Incoming Document
documentDateTextDocument date in ISO format
dueDateTextDue date in ISO format
vendorNoTextVendor number associated with the document
vendorNameTextVendor name associated with the document
documentStatusTextCurrent status of the Incoming Document
dataExchangeTypeTextData Exchange Type used for processing
processedBooleanWhether the document has been processed
postedBooleanWhether the document has been posted
recordObjectLinked BC record metadata (empty object if none)
errorArrayError messages from the Incoming Document (empty array if none). See Error Message Object Fields in Incoming.Document.Process for the full schema

Error Scenarios

ErrorCause
fileName is required.The fileName field is missing or empty
fileContent is required.The fileContent field is missing or empty

Incoming.Document.Attach

Direction: Inbound Object IDs: Codeunit 65422 (IncomingDoc Attach Impl), Codeunit 65426 (IncomingDoc Attach Help)

Purpose

Adds a supplemental attachment to an existing Incoming Document. The target document is identified by its Entry No. or SystemId in the subject field. The file content must be provided as a Base64-encoded string.

Request Format

{
  "specversion": "1.0",
  "type": "Incoming.Document.Attach",
  "source": "MyApp v1.0",
  "subject": "1001",
  "data": "{\"fileName\":\"delivery-note.xml\",\"fileContent\":\"<base64-encoded content>\"}"
}

Or by SystemId:

{
  "subject": "{a1b2c3d4-e5f6-7890-abcd-ef1234567890}",
  "data": "{\"fileName\":\"delivery-note.xml\",\"fileContent\":\"<base64-encoded content>\"}"
}

Request Fields

FieldTypeRequiredDescription
fileNameTextYesFile name including extension
fileContentTextYesBase64-encoded file content

Response Format

{
  "status": "Success",
  "entryNo": 1001,
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "lineNo": 20000,
  "description": "Purchase from Fabrikam",
  "documentDate": "2026-04-01",
  "dueDate": "2026-04-30",
  "vendorNo": "V10000",
  "vendorName": "Fabrikam Inc.",
  "documentStatus": "New",
  "dataExchangeType": "",
  "processed": false,
  "posted": false,
  "record": {},
  "error": []
}

Response Fields

FieldTypeDescription
statusText"Success" on success, "Error" on failure
entryNoIntegerEntry No. of the Incoming Document
idTextSystemId (GUID without braces) of the Incoming Document
lineNoIntegerLine No. of the newly created attachment
descriptionTextDescription of the Incoming Document
documentDateTextDocument date in ISO format
dueDateTextDue date in ISO format
vendorNoTextVendor number associated with the document
vendorNameTextVendor name associated with the document
documentStatusTextCurrent status of the Incoming Document
dataExchangeTypeTextData Exchange Type used for processing
processedBooleanWhether the document has been processed
postedBooleanWhether the document has been posted
recordObjectLinked BC record metadata (empty object if none)
errorArrayError messages from the Incoming Document (empty array if none). See Error Message Object Fields in Incoming.Document.Process for the full schema

Error Scenarios

ErrorCause
fileName is required.The fileName field is missing or empty
fileContent is required.The fileContent field is missing or empty
Incoming Document X not found.The subject does not match any Incoming Document

Incoming.Document.Process

Direction: Inbound Object IDs: Codeunit 65425 (IncomingDoc Process Impl), Codeunit 65429 (IncomingDoc Process Help)

Purpose

Processes an Incoming Document using the standard Business Central OCR/document processing flow, which attempts to create a purchase invoice or a journal line from the document.

Request Format

{
  "specversion": "1.0",
  "type": "Incoming.Document.Process",
  "source": "MyApp v1.0",
  "subject": "1001"
}

Or by SystemId:

{
  "subject": "{a1b2c3d4-e5f6-7890-abcd-ef1234567890}"
}

Response Format

{
  "status": "Success",
  "record": {
    "tableNo": 38,
    "tableName": "Purchase Header",
    "tableCaption": "Purchase Header",
    "recordSystemId": "c3d4e5f6-a1b2-7890-abcd-ef1234567890"
  },
  "entryNo": 1001,
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

On failure, a "status": "Error" response is returned with an "error" array containing the BC error messages that prevented the document from reaching Status = Created.

Response Fields

FieldTypeDescription
statusText"Success" when Incoming Document.Status = Created after processing; "Error" otherwise
entryNoIntegerEntry No. of the processed Incoming Document
idTextSystemId (GUID without braces) of the processed Incoming Document
recordObjectPresent on success. Table metadata for the linked BC document created from this Incoming Document
errorArrayPresent on failure. Array of BC error message objects that explain why processing did not reach Status = Created
record Object Fields
FieldTypeDescription
tableNoIntegerTable number of the linked BC document (e.g. 38 for Purchase Header, 81 for Gen. Journal Line)
tableNameTextInternal name of the linked document table
tableCaptionTextTranslated caption of the linked document table
recordSystemIdTextSystemId (GUID without braces) of the linked BC document
Error Message Object Fields

Each object in the error array has the following fields:

FieldTypeDescription
idIntegerError message ID
messageTextError message text
typeTextMessage type caption (e.g. "Error", "Warning")
tableObjectSource table — { "id": <tableNo>, "name": "<tableName>" }
fieldObjectSource field — { "id": <fieldNo>, "name": "<fieldName>" }
contextObjectContext — { "tableNumber": <int>, "fieldNumber": <int>, "fieldName": "<text>" }
additionalInformationTextAdditional information from the error message

Error Scenarios

ErrorCause
Incoming Document X not found.The subject does not match any Incoming Document
Incoming Document X has already been posted.The Incoming Document's linked document has been posted

Incoming.Document.Get

Direction: Outbound Object IDs: Codeunit 65431 (IncomingDoc Get Impl), Codeunit 65430 (IncomingDoc Get Help)

Purpose

Retrieves header information and all file attachments for an existing Incoming Document. Attachments are grouped into a mainAttachment object and an additionalAttachments array. File content is returned as Base64-encoded strings.

Request Format

{
  "specversion": "1.0",
  "type": "Incoming.Document.Get",
  "source": "MyApp v1.0",
  "subject": "1001"
}

Or by SystemId:

{
  "subject": "{a1b2c3d4-e5f6-7890-abcd-ef1234567890}"
}

The subject field accepts either:

Response Format

{
  "status": "Success",
  "entryNo": 1001,
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "description": "Purchase from Fabrikam",
  "documentDate": "2026-04-01",
  "dueDate": "2026-04-30",
  "vendorNo": "V10000",
  "vendorName": "Fabrikam Inc.",
  "documentStatus": "New",
  "dataExchangeType": "",
  "processed": false,
  "posted": false,
  "record": {
    "tableNo": 38,
    "tableName": "Purchase Header",
    "tableCaption": "Purchase Header",
    "recordSystemId": "c3d4e5f6-a1b2-7890-abcd-ef1234567890"
  },
  "error": [],
  "mainAttachment": {
    "lineNo": 10000,
    "fileName": "invoice.pdf",
    "fileContent": "<base64-encoded file content>"
  },
  "additionalAttachments": [
    {
      "lineNo": 20000,
      "fileName": "delivery-note.xml",
      "fileContent": "<base64-encoded file content>"
    }
  ]
}

Header Response Fields

FieldTypeDescription
statusText"Success" on success, "Error" on failure
entryNoIntegerIncoming Document Entry No.
idTextSystemId (GUID without braces)
descriptionTextDescription of the Incoming Document
documentDateDateDocument date in ISO format (yyyy-MM-dd)
dueDateDateDue date in ISO format (yyyy-MM-dd)
vendorNoCodeVendor No. from the Incoming Document
vendorNameTextVendor name from the Incoming Document
documentStatusTextStatus: New, Released, Rejected, or Posted
dataExchangeTypeTextData Exchange Type code configured on the Incoming Document
processedBooleanWhether the document has been processed
postedBooleanWhether the linked document has been posted
recordObjectLinked BC document metadata. Empty object when no document is linked
errorArrayBC error messages from the Incoming Document. Empty array when no errors. See Error Message Object Fields in Incoming.Document.Process for the full schema
record Object Fields
tableNameTextInternal name of the linked document table
tableCaptionTextTranslated caption of the linked document table
recordSystemIdTextSystemId (GUID without braces) of the linked BC document

Attachment Fields (mainAttachment and additionalAttachments entries)

FieldTypeDescription
lineNoIntegerAttachment line number
fileNameTextFile name including extension (e.g. invoice.pdf)
fileContentTextBase64-encoded file content

Notes

Error Scenarios

ErrorCause
Incoming Document X not found.The subject does not match any Incoming Document

Incoming.Document.SetDefault

Direction: Inbound Object IDs: Codeunit 65432 (IncomingDoc SetDef Impl), Codeunit 65433 (IncomingDoc SetDef Exec), Codeunit 65434 (IncomingDoc SetDef Help)

Purpose

Sets the default (main) attachment on an existing Incoming Document. The specified attachment is deleted and re-inserted as the first attachment (Line No. 10000) with the Main Attachment flag set to true. All other attachments are re-inserted after it in their original relative order.

Request Format

{
  "specversion": "1.0",
  "type": "Incoming.Document.SetDefault",
  "source": "MyApp v1.0",
  "subject": "1001",
  "data": "{\"lineNo\": 20000}"
}

Or by SystemId:

{
  "subject": "{a1b2c3d4-e5f6-7890-abcd-ef1234567890}",
  "data": "{\"lineNo\": 20000}"
}

Request Fields

FieldTypeRequiredDescription
lineNoIntegerYesLine No. of the attachment to set as the default (main) attachment

Response Format

{
  "status": "Success",
  "entryNo": 1001,
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Response Fields

FieldTypeDescription
statusText"Success" on success, "Error" on failure
entryNoIntegerEntry No. of the Incoming Document
idTextSystemId (GUID without braces) of the Incoming Document

Notes

Error Scenarios

ErrorCause
lineNo is required.The lineNo field is missing from the request
Attachment with lineNo X not found.No attachment with the specified Line No. exists on the document
At least 2 attachments are required to set a default.The document has fewer than 2 attachments
Incoming Document X not found.The subject does not match any Incoming Document

© Origo – Cloud Events Base Extension