China PDF Invoice Verification API
Verify an original Chinese PDF invoice through the API, preserve the source file, and distinguish a match from an upload or approval problem.
Verify a Chinese invoice from a Base64-encoded PDF document.

The PDF verification endpoint returns JSON. To make that result useful to finance, tie it to the exact PDF attachment you submitted. That gives this integration two practical jobs. First, deliver valid JSON containing the bytes of an issued Chinese VAT invoice PDF. Then keep the result associated with the original artifact, even if the finance team also uses a marked-up copy.
The ChinaValidate PDF invoice verification API can return an invoice verification outcome and available invoice details. Use this runbook to make the upload, distinguish a match from a technical failure and hand off a durable record to accounts payable.
1. Capture the original
Collect the original attachment before a reviewer opens an editable copy. Ask for the PDF the supplier originally downloaded or received through its invoicing channel. The email may also contain a packing list, commercial invoice or an internal bundle of several attachments. Identify the specific Chinese VAT invoice, often called a fapiao, before submitting it. A seller’s company name or a plausible total on a PDF attachment does not tell you which kind of document it is.
Use the original attachment or the issuer’s download feature. Saving a preview, printing to PDF and scanning a paper copy produce new files. If you have nothing but a scan or screenshot in a PDF wrapper, ask for the issued file. Where the printed fields are legible and your accounting owner allows field entry, the separate field verification endpoint can check those details. Record which route was actually used. A field lookup does not attach an authenticity result to the pixels of a scan.
| What you received | Role in the purchase record | Action |
|---|---|---|
| Original supplier PDF | File from the issuer’s delivery | Retain it and submit its original bytes to the PDF API. |
| Stamped or merged PDF | Approval markup or purchasing bundle | Retain as a working copy and retrieve the separate issued file. |
| Printout, scan or screenshot | Readable representation | Request the original file or verify the printed fields through the field route. |
| XML or OFD from the delivery | Separate electronic artifact | Retain it as appropriate and use a route that matches the artifact. |
China’s tax authorities describe digital invoice delivery in XML, PDF and OFD formats in their digital invoice questions and answers. They serve different practical needs. PDF is commonly used as a readable layout. Structured data can feed an accounting application. Preserve any original structured file that your process needs. The national electronic voucher accounting data standards notice explains the role of that structured data in electronic workflows. PDF verification covers one step in the wider process.
2. Encode and submit the PDF
Read the file in binary mode. Encode the complete byte sequence using standard Base64 and put the result in the JSON field file_base64. Send it to POST /v1/invoices/verify-pdf with a permitted bearer key and a JSON content type. A browser uploader can collect the attachment, but the backend should make the authenticated call. You can store the original in a restricted location and let the queue carry an internal storage reference.
The command below reads invoice.pdf from disk and passes JSON to cURL over standard input. Use an authorized original and set the API key in the environment before running it. The JSON string contains Base64 only. Do not add a data:application/pdf;base64, prefix. Encoding the original bytes makes the file safe to carry in JSON without replacing the original document on disk.
python3 - invoice.pdf <<'PY' | \
curl --silent --show-error 'https://api.chinavalidate.com/v1/invoices/verify-pdf' \
--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
Some upload widgets produce a data URL, and some command-line encoders insert line breaks for display. Read the original bytes rather than passing an existing preview URL or a copied Base64 display. Use a function that produces a continuous standard Base64 string and a JSON serializer that handles the surrounding object. If a local test can decode your generated value into the original file, it has already ruled out several intake bugs before sending a request.
Base64 expands the data by roughly one third before JSON overhead. Check your own application request limit, reverse proxy and worker memory against the files your suppliers actually deliver. Apply a suitable intake limit in your application and distinguish an oversized input from an API result. Recompressing an issued PDF changes the original, so retain that version if the team creates a smaller working copy. A request that never reached the verification service cannot tell the buyer anything about invoice authenticity.
For a first local test, stop before the outgoing request and compare the input file with a decode of file_base64. The byte sequences and hashes should agree. Compare the original browser upload with the file read by the worker as well if an intermediary thumbnails, optimizes or renames attachments. Keep the assertion in your integration test rather than printing Base64 to the console. The value can decode back to the complete invoice, including buyer and seller information.
Classify failures at the step where they occur. Your uploader can fail before reading the file. A reverse proxy can reject a request it considers too large. A JSON parser or the API can reject malformed content. The diagnosis for each is different. Compare the bytes before and after encoding for a local problem. Check the HTTP status and returned reason for a server-side request problem. In either case, leave the verification pending until you have a usable reply.
3. Branch on the returned state
This documentation sample shows a matched result. The amounts and nested party objects illustrate the response structure and are not a live invoice. Start with data.verification_status. Then check the fields needed by your purchase record. In this sample the seller is under data.seller, the buyer is under data.buyer, and the amounts and lines are in the same data object. Optional fields depend on the invoice and upstream record. Your interface can display a formatted amount while preserving the original response in the audit record.
{
"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"
}
]
}
}
The fixture shows a total of RMB 1,130.00. Consider a buyer who receives a matched result for that amount and sees that the seller taxpayer ID differs from the company selected earlier in the purchasing system. That is a party discrepancy. It can result from an overlooked affiliate, the wrong attachment or a genuine change in seller. Put the invoice in review and ask who issued it for the order. Similarly, an invoice can match the returned data and still be addressed to the wrong buying entity within the customer’s group.
Validation errors and timeouts go to the integration queue. A returned business mismatch goes to the invoice review queue. A malformed Base64 string calls for an encoding correction. If the API does not return a usable result, keep the invoice pending and show the technical issue. A returned mismatch calls for a document review. A new download from the supplier may help when the attachment was a working copy. Submitting the same bytes again simply repeats the original check, so look for a specific reason to retry.
- The client received a verification outcome.
- Save that outcome against the original PDF reference. On a match, compare the returned buyer and seller with the transaction. On a mismatch, make a document reviewer confirm which file was submitted and whether a fresh original is needed.
- The client received an error or no usable result.
- Save the failed attempt with its date, stage and error category. Release the job only according to your review or retry policy. A new attempt should be a separate event linked to the same original file.
A route can return an incomplete set of invoice details. Build the screen so a business result does not disappear simply because an optional field or line is unavailable. Compare fields that are present and flag a missing value only when it prevents the accounting decision. If you use a translated display, preserve the original party names and identifiers so procurement can perform the exact company comparison.
4. Record the AP handoff
A shared accounts payable mailbox might receive the same invoice twice. File hashing can identify an identical attachment and tell you which exact bytes your system verified. Use a separate invoice-level comparison when two files represent the same transaction. A PDF and OFD rendition may have the same invoice number and different hashes. An annotated PDF can also differ byte for byte while referring to the same payable. A file hash never establishes that a document was issued by the supplier. It gives your system a stable way to identify the file it already received.
Link the check result to a restricted original attachment and the purchase record. Keep the verification date, route, result and any review decision. Avoid placing the attachment, Base64 payload or API key in application logs. A purchase-file reviewer should be able to open the original according to existing permissions and see why the balance was posted, held or referred to procurement. The review need not expose the complete file to every staff member who can see the invoice status.
The Ministry of Finance and National Archives notice on electronic accounting vouchers associates electronic archiving with authenticity checks, reliable storage and controls such as preventing duplicate booking. It also addresses preserving the electronic original where a printout is used. Apply the retention rules that govern your organization. An API response can preserve evidence of a check, while the original invoice and related purchase documents explain the transaction that was checked.
When the input fails before verification, first confirm that it opens as the single invoice you expected. A failed attachment download can save a login page under a PDF name, and a mailbox rule can select the combined order bundle instead of the original invoice. A PDF signature at the beginning of the file only identifies a format and cannot establish who issued the invoice. If the file is password protected or unreadable in your normal workflow, obtain a readable original through an approved channel instead of stripping the protection or rebuilding the file yourself.
Consider the handoff after a correction. A supplier sends an original invoice, then issues a replacement after the buyer catches a party discrepancy. Preserve the first check as evidence of the first file. Add the replacement file and its result under a separate attachment reference, with an explicit relationship to the earlier invoice. A display flag such as “superseded in purchase record” should apply to the prior record that the buyer identified, rather than silently move the original check to the new document. This makes the eventual payment decision understandable to a reviewer who was not on the email thread.
Acceptance checklist
- Original PDF. Decode the generated request locally and compare it to the input to catch wrong encodings or changed files.
- Edited approval copy. Confirm your interface labels it separately and keeps the submitted original reachable.
- Different format. Use the OFD verification endpoint for an original OFD and preserve XML for the system designed to consume it.
- Party discrepancy. Exercise a sample match and an unexpected buyer or seller in your own test records. Show the verification outcome separately from approval.
- Technical failure. Confirm that an uncompleted request keeps the source file and next action visible to the reviewer.
One final walk-through can expose a handoff gap. Ask a colleague who never saw the email to trace an invoice from the approval screen back to its original file. They should be able to identify the checked version, the seller and buyer from the result, and any unresolved purchase issue. If they can see a green badge but cannot tell which attachment the badge describes, fix the link between the check and the file before relying on the integration to approve a payable.
Use the same checklist when you move intake to a new mailbox, storage service or procurement portal. It is easy to change attachment behavior without changing the API client. After migration, have one reviewer trace both a successful verification and an unresolved case back to their original files. If the new system can still display the file source, the result and the next action independently, the migration has retained the practical evidence trail.