# Programmatic Handling of E-Invoice Schema Errors

Parse validation error arrays, resolve structural XML issues, handle UBL/CII namespace mismatches, and automate corrections programmatically.

## Parsing the validation payload

When an invoice fails schema validation, the API returns a structured JSON payload containing a detailed list of errors instead of a converted XML file. Programmatic handling allows your system to automatically fix simple issues or route complex errors to human reviewers.

The error response contains a VALIDATION_FAILED status code along with an array of error objects. Each object provides a specific path to the failing field, the value that caused the error, and a human-readable description of the compliance rule that was violated (e.g., BR-CO-13).

## Automating common resolutions

- For missing BuyerReference, query your customer database for the default Leitweg-ID and retry.
- For rounding mismatches (e.g. PayableAmount differences), automatically apply a minor rounding adjustment of up to 0.02 currency units.
- For invalid unit codes (such as using PCE instead of standard C62), map the values programmatically before sending.

## Retry vs. manual escalation

- Automated Retry: Safe for temporary connection errors, rate limits, or quick schema fixes.
- Manual Review: Required when totals are significantly different, bank details are missing, or tax categories are ambiguous.
