What is a tax code lookup for?
When a new business signs up, pays, or issues an invoice to you, the one thing you usually have is a tax code. From that tax code you need to know: the full company name, registered address, managing tax office, legal representative, and whether it is still active.
Typing this information by hand is slow and error-prone, and a wrong name or address on an invoice can make the invoice invalid. The TConnect tax code lookup API returns all of that information from a single tax code, in one call.
Endpoint & parameters
GET /tax-code?tax={mst}
- No encryption needed, just pass
taxas a query parameter (unlike APIs that require AES). - Still uses the same Open API authentication:
Authorization: Bearer <access_token>+Partner-Code.
| Parameter | Type | Required | Description |
|---|---|---|---|
tax | string | ✅ | The tax code to look up |
Example API call
Look up TConnect's own tax code (0319074775):
curl "$BASE/tax-code?tax=0319074775" \
-H "Authorization: Bearer $TOKEN" -H "Partner-Code: $PC"Response:
{
"success": true,
"ma_so_thue": "0319074775",
"masothue_id": "0319074775",
"ten_cty": "CÔNG TY CỔ PHẦN GIẢI PHÁP T CONNECT",
"dia_chi": "232 Nguyễn Lương Bằng, Phường Tân Mỹ, Thành phố Hồ Chí Minh, Việt Nam",
"cqthuecap_tinh": "Chi cục thuế Hồ Chí Minh",
"cqthue_ql": "Thuế cơ sở 7 Thành phố Hồ Chí Minh",
"nguoi_dai_dien": null,
"ngay_thanh_lap": null,
"tthai": null,
"ten_tthai": null
}Response fields
| Field | Meaning |
|---|---|
ma_so_thue / masothue_id | The business tax code |
ten_cty | Full company/business name |
dia_chi | Registered business address |
cqthuecap_tinh | Managing provincial tax authority |
cqthue_ql | Directly managing tax office |
nguoi_dai_dien | Legal representative |
ngay_thanh_lap | Establishment date (YYYY-MM-DD) |
tthai / ten_tthai | Operating status code / name |
Some fields may be
nullwhen the tax authority does not publish the corresponding data for that tax code. Handlenullsafely on the client side.
Real-world uses
The tax code lookup API shows up at many touchpoints across B2B operations. Here are the most common situations.
1. Auto-fill an onboarding form from a tax code
The user only enters a tax code, and the rest fills in automatically:
function autofill_company_form(mst):
info = GET /tax-code?tax={mst}
if not info.success:
show_error("Không tìm thấy mã số thuế này")
return
form.company_name.value = info.ten_cty
form.address.value = info.dia_chi
form.tax_office.value = info.cqthue_ql
form.representative.value = info.nguoi_dai_dien or "" // có thể nullThe experience: type the tax code, see the company name right away, cut down on mistakes, and drop several manual input fields.
2. Fill in buyer details when issuing an e-invoice
This is the most important case. An e-invoice with the wrong buyer name or address can be treated as invalid, requiring an adjustment or replacement, costing time and creating tax risk. Instead of letting staff type it by hand, pull the registered details directly from the tax authority:
function build_invoice_buyer(mst):
info = GET /tax-code?tax={mst}
if not info.success:
raise Error("mã số thuế người mua không hợp lệ, không thể xuất hóa đơn")
return {
buyer_tax_code: info.ma_so_thue,
buyer_name: info.ten_cty, // ĐÚNG tên đăng ký thuế
buyer_address: info.dia_chi // ĐÚNG địa chỉ đăng ký
}Combined with an e-invoicing system, the flow "enter tax code, auto-fill buyer, issue invoice" becomes almost instant, with no more invoices carrying the wrong details.
3. Verify a business during KYB (Know Your Business)
Before opening an account, signing a contract, or granting a credit limit, compare the declared name against the official registered name:
function verify_business(mst, declared_name):
info = lookup_tax_code(mst)
// mã số thuế không tồn tại
if not info.success:
return { ok: false, reason: "mst_not_found" }
// Tên khai báo lệch quá nhiều với tên đăng ký
if similarity(declared_name, info.ten_cty) < 0.7:
flag_for_manual_review(mst, declared_name, info.ten_cty)
return { ok: true, official_name: info.ten_cty }4. Check the operating status of a tax code
The tthai / ten_tthai fields show whether a business is still active or has stopped, suspended operations, abandoned its address, and so on. Very useful for blocking transactions with risky partners:
function is_safe_to_transact(mst):
info = lookup_tax_code(mst)
if not info.success:
return false // mã số thuế không tồn tại
// Trạng thái bất thường → cảnh báo trước khi giao dịch/xuất hóa đơn
if info.ten_tthai is not null and "ngừng" in lower(info.ten_tthai):
warn("Đối tác đang ở trạng thái: " + info.ten_tthai)
return false
return true5. Reconcile suppliers on incoming invoices
When you receive a purchase invoice, reconcile the sellerTaxCode against the lookup result to catch suppliers that have stopped operating or data that does not match. This pairs naturally with the incoming invoice lookup API:
function reconcile_supplier(invoice):
info = lookup_tax_code(invoice.sellerTaxCode)
if not info.success:
flag("mã số thuế người bán không tra được", invoice.id)
else if similarity(invoice.sellerName, info.ten_cty) < 0.8:
flag("Tên người bán lệch với đăng ký thuế", invoice.id)6. Enrich CRM data / customer directories in bulk
Have a list of tax codes but missing standardized names and addresses? Run a batch to normalize everything (remember to cache and rate-limit):
function enrich_customers(mst_list):
for mst in mst_list:
info = lookup_tax_code_cached(mst) // xem phần Cache bên dưới
if info.success:
update_customer(mst, name=info.ten_cty, address=info.dia_chi,
tax_office=info.cqthue_ql)7. Validate a tax code on payment and contract forms
The moment a customer enters a tax code into a B2B payment or contract form, call the lookup to confirm the tax code is real and show the company name for the customer to double-check, reducing mix-ups and later disputes.
Cache to optimize cost and speed
Business information changes very rarely. For tax codes looked up repeatedly, cache them:
function lookup_tax_code_cached(mst):
cache_key = "taxcode:{mst}"
cached = cache.get(cache_key)
if cached exists:
return parse_json(cached)
result = GET /tax-code?tax={mst}
// Chỉ cache khi tra cứu thành công; TTL vài ngày là hợp lý
if result.success:
cache.set(cache_key, result, ttl = 7 days)
return resultCaching lowers latency and saves on billed requests.
Conclusion
Tax code lookup is a small API, but it shows up everywhere in B2B operations: onboarding, KYB, invoicing, supplier reconciliation. With just a tax code, you get standardized company details straight from the tax authority, no complex encryption, integrated in a few minutes.
See the full spec in the tax code lookup API documentation. Need a sandbox key to try it? Contact TConnect.