HALPII Tax ID in Excel
Last reviewed 2026-11-21 · HALPII S.A.C.
Two ways to validate tax IDs in Excel: an add-in with custom functions such as =HALPII.TAXID(country; id), and a Power Query function that adds the verdict, legal name and status to a table.
The add-in: =HALPII.TAXID
| Formula | Returns |
|---|---|
=HALPII.TAXID(country; id) | The verdict: pass, review or fail |
=HALPII.TAXID_MOTIVO(country; id) | The verdict and its reasons |
=HALPII.TAXID_NOMBRE(country; id) | The legal name, when the source publishes it |
Excel always puts the add-in’s namespace and a dot before a custom function, so the formula is HALPII.TAXID, where Google Sheets has HALPII_TAXID. A Clave Tax ID button on the Home tab stores your key in the add-in’s storage on that computer, not in the workbook; it is sent as X-API-Key. The three formulas share one request per ID, answers are kept for 6 hours while Excel is open, and at most 4 requests run at a time. A 429 or 503 with a wait of 10 seconds or less is retried once; otherwise the cell shows #N/A with the reason on hover.
It needs Excel for Microsoft 365 (web, Windows or Mac) or Excel 2021 or later, with shared-runtime custom functions. Loading it means sideloading: you serve the add-in’s files at https://localhost:3000 with Node.js and a development certificate, then upload manifest.xml under Add-ins → My Add-ins → Upload My Add-in (web), or copy it to Excel’s wef folder (Mac) or a trusted shared folder (Windows). For a team, host the files on any HTTPS site and change the URLs in the manifest; a Microsoft 365 administrator can deploy it to the organization without AppSource.
Power Query: paste a function
- Select Data → Get Data → From Other Sources → Blank Query, open Advanced Editor, paste the function below and select Done. Rename the query to
HalpiiTaxId. - Put your suppliers in a table named
Supplierswith the columnsCountryandTax ID. Optional: put your API key (100 lookups a month at no cost) in a one-cell table namedHalpiiKey; anyone with the workbook can read it. - Create a second blank query with the example below and select Close & Load. When Excel asks how to connect to
https://taxid.halpii.com, choose Anonymous: the key travels in theX-API-Keyheader.
The table comes back with six more columns: Verdict, Legal name, Status, Verification level, Data as of and Reasons. Rows are paced 300 ms apart; a failed lookup shows error and the HTTP status in Reasons. There is no cache: each refresh counts every row again.
The function: HalpiiTaxId
// HALPII Tax ID for Power Query (Excel and Power BI): one function that validates one tax ID.
// Paste this into a blank query named HalpiiTaxId (Data → Get Data → From Other Sources → Blank Query →
// Advanced Editor). Returns a record with Verdict, Legal name, Status, Verification level, Data as of, Reasons.
// MIT licence · HALPII S.A.C. · https://taxid.halpii.com/integrations/excel
let
HalpiiTaxId = (country as any, id as any, optional apiKey as nullable text) as record =>
let
cc = Text.Upper(Text.Trim(Text.From(country))),
value = Text.Trim(Text.From(id)),
// Peru, Mexico, Colombia and Costa Rica have their own routes; every other country uses /v1/validate.
dedicated = [PE = "pe/ruc", MX = "mx/rfc", CO = "co/nit", CR = "cr/cedula"],
route = Record.FieldOrDefault(dedicated, cc, null),
relative = if route <> null then "v1/" & route & "/" & Uri.EscapeDataString(value) else "v1/validate",
query = if route <> null then [] else [country = cc, id = value],
headers =
if apiKey = null or apiKey = "" then
[Accept = "application/json"]
else
[Accept = "application/json", #"X-API-Key" = apiKey],
raw = Web.Contents(
"https://taxid.halpii.com",
[
RelativePath = relative,
Query = query,
Headers = headers,
ManualStatusHandling = {400, 401, 403, 404, 429, 503}
]
),
status = Value.Metadata(raw)[Response.Status],
body = try Json.Document(raw) otherwise [error = "The answer was not JSON."],
isResult = status = 200 or (status = 400 and Record.HasFields(body, "format_valid")),
assessment = Record.FieldOrDefault(body, "assessment", []),
statusRecord = Record.FieldOrDefault(body, "status", null),
sourceRecord = Record.FieldOrDefault(body, "source", null),
reasons = Text.Combine(Record.FieldOrDefault(assessment, "reasons", {}), " "),
ok = [
Verdict = Record.FieldOrDefault(assessment, "verdict", null),
#"Legal name" = Record.FieldOrDefault(body, "legal_name", null),
Status = if statusRecord = null then null else Record.FieldOrDefault(statusRecord, "label", Record.FieldOrDefault(statusRecord, "code", null)),
#"Verification level" = Record.FieldOrDefault(body, "verification_level", null),
#"Data as of" = if sourceRecord = null then null else Record.FieldOrDefault(sourceRecord, "data_as_of", null),
Reasons = if Record.HasFields(body, "error") then reasons & " " & body[error] else reasons
],
failed = [
Verdict = "error",
#"Legal name" = null,
Status = null,
#"Verification level" = null,
#"Data as of" = null,
Reasons = "HTTP " & Text.From(status) & ": " & Text.From(Record.FieldOrDefault(body, "error", ""))
]
in
if cc = "" or value = "" then failed & [Verdict = null, Reasons = null]
else if isResult then ok
else failed
in
HalpiiTaxId
The example query: CheckSuppliers
// Example: validate every row of an Excel table named Suppliers with the columns Country and Tax ID.
// The API key is read from a one-cell table named HalpiiKey (anyone with the workbook can read it: keep the
// workbook private, or leave HalpiiKey empty to use the keyless allowance).
// Rows are paced 300 ms apart so a large table does not run into the per-minute safety limits.
let
Source = Excel.CurrentWorkbook(){[Name = "Suppliers"]}[Content],
KeyTable = try Excel.CurrentWorkbook(){[Name = "HalpiiKey"]}[Content] otherwise null,
ApiKey = if KeyTable = null or Table.RowCount(KeyTable) = 0 then null else Text.From(Table.FirstValue(KeyTable)),
Checked = Table.AddColumn(
Source,
"Check",
each Function.InvokeAfter(() => HalpiiTaxId([Country], [Tax ID], ApiKey), #duration(0, 0, 0, 0.3)),
type record
),
Expanded = Table.ExpandRecordColumn(
Checked,
"Check",
{"Verdict", "Legal name", "Status", "Verification level", "Data as of", "Reasons"}
)
in
Expanded
What the verdict means
| Verdict | Meaning |
|---|---|
| pass | Registered and in good standing per the official source |
| review | Needs a human look: an unusual status, a not-found the source cannot rule out, or a check that stopped at the format. Mexico RFCs never get pass, because Mexico publishes no RFC registry |
| fail | Malformed, wrong check digit, not active, or on a tax-authority list |
MIT licence. Source: folder excel of the halpii-taxid-integraciones repository. Excel and Power Query are trademarks of Microsoft Corporation. HALPII Tax ID is an independent service run by HALPII S.A.C. and is not affiliated with or endorsed by Microsoft or by any tax authority.