Skip to main content

idpc doctor

Check the environment, the credentials in use and whether the API key works. doctor is the first command to run when a key fails. It spends no lookup.

Usage​

idpc doctor

No flags beyond the global ones. It checks the key that --api-key, IDPC_API_KEY or the credentials file resolves to.

Output​

{
"cli": { "name": "@ideal-postcodes/cli", "version": "1.3.1" },
"runtime": { "node": "v24.13.1", "platform": "linux", "arch": "x64" },
"config": { "path": "/home/me/.config/ideal-postcodes/credentials.json" },
"credentials": { "api_key": { "source": "env" }, "user_token": null },
"connectivity": { "reachable": true },
"key": { "available": true, "diagnosis": [], "warnings": [] }
}
FieldMeaning
credentials.api_key, credentials.user_tokenWhere each credential came from: flag, env or config. null when not set
connectivity.reachabletrue when the API answered, false when the request failed in transit (connectivity.error says why), null when no API key is set and nothing was checked
key.availabletrue when the key can make lookups, false when the API refused it, null when the key was not checked: the API was not reached, or it answered with a rate limit or server error
key.lookups_remainingThe key's balance. Present only with a user token
key.diagnosisWhy the key is unusable, one sentence per cause
key.warningsProblems that do not stop the key working, such as a low balance or no user token

Exit code​

doctor exits 1 when the API is unreachable, the key is unusable or the key check did not complete, and 0 otherwise. The report prints either way, so read key.diagnosis before the exit code.

Diagnoses​

key.diagnosis starts withCauseFix
Key not foundThe API has no key with this valueCheck the key against https://ideal-postcodes.co.uk/account/ and which source supplied it (credentials.api_key.source)
No lookups remainingThe balance is 0Top up the key
Daily limit reached, Monthly limit reachedThe key hit a limit set on itWait for the limit to reset, or raise it with idpc keys update
Allowed URLs are setThe key is restricted to named URLs. The CLI sends no Origin, so the key reports unusable here and still works from those URLsUse an unrestricted key for the CLI
Key check failed [<code>]The API answered the check with another error. rate_limited and server_error leave key.available as null, since they say nothing about the key; any other code sets it to falseRetry after a rate limit or server error. Otherwise act on the error code
Key reports unusableThe key is unusable and its balance, limits and allowed URLs do not explain itContact support
Could not read key detailsThe user token was rejectedCheck IDPC_USER_TOKEN

Balance and limit diagnoses need a user token. Without one, doctor reports only whether the key is usable and adds a warning.

A failing key​

idpc doctor | jq '{reachable: .connectivity.reachable, key: .key}'
  • reachable: false: a network fault between you and the API. The key was not checked.
  • available: false: the API answered and refused the key. diagnosis holds the cause.
  • reachable: true and available: null: the API was rate limiting or failing. Run doctor again before judging the key.
  • available: true and a command still fails: the key works, so read that command's error code. Error codes lists them.