Guided Tour: Transaction Services
This is a step-by-step guide to using Transaction Services for sending and receiving electronic business documents from a backend, such as an ERP system, in JSON format.
Transaction Services are used for creating or parsing electronic business documents with JSON metadata, which abstracts the underlying XML (or EDI) technical specifications.
- Documents are validated before delivery. Errors are returned if submitted data is inconsistent, but Unimaze will otherwise guarantee that documents are in compliance with syntax and business rules.
- For working with raw XML, please refer to Guided Tour: Messaging Services.
Sending electronic documents
-
Create a random unique identifier (GUID) and store internally. This will become the message identifier (
:mid), passed as themessageIdparameter when you submit the document. -
Prepare the JSON message and submit the business documents using, e.g.:\
POST /transactions/submit-invoicePOST /transactions/correct-with-creditPOST /transactions/submit-order
When including additional attachments in the message, ensure the parametermoreis set totrue. Otherwise set it tofalseto trigger processing and delivery of the message.
-
Optionally, stream a binary payload as attachment (e.g. timesheet, product description) using:\
POST /messages/:mid/documents
Send the file as the raw request body withContent-Type: application/octet-stream. ThecontentTypequery parameter is the file's own MIME type; supported are images, PDF, XLSX, CSV and plain text files. Setmoretotrueorfalsedepending on if processing can be triggered or not. If desired, setembedDocumenttotrue.
-
Follow the state of the message through webhooks: Unimaze sends a
messageStatusChangedevent each time the delivery status changes. The statesdelivered(delivered to the receiver),failed(there was an error) andparked(manually parked as handled) are final states.
To check the state at any time, for example if you may have missed an event, use:\GET /messages/:mid/status
This gives both delivery information and message handling traces.
-
Store the
referenceIdparameter for each document for later displaying the document(s), see Receiving electronic documents below.
Getting notified of incoming documents
To keep incoming documents from piling up in the inbox, set up a webhook endpoint for inbound messages. When a message is ready to be fetched, Unimaze sends your endpoint a deliveryNotified event. Fetch the documents into the ERP system as described below.
Once a day, also run a safety-net check with GET /messages?status=pendingdelivery&transfer=inbound, and handle any message that is still pending in the same way.
Fetching pending messages on a schedule instead (polling) is the legacy approach, supported for existing integrations. See Polling (legacy).
Receiving electronic documents
-
When a
deliveryNotifiedevent arrives, read the message from it:messageIdis the unique identifier (GUID), anddatais the message envelope, with theactionparameter and thereferenceIdof each document. -
If
validationStatusof a message is not approved, it has one or more validation errors. Either mark the message as delivered or parked so that it will be removed from the list of pending incoming messages. If you like to fetch validation errors or warnings use:\GET /messages/:mid/validations
-
Based on the
actionparameter, get business document data in JSON format using:\GET /transactions/submit-invoice?messageId=:midGET /transactions/correct-with-credit?messageId=:midGET /transactions/submit-order?messageId=:mid, etc.
Optionally, get any attached documents and store them if needed:\GET /messages/:mid/documents/{nameOrIndex}
-
Change the state of the message to delivered using:\
POST /messages/:mid/mark-as-delivered
Generally, marking the message delivered should be done as soon as possible (within minutes or hours).
-
To allow a user to view the document or any of the attached documents, use:\
GET /messages/display/:referenceId(optionally add the?lang=<language>parameter)
Updated 4 days ago
