Look up a country
Find a country's code and postcode rules by name or code. Returns at most 5 matches. Only needed when unsure of a code.
Request
| Field | Type | Notes |
|---|---|---|
query required | string | Country name or ISO code, e.g. 'germany', 'DE', 'DEU' |
from | string | Sender's country: decides which destinations are open (sendTo) Default: "GB". |
Examples
curl "https://p2g-mcp-sandbox.dotnethelp.workers.dev/v1/countries?query=germany"
As an MCP tool call over POST /mcp:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "lookup_country",
"arguments": {
"query": "germany"
}
}
}
Response
| Field | Type | Notes |
|---|---|---|
countries required | object[] | |
countries[].code required | string | Code to use in other tools, e.g. GB, DE, GB-NIR |
countries[].iso3 required | string | |
countries[].name required | string | |
countries[].sendFrom required | boolean | Parcels can be sent from here |
countries[].sendTo required | boolean | Parcels can be sent here |
countries[].postcodeRequired required | boolean | |
countries[].postcodePattern | string | Regex the postcode must match |
countries[].regions | object[] | Territories with their own code, chosen automatically from the postcode |
countries[].regions[].code required | string | |
countries[].regions[].postcodes required | string | Postcode prefixes that belong to it |
totalMatches required | integer |
Errors
Errors are problem JSON. Each issue names the field to fix and how to fix it. See every error code and its fix.