Identifier detector
US National Provider Identifier (NPI): format, validation and detection
Short answer
A US NPI has 10 digits, starts with 1 or 2, and ends in a Luhn check digit calculated as if the prefix 80840 were written in front of the number.
What it is
The National Provider Identifier identifies healthcare providers in the US under 45 CFR 162.406, the rule cited in Maskflare's validator. It sits in the Healthcare (PHI) pack, so the HIPAA Safe Harbor, UK GDPR and Swiss nDSG health profiles include it.
In Maskflare this is the detector us_npi, labelled "US - National Provider Identifier (NPI)", category health id number, in the Healthcare (PHI) pack.
Format and layout
- Ten digits with no separators.
- The first digit is 1 or 2.
- The tenth digit is the check digit.
How the check works
Put 80840 in front of the ten digits and run the Luhn algorithm over the fifteen digits: double every second digit counting from the right, subtract 9 from any result over 9, add everything up, and require a multiple of 10.
Worked example
- Prefixed number: 80840 1234567893.
- Luhn over those fifteen digits gives a total that is a multiple of 10, so 1234567893 passes.
- Changing the last digit to 0 breaks the total, which is how the invalid example fails.
Valid and invalid examples
| Example | Result | Why |
|---|---|---|
1234567893 | Valid | Matches the layout and passes the validator. |
1234567890 | Invalid | The invalid example changes one character, the last character: 3 becomes 0. |
In running text the valid example reads, for instance, NPI: 1234567893. The invalid one is left alone: a value that fails the validator is treated as an ordinary string.
Regex and validation caveats
- Ten-digit numbers are common, so a keyword is required before the number: NPI, national provider identifier, billing provider or prescriber NPI.
- The detector accepts only the bare ten digits; a value with a space or hyphen inside is not matched.
- An NPI identifies a provider, who can be a sole practitioner, so it can identify a person.
Words that confirm it
The detector masks a match only when one of its keywords appears within 48 characters before the value. The catalogue lists 8: billing provider, national provider id, national provider identifier, npi, prescriber npi, provider npi, referring provider, rendering provider.
How to detect it in LLM traffic
US National Provider Identifier (NPI) values appear in referral letters, lab reports, claims exports, appointment lists and clinical notes. When a clinician or administrator asks an assistant to summarise or rewrite such a document, the identifier goes with the text even though the task does not need it.
Maskflare scans the whole request, replaces each match with a token and, with response restoration on, puts the real value back into the answer for the person who is allowed to see it. Health identifiers sit in the Healthcare (PHI) pack, which is on in the default template without a country choice.
If you build the detection yourself
- Strip spaces, dots and hyphens before running any arithmetic, but remember where they were so the original text can be replaced exactly.
- Match the shape with a pattern anchored on word boundaries, so that a long digit string is not read as several shorter US National Provider Identifier (NPI) candidates.
- Apply the layout rules from the section above. This identifier has no check digit to recompute, so expect more look-alikes than with a checksum-based format.
- Require one of the words listed above shortly before the value. Maskflare looks back 48 characters.
- Replace the value before the text is sent anywhere, and keep a mapping if the answer has to be restored afterwards.
How Maskflare handles it
- Protect now, Finance - Protect now and Healthcare: mask (a reversible token).
- Developer: not turned on.
- Monitor first: alert (counted, forwarded unchanged).
The available actions are mask (reversible token), redact, partial, hash, format-preserving encryption, generalize, alert and block. Masked values are kept encrypted for 30 days so that answers can be restored, then they expire; prompts and responses are not logged. The full list of detectors is in the detector reference.
Compliance profiles that include it
3 of the 6 compliance profiles include the Healthcare (PHI) pack, and applying them turns this detector on: HIPAA Safe Harbor, UK GDPR and Switzerland - nDSG health data. A profile is a floor: it never turns anything off or weakens a rule that is already stricter.
Frequently asked questions
Why is 80840 added before the Luhn check?
The NPI's check digit is defined that way. Without the prefix the Luhn result would not match the published algorithm.
Is the NPI masked by default?
Yes, in Maskflare's default template, because it belongs to the Healthcare (PHI) pack. Monitor first only alerts.
Is the US National Provider Identifier (NPI) detector on by default?
Yes. It belongs to the Healthcare (PHI) pack, which the default Protect now template turns on with the action mask.
Does a valid US National Provider Identifier (NPI) prove the person exists?
No. This identifier is validated on its layout alone, so a passing value is only well formed, not known to be real.
Rules on this page describe what Maskflare's detectors and validators check. They are read from the detection catalogue and are not the specification of the body that issues the identifier. Examples are synthetic.