China PDF vs OFD Invoice Verification API
Route native PDF and OFD invoices by format, reconcile matching responses, and preserve the original files and invoice identity.
Verify a Chinese invoice from a Base64-encoded PDF document.

One Chinese invoice can reach an accounts team as a PDF and an OFD. The file formats determine which verification operation receives the attachment. The invoice identity determines whether the two records represent one payable document. A useful integration tracks both levels so it can preserve original files without treating two representations as two purchases.
ChinaValidate offers a PDF invoice verification API and a separate OFD invoice verification API. Both accept the original document encoded in the documented JSON shape and illustrate similar fields in the result. Start with the true format and retain a record of which attachment was sent. If a second file identifies the same invoice, link it with supporting evidence instead of discarding the original attachment or creating another payable.
Routing starts with the file that arrived
Recognize the original attachment format before sending an API request. Metadata from a reliable source can help choose a parser. Use a file-type check appropriate to the receiving system and preserve the original file. The extension of a renamed file is only a hint. When an OFD was rendered to PDF for viewing, keep the native original linked to that preview. Sending the original OFD to its endpoint preserves the record of which source document was actually evaluated.
The Shanghai tax authority describes distribution of fully digital invoices through its platform, including files in PDF, OFD or XML. The national tax administration's announcement on promoting fully digital electronic invoices describes the official invoice type and its legal effect. The steps a recipient uses to file an electronic accounting voucher depend on the applicable archival rules and the received material. Preserve relevant originals and required digital evidence independently of a verification response. Shanghai tax authority format guidance · State Taxation Administration announcement
A recipient can see a printed copy, a scan of a printout, a view generated by an accounting platform or the original document delivered by the issuer. These artifacts can look similar on a screen and carry different evidence. When the system cannot identify a suitable original, route the item for review or ask the sender for the native file. The separately documented invoice field verification operation can be appropriate when the team has the required source fields and its process calls for field-based verification.
Send the right format through the shared request shape
Use POST with JSON, send file_base64 as the Base64 encoding of the original bytes, and omit the data URL prefix. Supply authorization as documented. The recipient service should know whether it is submitting PDF or OFD before creating the body. Use the following example for files already identified as native PDFs or OFDs. The helper only encodes the file and passes the JSON to the selected, documented endpoint.
encode_invoice() {
python3 -c 'import base64,json,pathlib,sys; print(json.dumps({"file_base64":base64.b64encode(pathlib.Path(sys.argv[1]).read_bytes()).decode("ascii")}))' "$1"
}
encode_invoice 'invoice.pdf' |
curl -sS 'https://api.chinavalidate.com/v1/invoices/verify-pdf' \
-H "Authorization: Bearer ${CHINAVALIDATE_API_KEY}" \
-H 'Content-Type: application/json' --data-binary @-
encode_invoice 'invoice.ofd' |
curl -sS 'https://api.chinavalidate.com/v1/invoices/verify-ofd' \
-H "Authorization: Bearer ${CHINAVALIDATE_API_KEY}" \
-H 'Content-Type: application/json' --data-binary @-
Keep file contents, Base64 strings and credentials in the protected request path. The operator generally needs to know which original was routed, the detected format, endpoint, submission time and outcome. An ordinary log need not contain the invoice itself. Store or retrieve the protected attachment through the approved accounting record rather than repeatedly embedding it in new exports.
Read the application code and then examine the receipt-specific verification_status in the returned items when present. The documented statuses include matched, mismatch and not_found. Preserve the original result together with the attachment reference. An incomplete request, a valid lookup without a match and an actual mismatch need separate review paths. A new attempt with another artifact may be legitimate when the operator obtains a better original. Record that reason instead of swapping the file under the earlier verification record.
Reconcile attachments before the payable is created
A byte hash helps recognize an identical file delivered more than once. A PDF representation and an OFD representation of the same invoice normally have different bytes and hashes. Compare the verified identity fields separately. Keep the original invoice_number as a string, including leading zeros, and review the invoice_type, issue_date, seller and buyer tax identifiers, and total_amount where they are available and relevant. Use the organization's review policy when a value conflicts or is missing.
Suppose a fictional supplier emails a native OFD, then sends a platform-exported PDF for convenience. The buyer obtains matching verification information and compares the two representations. It can retain two attachment records and one payable if the evidence establishes the same invoice and there is no outstanding discrepancy. If the PDF shows a different buyer identifier, the team should compare originals and source records before accepting either as the payable. Matching amounts by themselves cannot resolve an identity conflict.
| Evidence at intake | Routing or reconciliation decision |
|---|---|
| Original native PDF | Use the PDF endpoint and preserve the original attachment reference. |
| Original native OFD | Use the OFD endpoint and preserve the original attachment reference. |
| Second file has a different hash but the invoice identity is confirmed | Link both artifacts to the reviewed invoice under the accounting policy. |
| Filename and detected artifact type conflict | Confirm the original format and get the intended source document when necessary. |
| Buyer, seller or other material identity detail differs | Reconcile the source evidence before linking files or admitting a payable. |
| Preview exists and its native original is available | Keep the relationship between them and route the native original as appropriate. |
A buyer can verify both versions when the decision calls for separate observations. A routine import can also choose one appropriate original for verification and attach the other as a reference after identity review. Establish that policy before processing a mailbox in bulk. Retain which attempts the organization actually submitted so an audit can relate invoices to the relevant responses and costs.
Test the mailroom and accounting handoff
Test genuine, authorized examples or local fixtures that represent the layouts your organization receives. Include a native PDF, a native OFD, an identical retransmission and two different files for one invoice. Add a mislabelled file and one invoice whose returned parties disagree with the purchase record. Make sure the leading zeros and original field meanings survive a CSV export or a transition into the accounts payable application.
If a request fails, retain the original so someone can retry the correct operation after identifying the problem. A replacement sent by the issuer should have its own receipt date and artifact reference. If the replacement represents a correction or a different invoice, ask the accounts team to apply the appropriate process to the actual invoice identity. The verification history can then show why one file was used and why another was not routed to payment.
One unified handoff can support both formats if it clearly distinguishes the received file, the submitted request and the verified business document. A reviewer should be able to recover all three and see the evidence linking them. That is what prevents format conversion, duplicate email or a convenient preview from quietly changing the invoice the organization approved.
Audit trail for a second delivery
Store a receipt event for each means of delivery. An OFD received in an approved supplier portal can be linked to a later PDF attached to email. Record the received filename, protected artifact identifier and format detection result. Preserve a reference to the verification attempt that used each file. If your organization already knows the invoice was received, the accounts team can still inspect which artifact supports it and whether the newer attachment brings a genuine correction.
A source system may issue deliberately different renderings for the same invoice. Check identity and decisive values from appropriate evidence, including the original delivery information. Record which fields the reviewer confirmed when they tied the two artifacts together. A second message can then join the existing review record without silently changing the attachment that supported the first verification.
Handle a conflict as a specific data issue. If a discrepancy involves the invoice number or legal buyer, ask the supplier to identify the actual document and obtain the original from the proper channel when available. If it involves net amount, tax or gross amount on otherwise matching artifacts, compare the original fields and their meaning before changing what gets posted. The approval and the verification observation are distinct records. Avoid replacing an earlier mismatch with a successful state without retaining the evidence that resolved the earlier disagreement.
For a large intake flow, measure the number of distinct received artifacts and the number of reviewed invoice identities independently. This makes duplicate delivery visible without charging it against ordinary invoice volume. Keep a separate count for verification attempts, especially where the same original was deliberately resubmitted after an error or another native format was submitted for a defined reason. Use the documented billing terms to reconcile completed requests and investigate discrepancies. API pricing and billing terms
The resulting review file answers three different dates: when the original was received, when the verification was attempted and when the accounts team accepted the invoice. This is valuable when a corrected attachment reaches the team after month end. The reviewer can reconstruct the evidence before and after the cutoff while keeping the relevant original available for accounting.