# Npi validate

`npi-validate` · version 1.0.0 · Identifiers & check digits · free, no key needed

Validate a 10-digit US National Provider Identifier using the Luhn formula with the constant 80840 healthcare prefix.

**Use when you need to: validate a national provider identifier · check an npi check digit · is this npi number valid.**

## Decide before calling

Read the [versioned contract](/v1/tools/npi-validate/versions/1.0.0) and the supported scope below. Reuse `npi-validate@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `npi-validate@1.0.0` for validate a national provider identifier. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- validate a national provider identifier
- check an npi check digit
- is this npi number valid
- verify a doctor's npi
- npi luhn check 80840
- check digit validation for a healthcare provider id

## Not supported

- a live NPPES registry lookup for the provider name or taxonomy
- enforcing the Type 1 (starts with 1) / Type 2 (starts with 2) allocation policy
- accepting hyphens, spaces or a labeled "NPI:" form (npi is taken exactly as given)

## Behavior

- npi is taken exactly as given: no stripping of spaces/hyphens, no case folding. Length != 10 returns reason wrong_length; length 10 but not all-digit returns reason invalid_character; both leave check_digit null.
- check_digit = npi[9], populated once length and charset pass, regardless of validity.
- Compute the Luhn check digit of the 14-digit payload '80840' + npi[0:9] (the constant prefix concatenated left of the 9-digit identifier part, never re-derived); compare it to check_digit for reason check_digit_mismatch.
- No leading-digit restriction is enforced: only the Luhn check digit is validated.

## Input

- `npi` (string, required): min length 1; max length 20

## Output

- `valid` (boolean, required)
- `reason` (one of null, "wrong_length", "invalid_character", "check_digit_mismatch", required)
- `check_digit` (string or null, required): pattern `^[0-9]$`

## Limits

- max npi bytes: 20

## Example

Request input:

```json
{
  "npi": "1234567893"
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "check_digit": "3"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "npi-validate",
  "version": "1.0.0",
  "input": {
    "npi": "1234567893"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/npi-validate/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"npi":"1234567893"}'
```

The machine-readable contract is at [/v1/tools/npi-validate/versions/1.0.0](/v1/tools/npi-validate/versions/1.0.0).

### CLI

```sh
node cli.mjs run npi-validate 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Imei validate](/tools/imei-validate): Validate a 15-digit IMEI's Luhn check digit or accept a 16-digit IMEISV, and split the TAC from the serial.
- [Iccid validate](/tools/iccid-validate): Validate a 19/20-digit ICCID's Luhn check digit, require the 89 major industry id, split issuer/account digits.
- [Iso6346 container validate](/tools/iso6346-container-validate): Validate an 11-character ISO 6346 container number's mod-11 check digit and split the owner code, category and serial.
- [Uk nhs number validate](/tools/uk-nhs-number-validate): Validate a 10-digit NHS number's modulus 11 check digit (NHS Data Dictionary); 11 minus remainder = 10 is never valid.
- [Upu s10 validate](/tools/upu-s10-validate): Validate a 13-char UPU S10 postal identifier's weighted mod-11 check digit, split service indicator and country.
- [Checkdigit validate](/tools/checkdigit-validate): Validate a full value's trailing check digit(s) against a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).
