🧾 Try it now, no code needed. Open the Input & output e-invoice lookup tool, enter your tax code and tax portal password, and the system pulls your invoices and lets you download them as JSON in a single click. Try it before integrating the API below.
What are input invoices and why automate them?
Input invoices (purchase invoices) are the e-invoices a business receives from suppliers when buying goods and services. This is required data for:
- Declaring and deducting input value-added tax: missing invoices means losing the right to deduct.
- Recording expenses and reconciling payables with suppliers.
- Corporate income tax finalization at the end of the period.
The problem: accountants have to log in manually to the General Department of Taxation's e-invoice portal (hoadondientu.gdt.gov.vn), filter by each date range, then download batch by batch, repeating every month, which is easy to miss and easy to get wrong. For a business with hundreds of invoices per month, this is hours of work.
TConnect's input invoice lookup API replaces all that manual work with a few API calls. The same set of APIs also pulls your output invoices (sales) that you issue to customers.
Try it now, no code needed: enter your tax code and tax portal password at the input & output e-invoice lookup tool, and the system pulls them for you and lets you download the JSON in a single click.
How the API works: "fetch on your behalf", no data tampering
The core principle: the system only fetches your exact invoices, without editing, processing, or changing the original data.
- The partner provides a tax portal account (tax code + password).
- The system automatically fetches and syncs invoices, both e-invoices and cash-register invoices, back to you, with no manual work.
- The data is encrypted and stored, then returned through the API as structured JSON, kept exactly as it appears on the tax portal.
Asynchronous by design: The tax portal limits each query to roughly 31 days and fetching data takes time. So the sync runs in the background (async): you create a request, receive a
jobId, then poll the status until it is done.
The 5-step integration flow
All the paths below are relative to the base URL:
https://sme-open-api-sandbox.tconnect.vn/openapi/v1/api-invoice
Every request needs two auth headers: Authorization: Bearer <access_token> and Partner-Code: <Merchant code>.
1. Register a tax portal account
curl -X POST "$BASE/tax-accounts" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC" \
-H "Content-Type: application/json" \
-d '{
"mst": "03123456789",
"password": "••••••••",
"initialSync": { "dateFrom": "2026-07-01", "dateTo": "2026-07-31" }
}'{
"id": "cf00eea0-af08-4e84-9aa3-e12d23b3a568",
"maskedMst": "03•••••789",
"status": "active",
"initialJob": { "id": "b6bf6a2a-9082-4882-b798-b35fc5985894", "status": "queued" }
}The id is the accountId used in the following steps. The tax portal password is encrypted as soon as it is stored.
2. Request an invoice sync
curl -X POST "$BASE/tax-accounts/$ACC/sync" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC" \
-H "Content-Type: application/json" \
-d '{ "dateFrom": "2026-07-01", "dateTo": "2026-07-31", "fetchDetails": true }'{ "id": "b6bf6a2a-9082-4882-b798-b35fc5985894", "status": "queued", "priority": 0 }fetchDetails: true→ also pulls the line items of each invoice (full detail).fetchDetails: false→ pulls only the header (faster and cheaper), used when you only need the summary list.direction:"purchase"pulls input invoices (default),"sold"pulls output invoices. To pull both in one pass, usedirections: ["purchase","sold"].- A date range longer than 31 days is automatically split into multiple windows.
3. Track progress
Poll until status = succeeded:
curl "$BASE/sync-jobs/$JOB" -H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC"{
"id": "b6bf6a2a-9082-4882-b798-b35fc5985894",
"status": "succeeded",
"totalFound": 42,
"totalSaved": 42
}The statuses: queued → running → succeeded | failed. If failed, errorCode tells you why, for example INVALID_CREDENTIALS (wrong password, needs updating) or SYNC_FAILED (sync error or network).
Suggested client-side poll logic:
function wait_for_sync(job_id):
loop:
job = GET /sync-jobs/{job_id}
if job.status == "succeeded":
return job
if job.status == "failed":
raise Error(job.errorCode, job.errorMessage)
sleep(3 seconds) // backoff nhẹ, tránh poll dồn dập4. Get the invoice list
Synced data sits in the system and can be queried instantly, with pagination and filtering:
curl "$BASE/invoices?accountId=$ACC&direction=purchase&dateFrom=2026-07-01&dateTo=2026-07-31&page=1&limit=20&sort=issueDate:desc" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC"{
"data": [
{
"id": "7b1e...c2",
"sellerTaxCode": "0101243150",
"sellerName": "CÔNG TY TNHH VẬT TƯ ABC",
"buyerTaxCode": "03123456789",
"invoiceSymbol": "C26TAB",
"invoiceNumber": "205",
"issueDate": "2026-07-18",
"totalBeforeTax": 1472727,
"totalTax": 147273,
"totalAmount": 1620000,
"currency": "VND"
}
],
"total": 42, "page": 1, "limit": 20, "totalPage": 3
}You can filter by sellerTaxCode, invoiceSymbol, invoiceNumber, issueDate. These are the plaintext columns kept for search.
5. View detail + line items
curl "$BASE/invoices/$INV" -H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC"{
"id": "7b1e...c2",
"invoiceSymbol": "C26TAB", "invoiceNumber": "205", "issueDate": "2026-07-18",
"sellerName": "CÔNG TY TNHH VẬT TƯ ABC", "sellerTaxCode": "0101243150",
"buyerName": "CÔNG TY CỔ PHẦN GIẢI PHÁP T CONNECT", "buyerTaxCode": "03123456789",
"totalBeforeTax": 1472727, "totalTax": 147273, "totalAmount": 1620000, "currency": "VND",
"taxBreakdown": [ { "taxRate": "10%", "amountBeforeTax": 1472727, "taxAmount": 147273 } ],
"items": [
{
"lineNumber": 1, "description": "Mực in laser HP 12A", "unit": "Hộp",
"quantity": 3, "unitPrice": 490909, "amount": 1472727,
"taxRate": "10%", "taxAmount": 147273, "totalAmount": 1620000
}
]
}items appear only when you sync with fetchDetails=true, or after calling POST /invoices/{id}/fetch-detail to pull the detail of exactly one invoice on demand.
Pull output invoices (sales) too
The same set of APIs pulls output invoices (the invoices you issue to customers) via the direction parameter:
direction: "purchase"pulls input invoices (default).direction: "sold"pulls output invoices.directions: ["purchase","sold"]pulls both directions in a single sync pass.
Sync both directions, then pull just the output list:
curl -X POST "$BASE/tax-accounts/$ACC/sync" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC" \
-H "Content-Type: application/json" \
-d '{ "dateFrom": "2026-07-01", "dateTo": "2026-07-31", "directions": ["purchase","sold"] }'
curl "$BASE/invoices?accountId=$ACC&direction=sold" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC"Each invoice returned has a direction field telling you whether it is input or output. That way, a single integration flow serves both input VAT reconciliation and tracking revenue and sales invoices.
Authentication & data security
This set of APIs shares the same JWT Bearer (Keycloak) + Partner-Code authentication mechanism as TConnect's other Open APIs (for example the payment API). On storage:
- The tax code is hashed with HMAC-SHA256, not stored in raw form.
- The tax portal password and sensitive fields (partner name, amounts, line items) are encrypted with AES-256-GCM.
- Only the columns used for search (
sellerTaxCode,buyerTaxCode,invoiceSymbol,invoiceNumber,issueDate) stay in plaintext.
Fetch only: the system does not edit, "clean up", or reinterpret the data. The numbers you receive are exactly the numbers on the tax portal.
Real-world uses
- Automating input accounting: sync invoices every month straight into your accounting software, dropping the manual download step entirely.
- VAT reconciliation: match input invoices against tax returns to catch discrepancies before the finalization period.
- Payables control: reconcile received invoices against purchase orders and contracts by
sellerTaxCode. - New invoice alerts: poll on a schedule, and when a new invoice appears, push a notification to accounting.
Conclusion
The input invoice lookup API fetches on your behalf the whole repetitive manual process, from logging into the tax portal to downloading each date range, packaged into a few API calls that run in the background. The data comes back clean, structured, securely encrypted, and kept exactly as the original from the General Department of Taxation.
Want to try it fast with no code? Use the input & output e-invoice lookup tool: enter your tax portal account, let it fetch for you, then download the JSON. See the full spec in the input & output invoice lookup API documentation, which includes a single-file version for AI Agents to integrate directly. Need a sandbox key to integrate? Contact TConnect.