Ideal Postcodes CLI
idpc is the official command line interface for Ideal Postcodes. It manages API keys, cleanses messy addresses, lists the addresses at a postcode, validates emails and phone numbers and resolves specific addresses from partial queries.
It is built for LLM agents (Claude Code, Cursor, Codex) and CI/CD pipelines, and works equally well from a terminal.
Installation
Requires Node.js 22 or later.
npm install -g @ideal-postcodes/cli
idpc --versionAgent protocol
The CLI auto-detects non-TTY environments and emits JSON, so no --json flag is needed when piping or running headless.
- Supply ALL required flags. The CLI will NOT prompt when stdin is not a TTY.
-q, --quietsuppresses status output and implies--json.- Exit
0means success,1means error. - Both success and error JSON go to stdout. Parse it uniformly, then check for an
errorkey and the exit code:{"error":{"code":"...","message":"...","details":{}}} - Destructive commands (e.g.
keys configs delete) require--yesin non-TTY. - Use env vars or flags in automation. Never rely on
idpc auth loginfrom an agent.
Authentication
Two credentials: api_key (required) and user_token (required for /keys/* reads, configs and updates). Each credential resolves independently, in this order:
| Priority | Source |
|---|---|
| 1 (highest) | --api-key <k> / --user-token <t> |
| 2 | IDPC_API_KEY / IDPC_USER_TOKEN env var |
| 3 (lowest) | ~/.config/ideal-postcodes/credentials.json (written by idpc auth login) |
A missing api_key returns error code missing_api_key. A missing user_token on a command that needs it returns missing_user_token.
Global flags
| Flag | Description |
|---|---|
--api-key <k> | Override API key for this invocation |
--user-token <t> | Override user token |
--json | Force JSON (automatic in non-TTY) |
-q, --quiet | Suppress status, implies --json |
--base-url <url> | Override API base (diagnostics only) |
Commands
| Group | Subcommands |
|---|---|
idpc auth | login, logout, whoami |
idpc keys | get, details, update, usage, logs, configs {list,get,create,update,delete} |
idpc cleanse | Cleanse one address, a file or stdin |
idpc email | Validate one email, a file or stdin |
idpc phone | Validate one phone number, a file or stdin |
idpc postcode | List the addresses at a postcode |
idpc find / resolve | Autocomplete, with filters and bias, then resolve a suggestion id to a full address |
idpc doctor | Print environment info, verify connectivity and check key usability |
Run idpc <command> --help for full flags.
Common pitfalls
user_tokenis separate fromapi_key.keys details,keys usage,keys logs,keys updateand allconfigscommands require both.cleanse,email,phone,postcodeandresolvecost paid lookups. An unknown postcode costs nothing.findspends no lookup, but keys that autocomplete repeatedly without resolving are rate limited, then suspended.- Batch mode emits CSV unless
--jsonis passed; a single query always emits JSON. - Parse errors are JSON too. A missing argument (
idpc findwith no query) returnsmissing_argument; an unknown option, command or--filterkey returnsinvalid_input. findsuggestions end at the outward code (BR8). Use--filter postcode=...orresolveto pin the full postcode.keys logsemits raw CSV, not JSON, and rejects--json/-qwithinvalid_input. Redirect to a file or pipe into your CSV tooling.- The credentials file is
0600. If your umask is unusual,idpc auth loginmay fail withwrite_failed.
Quick examples
# Cleanse one address (JSON to stdout)
idpc cleanse "10 downing street, london"
# Batch cleanse
cat addresses.txt | idpc cleanse --stdin
# Validate an email or phone number
idpc email "support@example.com"
idpc phone "+442071128019" --carrier
# Batch validate emails to a CSV
cat emails.txt | idpc email --stdin > emails.csv
# List the addresses at a postcode
idpc postcode "BR8 7RE"
# Find a specific address within a postcode and resolve it
ID=$(idpc find "9 malyons" --filter postcode=BR87RE | jq -r '.suggestions[0].id')
idpc resolve "$ID"
# Inspect a key
idpc keys details