China OFD Invoice Verification API

Send a Chinese OFD invoice to the verification API without conversion, reconcile the returned invoice, and preserve its original file.

ArticlesPublished by ChinaValidatePublished November 27, 2026Last updated November 27, 2026

Verify a Chinese invoice from a Base64-encoded OFD document.

View API documentationAPI workspace
China OFD Invoice Verification API

Keep the OFD issued for the invoice and the file you use to view it as separate artifacts. A PDF exported from an OFD can help a colleague see the layout, but the export cannot stand in for the original bytes when the application calls the OFD route. The same distinction applies to a screenshot or printed copy.

The ChinaValidate OFD invoice verification API takes the original OFD as Base64 in JSON at POST /v1/invoices/verify-ofd. Start by identifying what you actually received. The job aid below gives a route for each artifact and a record to leave for the next reviewer.

Route the received file

OFD intake job aid for a mixed-format delivery
Artifact Use in the integration Useful evidence to keep
Issuer-provided OFD OFD verification API Original bytes, supplier delivery source and the result.
Issuer-provided PDF PDF verification API, if a PDF check is the step you need Separate PDF reference and its own verification result.
XML companion file Accounting or archive workflow designed for structured data Keep the original structured file if your process requires it.
Screenshot, converted copy or preview Human reference or separately recorded field entry Identify the representation and record how it was obtained.

OFD stands for Open Fixed-layout Document. It is a fixed-layout electronic format described in China’s GB/T 33190-2016 standards listing. A layout format represents pages with their intended structure. The file extension tells your router which handling path to consider. It does not establish that the document is an invoice or that its contents came from the issuer you expect.

China’s tax administration describes XML delivery alongside PDF and OFD in its digital invoice questions and answers. Different representations can refer to the same invoice. A buyer may use a PDF to display it, an authorized application may use structured data for bookkeeping, and an OFD can remain the source artifact for the OFD verification route. This gives the purchaser a practical distinction between invoice identity and file format.

If a delivery email contains an archive, select the intended OFD attachment within the delivery under your normal controlled intake process. Sending the outer archive, a preview image or a file renamed to .ofd does not supply the original invoice bytes. When a filename contains a purchase or delivery number, use it as a routing hint only. The adjudicated link to a payable still comes from the invoice number and parties read from the invoice record.

Submit one native OFD

  1. Pin the original. Link the received OFD to the invoice evidence and pass its storage reference to the verification job.
  2. Prepare the request. Read the .ofd as bytes; encode those bytes with standard Base64. Place the uninterrupted encoded value under file_base64 in a JSON request body.
  3. Send it to the OFD route. Use a permitted bearer key on your server. The endpoint expects JSON without a data:…;base64, prefix or other wrapper around the Base64 string.
  4. Attach the outcome. Store the result on that artifact’s record so a display copy cannot silently inherit the check.

The command below reads a local invoice.ofd without converting it. Set the bearer key in the environment and use an original file you are authorized to submit. The demonstration keeps the encoded document in the request stream instead of printing it as a terminal argument. For integration testing, use the documented test environment and the response fixture to check your handler. For a live business check you need the actual document.

python3 - invoice.ofd <<'PY' | \
curl --silent --show-error 'https://api.chinavalidate.com/v1/invoices/verify-ofd' \
  --header "Authorization: Bearer ${CHINAVALIDATE_API_KEY:?Set CHINAVALIDATE_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data-binary @-
import base64
import json
from pathlib import Path
import sys

original = Path(sys.argv[1]).read_bytes()
print(json.dumps({"file_base64": base64.b64encode(original).decode("ascii")}))
PY

Once the JSON shape is correct, route by the artifact retained in your application. Consider storing the expected format alongside each attachment at intake. A correct Base64 string can still encode the wrong file, so checking that it decodes is useful but not sufficient. In local tests, decode the request and compare its bytes with the expected source. That catches accidental conversion, double encoding or substitution by a thumbnail service.

Record the artifact and result

The documentation example below shows a matched outcome. The sample values illustrate the contract and are not the result of querying a third party’s invoice. Read data.verification_status before using the details. In this example, the seller and buyer occupy their own objects and line items sit in the same data object. Preserve the returned values and account for fields that may not be present. Keep long invoice numbers as strings in your application.

{
  "code": 0,
  "msg": "ok",
  "data": {
    "verification_status": "matched",
    "invoice_number": "25322000000000123456",
    "invoice_type": "10",
    "issue_date": "2025-03-18",
    "net_amount": "1000.00",
    "tax_amount": "130.00",
    "total_amount": "1130.00",
    "seller": {
      "name": "苏州示例精密制造有限公司",
      "tax_id": "91320505MA00000005"
    },
    "buyer": {
      "name": "杭州示例工业设备有限公司",
      "tax_id": "91330100MA0000000C"
    },
    "line_items": [
      {
        "item_name": "精密加工零件",
        "quantity": "10",
        "unit": "件",
        "net_amount": "1000.00",
        "tax_amount": "130.00",
        "tax_rate": "0.13"
      }
    ]
  }
}

For an illustrative purchasing case, consider machining work ordered through a group purchasing team. The invoice verifies, but the buyer taxpayer ID in the response refers to a sister company. The accounting team can retain the verified invoice result and still route the payable to the correct entity for review. If the seller ID also differs from the onboarding record, ask the procurement owner who issued the document for that order and why. A verified invoice, a matched purchase order and a completed payment approval are separate pieces of the transaction.

A returned mismatch should go to document review. Verify that your team selected the exact OFD from the supplier, then inspect the outcome against the order evidence. If the request never reached the service, investigate the upload or network failure and keep the document pending. A failed Base64 conversion, an unavailable service and a mismatch require different next actions. Give reviewers the state they can act on instead of showing one red “verification failed” label for every case.

Resolve preview and delivery problems

An OFD will not open on a reviewer’s desktop. Keep the original and request a readable companion copy from the issuer if available. A viewer can help a reviewer read the visual invoice, but your application should submit the actual OFD bytes to the OFD endpoint. If the supplier sent only a PDF, use the PDF route for that original rather than renaming or converting it. For readable invoice fields without a suitable original file, the field verification route is another separately documented option.

Intake screens can make this decision easier by grouping several artifacts with the same invoice reference. Mark which copy was reviewed visually and which copy was submitted. Do not treat separate file formats as separate payable events simply because their hashes differ. Conversely, if two invoices share a seller and total but carry different invoice numbers, do not assume a duplicate. Escalate the discrepancy when a credit note, replacement or split shipment might explain it.

Use the collection of original documents required by your accounting team. The national notice on electronic voucher accounting data standards explains the role of original structured electronic vouchers in reception and accounting. The Ministry of Finance and National Archives notice also covers controls for electronic accounting vouchers and preserving a corresponding electronic original when a paper printout is used. Design your archive around the rules that apply to your organization. The verification result is useful evidence, but it should remain linked to the received artifact and related accounting records.

Build the attachment handoff into the supplier instructions. A workable request is “Please send the original OFD from your issuing system, with the PDF rendition if available.” This gives the sender two roles for two files. A request for “an invoice we can open” often comes back as a screenshot. When the delivery channel makes the original available through a download, record the date and source of the download and retain the resulting file with the transaction. If a supplier later corrects or replaces the invoice, treat the new document as a separate source artifact and link it to the superseded record. Attaching the replacement to the purchase is different from modifying the first file. Keeping that distinction visible lets the accounting reviewer identify whether the verification belongs to the original issue, its replacement or a separate adjustment.

Mailbox acceptance test

Use a mixed-format mailbox fixture as the final check. Include an original OFD and a readable PDF referring to the same invoice. Confirm that the OFD request captures the intended artifact and that your interface can show the PDF without changing which file receives the verification result. Next, test a delivery with a similarly named commercial invoice. It should stay linked to the purchase without being routed as the tax invoice. Finally, force a request failure and make sure the buyer can still retrieve the original OFD and understand whether a new upload or a retry is appropriate.

Review the storage and logging paths as well. The encoded value can be decoded back into the original invoice, so do not use payload logging as a troubleshooting shortcut. Prefer a request timestamp, an internal file reference, outcome and explanatory error category. Keep credentials on the server and restrict access to the original attachments according to the workflow. Then a reviewer can reproduce the path from delivery to verification without circulating the document across debugging tools.

The acceptance criterion is concrete. A teammate should be able to select the issued file, read the matched or unresolved outcome, and see which supplier and buyer were involved even if the OFD has no desktop preview. If that chain stays intact, adding a convenient PDF view will improve the intake experience without making the original of the invoice harder to find.