← All insights

Preventing duplicate billed registrar calls: write-ahead markers, leases and read-back instead of retries

How my domain portal guards billed registrar calls against duplicates even though the registrar does not deduplicate: a marker before every call, a lease per domain, read-back when the outcome is unclear, and a nightly reconciliation.

Part one covered how I built the domain portal behind chnet.domains with a team of AI agents. It says: every write call to the registrar costs money, even one that fails. Here is the architecture that guards the portal against duplicate billed calls, and its limits.

Starting point

Registering a domain is a single call to the registrar interface. Three properties make it delicate; I measured all three in explicitly approved one-off tests before the first automated call:

Add timeouts, dropped connections and automatic retries. The reflex “on error, try again” is wrong here: if it is unclear whether a request arrived, a second attempt can mean a second invoice.

A true once-only guarantee is impossible without the registrar’s cooperation, so the goal was: no second billed call unless the first one has clearly failed. When in doubt, a delayed registration beats a duplicate one.

Solution

All calls to the registrar interface go through one worker. There, a registration always follows the same sequence:

  1. Take a lease. A run places a lease on the domain in DynamoDB using a conditional write. A second run, such as a retry, gets “busy” back and does nothing. The lease expires on its own, so a crashed run cannot block anything for good. For orders from existing customers the lease sits on the order.
  2. Re-read the state. Under the lease, the run reads the record fresh; a parallel run may have sent the request in the meantime.
  3. Read back first, then check. If the domain is already in our account, say because it was registered by hand, the run ends successfully. Free pre-checks follow: the TLD is enabled for automation, the domain is not premium (no clear answer means no automation), the DNS zone exists.
  4. Write the write-ahead marker. Right before the billed call, the run writes the state “sent”, a timestamp and the transaction reference to the record. What matters is where the check lives: the write itself is rejected if a marker exists, guarded by a revision number, so a run holding a stale copy cannot overwrite it.
  5. One call, three possible outcomes. The run sends the request and classifies the response:
    • Clear success: the run reads back, a bounded number of times, until the domain shows up in the account, then marks it registered.
    • Clear rejection: a business error code. The state becomes “failed” and I get an alert.
    • Unclear: timeout, dropped connection, “queued”, or success without a visible domain. The state becomes “pending” or “unconfirmed”, also with an alert. A success with a name server error also stays pending until the admin has fixed the name servers.
  6. Unclear means: read back only. Once a marker exists, the code knows no second write call for that domain. Every later run, including the nightly reconciliation, only queries the registrar’s read interface. If the domain appears in our account, it is adopted; otherwise the case comes to me. Even after a clear rejection, only the admin triggers a new request.

Long-running flows in Step Functions. An order waits for payment, possibly a review, and the owner contact at the registrar. These are task-token waits: the workflow pauses until a payment, an admin decision or the worker resumes it. The owner contact is also created behind a marker; a repeat run that finds a marker without a result hands over to the admin instead of calling again. Retries on transient errors are fine, since the marker turns each into a read-back; permanent errors are not retried.

A lock for technical administration. The hosting provider’s technical domain administration is a second interface that does not tolerate calls in quick succession. All components working on one customer there share a lock that also records when the next call may run.

Nightly reconciliation. Every night a reconcile run compares the portal database with the technical domain administration and with accounting. It finds domains in the account that the portal does not list as registered: the most expensive case, because the registrar bills them and I do not bill them on. It reconciles invoices and payments with Lexware Office and restarts open registrations, for read-back only. Every finding reaches me as an alert.

Guardrails

Outcome

On 26 October 2026 the first registration ran fully automatically through this path, initially for one TLD. Three lessons from the measurements:

What the architecture does not guarantee. It guards against duplicate billed calls from the portal, nothing more. If a run crashes between marker and call, the record says “sent” although nothing was sent; the read-back finds nothing, and the case goes to the admin. That is deliberate: a false “maybe sent” costs manual work, a duplicate request costs money. Requests made at the registrar outside the portal surface only in the nightly reconciliation.

Transfer

The pattern fits wherever an external call costs money or cannot be undone: payments, SMS, ERP postings, invoice dispatch.

Use an interface’s idempotency keys where they exist; they do not replace your own marker, which alone shows what was sent. The read-back does not transfer one-to-one: it needs a read interface that finds the request unambiguously. Without one, “unclear” stays unclear and a human decides.

Stack: AWS CDK · AWS Lambda · AWS Step Functions · DynamoDB · Amazon EventBridge · Amazon SNS · Lexware Office

← All insights