Back to blog

Validating Romanian addresses via API

How POST /v1/addresses/verify works, what the "corrected" verdict means, and how to integrate validation at checkout without blocking the user.

The problem: Romanian addresses are not uniform

If you have ever built a shipping form or an onboarding flow with Romanian addresses, you know that data looks different from every user:

  • "Str. Mihai Vitezu 12" vs "Strada Mihai Viteazu nr. 12" vs "Mihai Viteazu 12, Cluj"
  • "ş" with cedilla vs "ș" with comma-below: same letter, different Unicode code points
  • "Cluj" vs "Cluj-Napoca": both correct, neither canonical

The result: duplicates in your database, failed deliveries and hard-to-debug reconciliation errors.

How Posty verification works

The POST /v1/addresses/verify endpoint accepts an address either as a free-form string or as structured fields:

{
  "freeform": "Str. Mihai Vitezu 12, cluj"
}

The response contains a verdict (verified, corrected, partial, unverifiable), per-field corrections and a confidence score:

{
  "verdict": "corrected",
  "confidence": 0.92,
  "input": { "street": "Mihai Vitezu", "house_number": "12", "locality": "cluj" },
  "normalized": {
    "postal_code": "400151",
    "locality": "Cluj-Napoca",
    "county": "Cluj",
    "county_code": "CJ",
    "street": "Strada Mihai Viteazu",
    "house_number": "12"
  },
  "corrections": [
    { "field": "street", "from": "Mihai Vitezu", "to": "Mihai Viteazu", "reason": "typo" },
    { "field": "locality", "from": "cluj", "to": "Cluj-Napoca", "reason": "locality_mismatch" }
  ],
  "unmatched": [],
  "metadata": { "source_versions": { "baseline": "infocod-2016-05" } }
}

Integration in practice

The most common pattern is validating at form-submit time, not post-processing:

1. On submit: send the address to /verify before saving to the database. 2. If verdict === "corrected": show the user the canonical form and ask for confirmation. 3. If verdict === "partial": unmatched names the field that could not be confirmed (e.g. street); ask the user for that field only. 4. If verdict === "unverifiable": block the order and request a corrected address. 5. Store the canonical form, not what the user typed. Reconciliation becomes trivial.

What determines the confidence score

The score reflects how well the fields you sent match: locality, street, house number and postal code each carry a weight, and a corrected field earns at most half of it. The postal code is not taken as given: it is compared with the code that covers the street and house number, and a wrong code is corrected and lowers the score. An exact address scores 1. An address with an unrecognised street drops below 0.60 and gets the verdict partial, with street in unmatched.

You can set your own acceptance threshold: some teams pass anything above 0.70, others require 0.90 before shipping without human confirmation.

Data sources

  • Poșta Română: the postal-code base, May 2016 edition
  • SIRUTA (INS): the Teritorial-Administrative units nomenclature

Every response includes the database version in metadata.source_versions, useful for auditing.