Skip to content

Concept by Reed Tereski

ferrule

API reference

POST https://api.ferrule.example/v1/verify

Authentication

Send a key as a Bearer token on every request. Keys starting fr_sample_ are fake and only exist on this page. Ferrule shows a key once, then masks it, so store it when it is issued.

curl -s https://api.ferrule.example/v1/verify -H "Authorization: Bearer fr_sample_PUBLIC_not_a_real_key"

Request body

JSON. Leave out optional fields you do not have.

Request body fields
fieldtypepresentdescription
line1stringrequiredStreet number and name. Must contain a digit.
line2stringoptionalApartment, suite or unit.
citystringrequiredCity or town. Letters only.
regionstringUS, CATwo-letter code. Optional when country is GB.
postal_codestringrequiredMust fit the format for country.
countryenumrequiredOne of US, CA, GB.
geocodebooleanoptionalAdds coordinates to the response. Default false.
{  "line1": "118 tannery street",  "line2": "apartment 4",  "city": "Aldrefield",  "region": "oh",  "postal_code": "00014",  "country": "US",  "geocode": true}

Response body

Status 200 means Ferrule answered. Read verdict to learn the answer.

Response body fields
fieldtypepresentdescription
request_idstringalwaysQuote this when asking for support.
verdictenumalwaysOne of the four verdicts below.
deliverablebooleanalwaysTrue when mail can reach the returned address.
addressobjectalwaysThe address in postal case and abbreviation.
address.line2string | nullalwaysNull when no unit was sent.
address.regionstring | nullalwaysNull when no region was sent.
changes[]arrayalwaysEmpty when nothing changed. Case changes are not listed.
changes[].fieldstringper itemWhich address field changed.
changes[].fromstringper itemThe value you sent.
changes[].tostringper itemThe value returned.
changes[].reasonstringper itemFor example suffix_abbreviated.
geocodeobjectif requestedHolds lat, lng and precision. Left out when undeliverable.
{  "request_id": "req_a2dfa61b",  "verdict": "corrected",  "deliverable": true,  "address": {    "line1": "118 TANNERY ST",    "line2": "APT 4",    "city": "ALDERFIELD",    "region": "OH",    "postal_code": "00014",    "country": "US"  },  "changes": [    {      "field": "line1",      "from": "118 tannery street",      "to": "118 TANNERY ST",      "reason": "suffix_abbreviated"    },    {      "field": "line2",      "from": "apartment 4",      "to": "APT 4",      "reason": "unit_designator_standardized"    },    {      "field": "city",      "from": "Aldrefield",      "to": "ALDERFIELD",      "reason": "city_spelling_corrected"    }  ],  "geocode": {    "lat": 46.32,    "lng": -87,    "precision": "rooftop"  }}

Verdicts

deliverable
Mail can reach the address as sent.
corrected
Mail can reach the address once the listed changes are applied.
unit_required
The building has several delivery points and no unit was sent.
undeliverable
No delivery point exists at this address.

Errors

Every error has the same shape, so one handler covers them. A 422 returns every failing field at once, so a form can mark them all together.

Error body fields
fieldtypepresentdescription
error.typestringalwaysauthentication, invalid_request or rate_limit.
error.codestringalwaysStable. Branch on this, not on message.
error.messagestringalwaysWritten for developers. May change.
error.fields[]array422 onlyOne entry per field that failed. All failures are returned at once.
error.fields[].fieldstringper itemThe request field to fix.
error.fields[].codestringper itemFor example postal_code_format.
error.fields[].gotstring | nullper itemThe value you sent. Null when missing.
error.fields[].expectedstringper itemThe accepted format, in words.
error.retry_afterinteger429 onlySame value as the Retry-After header, in seconds.
request_idstringalwaysQuote this when asking for support.

401 Unauthorized

No key, or a revoked key. Does not count against the limit.

{  "error": {    "type": "authentication",    "code": "api_key_missing",    "message": "No API key was sent. Create a sample key and send it as a Bearer token."  },  "request_id": "req_7341f731"}

422 Unprocessable Content

The address could not be read. Nothing was looked up.

{  "error": {    "type": "invalid_request",    "code": "address_malformed",    "message": "3 fields failed validation. Nothing was looked up.",    "fields": [      {        "field": "line1",        "code": "street_number_missing",        "got": "Tannery Row",        "expected": "A street number and name, such as 118 Tannery Row",        "message": "line1 has no street number."      },      {        "field": "region",        "code": "region_format",        "got": "Ohio",        "expected": "A 2-letter code, such as OH",        "message": "region is not a 2-letter code."      },      {        "field": "postal_code",        "code": "postal_code_format",        "got": "OH-14",        "expected": "5 digits, or ZIP+4 as 12345-6789",        "message": "postal_code does not fit the US format."      }    ]  },  "request_id": "req_68b64701"}

429 Too Many Requests

Wait the number of seconds in the header, then retry once.

{  "error": {    "type": "rate_limit",    "code": "too_many_requests",    "message": "Sample keys allow 5 requests per 60 seconds. Wait 15 seconds, then retry.",    "retry_after": 15  },  "request_id": "req_7341f731"}

Rate limits

A sample key allows 5 requests per 60 seconds. The next one returns 429 with Retry-After: 15, and the limit clears when that time is up. Requests that return 422 count. Requests that return 401 do not.

Rate limit response headers
headersent onmeaning
X-RateLimit-Limit200, 422, 429Requests allowed in a window.
X-RateLimit-Remaining200, 422, 429Requests left in this window.
Retry-After429Seconds to wait before retrying.

Ferrule is an invented product. api.ferrule.example is a reserved host and does not resolve, so every response here comes from a simulator in this page. Addresses you type stay in its memory.

Ferrule is an invented company.

About this concept

The measure that sets this layout is time to first response: how long a developer waits between opening the docs and seeing the API answer. The docs home opens on a command with its response already printed, and the console lets you send before you have a key, because the 401 that comes back names the next step.

Errors get the same care as success because errors are what an integration shows you first. The 422 lists every bad field and jumps to its input, and the 429 counts down its Retry-After and holds the send button until the window clears.

The command is the call to action because copying it is the real first move, and other actions invert through one difference-blend layer, so a single hover rule holds on black, bone and acid.

Figma mockups

Ferrule desktop mockup in Figma.
Desktop, 1440 wide
Ferrule phone mockup in Figma.
Phone, 390 wide

Prototype map

3 screens and 6 prototype links, drawn from the Figma file.

Map of the Ferrule prototype: Docs home, Console and Reference, joined by 6 links.