Unify V2 Responses and Errors
Unify V2 uses HTTP statuses to distinguish successful processing, document validation failures, and request or processing errors.
Your client should branch on the HTTP status first and then inspect the response body.
Successful document: HTTP 200
A successfully processed mapping or invoicing request returns a direct document result:
{
"documentId": "6a7eab425227e2981a38f486",
"message": "Your invoice was validated and is ready for submission.",
"Base64XML": "PEludm9pY2U+PC9JbnZvaWNlPg=="
}| Field | Description |
|---|---|
documentId | Complyance identifier for the persisted document. |
message | Human-readable outcome. Do not compare this text to determine success. |
Base64XML | Generated invoice XML encoded as Base64. |
debug | Optional diagnostics when debug: true is requested. |
Validation failure: HTTP 422
If source mapping succeeds but the converted GETS document or generated XML fails validation, the response contains structured findings:
{
"documentId": "6a7eab425227e2981a38f486",
"message": "Your invoice could not be validated. Review the errors and try again.",
"validationStage": "gets",
"errors": [
{
"code": "IBR-015",
"getsPath": "totals.amountDue",
"payloadPath": "invoice_data.amount_due",
"message": "An Invoice MUST have the Amount due for payment (ibt-115).",
"severity": "error",
"ruleSet": "ae:tax_invoice"
}
]
}| Field | Description |
|---|---|
documentId | Persisted document identifier when the document was created before validation failed. |
message | General validation-failure message. |
validationStage | gets when the canonical document failed validation or xml when generated XML failed validation. |
errors | Validation findings to correct before resubmission. |
errors[].code | Rule identifier when supplied by the validator. |
errors[].payloadPath | Location in your original source payload when it can be derived from the mapping. Start here when correcting data. |
errors[].getsPath | Location in the canonical GETS document. Use it to understand which mapped field failed. |
errors[].message | Human-readable explanation of the finding. |
errors[].severity | Validation severity when available. |
errors[].ruleSet | Rule set that produced the finding when available. |
Base64XML | May be present for an XML validation failure because XML was generated before XML validation. |
debug | Optional diagnostics when requested. |
code, getsPath, payloadPath, severity, and ruleSet may be null when the validator cannot provide that information. documentId, validationStage, Base64XML, and debug are optional. Build your client to tolerate missing or null fields.
A 422 is a document validation outcome, not a transport failure. Correct the source data or mapping as appropriate before sending the document again.
Invalid request: HTTP 400
Malformed JSON or a body that does not match the new request schema returns:
{
"code": "invalid_argument",
"message": "Invalid request."
}Other direct request checks can use the same code and message shape.
Check that:
- a single request has
country,environment,purpose,source,documentType, andpayloadat the request root; - a bulk request has
invoicesat the root and every item contains those document fields; - the request does not mix root document fields with the bulk
invoicesformat; purposeismappingfor the Integration Engine orinvoicingfor sending invoices;environmentissandboxorproductionfor every document;documentType.modifiersis present for every document, even when it is[]; and- the body contains valid JSON.
Authentication and processing errors
Errors raised during authentication, source resolution, or processing can use a smaller shape:
{
"error": "Source AES:1 was not found"
}Clients should support both error and message when displaying a non-validation failure.
HTTP status reference
| HTTP status | Meaning | Recommended client action |
|---|---|---|
200 | The document was converted and validated. | Store documentId; process Base64XML when required. |
400 | The JSON or request fields are invalid or unsupported. | Check the single or bulk request shape, required fields, and allowed values. |
401 | Authentication is missing or invalid. | Check the Authorization header and API key. |
403 | The caller lacks permission or the API key does not match environment. | Use a key for the requested workspace and environment. |
404 | The requested source or mapping could not be found. | Verify the source alias, version, country, document type, and workspace configuration. |
409 | The request conflicts with an existing resource or state. | Review the document identifier and current workflow state. |
422 | Mapping completed, but GETS or XML validation failed. | Read errors, beginning with payloadPath, and correct the data or mapping. |
429 | The rate limit was exceeded. | Respect the Retry-After header when present. |
500 | An unexpected server error occurred. Internal details are not exposed. | Retain the response and identifiers, then follow your agreed retry or support process. |
Recommended client handling
- Check the HTTP status before parsing outcome details.
- On
200, storedocumentIdand decodeBase64XMLif your workflow needs the generated XML. - On
422, retain the fullerrorsarray and show actionable messages without assuming optional fields exist. - On other failures, read
errorormessageand retain the response for troubleshooting. - Do not make workflow decisions by comparing human-readable message text.
- Retain
documentIdanddebug.requestId, when present, for support.
Example handling logic:
const response = await fetch(url, requestOptions);
const body = await response.json();
if (response.status === 200) {
saveDocumentId(body.documentId);
} else if (response.status === 422) {
showValidationFindings(body.errors ?? []);
} else {
showRequestError(body.error ?? body.message ?? 'Request failed');
}Troubleshooting
My request was routed to Unify V1
Confirm that new-api: true is present as an HTTP header on the exact POST /api/v3/unify request. It must not be in the JSON body. An invoices array can be used by both contracts; the header selects the contract, while Unify V2 bulk items use self-contained document fields without defaults.
I received HTTP 403
Confirm that the API key belongs to the correct workspace and environment. Sandbox/mock keys cannot be used for production requests, and production keys cannot be used for sandbox requests.
I received HTTP 404
Verify the complete source alias, including its version. Confirm that the mapping supports your workspace, country, and document type.
I received HTTP 422
Start with payloadPath to locate the source value. Use getsPath, code, and ruleSet to understand the canonical rule. If the source value is correct but the mapped GETS field is not, contact the team responsible for your source mapping.
Unify V1 error responses
Unify V1 uses a different bulk response and error model. If your request uses the defaults and invoices envelope, see the Unify V1 Error Codes instead.