Cross-border legal processes, like inheritance cases, generate a surprising amount of document workflow complexity. If you've ever built an internal tool for a legal ops team, a KYC pipeline, or any system that needs to route documents to the right authentication path, you've probably hit the same wall: the rules aren't written as logic anywhere. They're scattered across government sites, consulate PDFs, and institutional knowledge.
This post walks through how to actually model that logic in code, using the apostille-vs-legalization decision as a concrete example. The legal background comes from this article on certified translation for Portuguese death certificates in inheritance cases, which lays out the human-readable version of the rule. Here's the developer version.
The underlying rule is a lookup, not a calculation
The core decision point is binary but data-dependent:
- If the destination country is party to the Hague Apostille Convention, you need exactly one authentication step: an apostille issued by the relevant authority in the origin country.
- If it isn't, you need a multi-step consular legalization chain: origin country's foreign ministry, then the destination country's embassy/consulate.
That sounds simple until you realize the membership list changes over time (countries join the Convention, and a few have had disputed or partial accession), and the correct source of truth is the HCCH status table, not a static list baked into your app two years ago.
If you're building anything that touches this, don't hardcode the country list. Treat it as external, versioned data.
A minimal data model
from dataclasses import dataclass from enum import Enum class AuthMethod(Enum): APOSTILLE = "apostille" CONSULAR_LEGALIZATION = "consular_legalization" NONE = "none" # some bilateral treaties waive this entirely @dataclass class CountryAuthRule: iso_code: str hague_member: bool bilateral_waiver: bool = False # e.g. some EU country-pairs skip both def resolve_auth_method(origin: CountryAuthRule, destination: CountryAuthRule) -> AuthMethod: if destination.bilateral_waiver: return AuthMethod.NONE if destination.hague_member: return AuthMethod.APOSTILLE return AuthMethod.CONSULAR_LEGALIZATION This is intentionally dumb. The complexity isn't in the branching, it's in keeping hague_member accurate and handling the asymmetric cases.
Why asymmetry breaks naive implementations
A mistake I see in first-pass implementations: treating the relationship as symmetric. It isn't.
Take Angola, used as the example in the source article. Angola is not a Hague Convention member, so documents going into Angola require consular legalization. But Angola's own foreign ministry (MIREX) only legalizes documents going out of Angola. There's no inbound equivalent on their side for foreign documents.
If your data model assumes a single legalization_authority field per country, you'll misroute this. You need direction-aware fields:
@dataclass class CountryAuthRule: iso_code: str hague_member: bool outbound_legalizer: str | None = None # authority for docs leaving this country inbound_legalizer: str | None = None # authority for docs entering this country For Angola: outbound_legalizer = "MIREX", inbound_legalizer = None (because inbound documents go through the origin country's foreign ministry plus the Angolan consulate abroad, not through an Angolan domestic authority).
This kind of directional asymmetry is common enough in international document workflows that it's worth modeling explicitly rather than discovering it in a bug report.
Building a document checklist generator
The second piece of complexity in the source material is that a death certificate is rarely the only document needed. Inheritance cases typically also need:
- Certificate of inheritance (habilitação de herdeiros)
- Will, if one exists
- Birth/marriage certificates for heirs
- Power of attorney, if an heir isn't local
Each of these needs its own translation and potentially its own authentication step. This maps well to a simple rules engine instead of hardcoded conditionals:
REQUIRED_DOCS = { "inheritance_cross_border": [ {"doc": "death_certificate", "always": True}, {"doc": "certificate_of_inheritance", "always": True}, {"doc": "will", "condition": "will_exists"}, {"doc": "birth_certificate", "condition": "heir_count > 0"}, {"doc": "power_of_attorney", "condition": "heir_is_foreign_resident"}, ] } def generate_checklist(case_type: str, facts: dict) -> list[str]: required = [] for rule in REQUIRED_DOCS[case_type]: if rule.get("always") or eval_condition(rule.get("condition"), facts): required.append(rule["doc"]) return required (Skip eval in production, obviously, use a proper condition evaluator or a library like rule-engine in Python, or a JSON Logic implementation if you want it portable across services.)
The payoff here isn't flashy, but it's real: teams that build this as an ad hoc checklist in a wiki page end up with exactly the failure mode described in the source article, someone translates only the death certificate, submits it, and gets a rejection notice three weeks later asking for the certificate of inheritance too. A checklist generator driven by case facts catches that before the first submission.
Where this fits in a larger pipeline
If you're building internal tooling for a legal, immigration, or international HR workflow, the pattern generalizes:
- Country metadata service — treaty memberships, authentication authorities, kept as versioned data, not application code.
- Document requirement engine — case type + facts → required document list.
- Translation/authentication status tracker — per document, track translation status, authentication method, and current step, so you can flag incomplete chains before submission.
None of this requires anything exotic. A Postgres table for country rules, a small rules engine for requirements, and a state machine per document (draft → translated → certified → apostilled/legalized → submitted) covers most of it.
The actual legal nuance, who can certify a translation in Portugal, what ISO 17100 workflows look like, when a notary vs a lawyer needs to sign off, is covered well in the original article. That's worth reading if you're scoping requirements for a tool in this space, since getting the legal model wrong is more expensive than getting the code wrong.
Takeaway
Cross-border document workflows look like simple lookups from the outside, but the rules are asymmetric, time-sensitive, and poorly centralized. If you're building anything in this space, invest early in separating the "what's legally true right now" data layer from your application logic. It'll save you from the class of bugs where the code was correct but the underlying rule changed six months ago and nobody updated the hardcoded list.