Skip to main content

POST /api/validate

Check whether a postal code exists. Unlike Lookup, this endpoint returns valid: true or valid: false instead of throwing an error for unknown codes.

Request

POST https://postaldatapi.com/api/validate
Content-Type: application/json

Body Parameters

ParameterTypeRequiredDescription
zipcodestring or numberYesThe postal code to validate
apiKeystringYesYour API key
countrystringNoISO 3166-1 alpha-2 country code (default: "US")

Response

Valid postal code (200)

{
"valid": true,
"zipcode": "90210",
"responseTime": "0ms",
"performance": { "totalTime": "2ms" },
"balance": 4.99
}

Invalid postal code (200)

{
"valid": false,
"zipcode": "00000",
"responseTime": "0ms",
"performance": { "totalTime": "1ms" },
"balance": 4.99
}

Response Fields

FieldTypeDescription
validbooleantrue if the postal code exists, false otherwise
zipcodestring or numberThe postal code that was validated (echoed back)
performanceobjectTiming breakdown
balancenumberAccount balance after this query (USD)
tip

Both valid and invalid postal codes return HTTP 200. Check the valid field to determine existence.

Examples

# Valid US ZIP
curl -X POST https://postaldatapi.com/api/validate \
-H "Content-Type: application/json" \
-d '{"zipcode": "90210", "apiKey": "YOUR_API_KEY"}'

# Valid UK postcode
curl -X POST https://postaldatapi.com/api/validate \
-H "Content-Type: application/json" \
-d '{"zipcode": "SW1A", "country": "GB", "apiKey": "YOUR_API_KEY"}'

Errors

StatusErrorCause
400Missing required field: zipcodeNo zipcode in request body
401Invalid API keyAPI key does not exist or was revoked
402Insufficient balanceAccount balance is zero
429Rate limit exceededToo many requests

SDK Examples

from postaldatapi import PostalDataPI

client = PostalDataPI(api_key="YOUR_API_KEY")

result = client.validate("90210")
print(result.valid) # True
print(result.postal_code) # 90210

# UK postcode
gb = client.validate("SW1A", country="GB")
print(gb.valid) # True