List the zone's published records before deleting a single DNS record, then use the exact identity returned by that listing. For healthtech onboarding, the deciding constraint is drift: the proof record a queued job intended to remove may no longer be the record that is published. Keep ownership verification pending until its evidence is resolved.

Short answer: select by zone, type, and name; require exactly one expected match; compare its content with the approved before-state; delete using the identifier you just read. Preserve the complete listed entry for recovery. A Node.js worker needs the same checks as any other client. The Go example below isolates that decision without inventing provider request fields.

How do you delete a single DNS record without guessing?

Consider an illustrative clinic onboarding request for clinic.example. Its cleanup intent names a TXT record at _ownership.clinic.example with content onboarding-proof-old. These are example values, not a prescribed verification protocol. Before the queued cleanup runs, an administrator replaces the intended proof with onboarding-proof-current. A job that reconstructs the target from the original name can now act against the wrong state. The requested work became stale.

Stop the deletion.

The useful postmortem question is where intent stopped matching evidence. A record name identifies the place being inspected, but it does not prove that the current content belongs to the old onboarding attempt. An old identifier does not establish that the record has remained unchanged either. Listing first provides both the identity needed for deletion and a before-state that an operator can examine later. Capture the zone identifier, record identity, type, name, content, and all returned attributes needed to reconstruct the entry. Associate that evidence with the onboarding attempt in the application audit trail before performing the destructive change.

Cleanup must not erase its own explanation.

Make the deletion conditional on evidence

Use four gates in the worker: establish the intended zone, list its records, select the exact type and name, and compare the selected entry with the approved content. Zero matches means there is no listed target to authorize. Two matches mean the selection is ambiguous. Neither condition permits a destructive guess. Even one match must be rejected if its content differs from the approved before-state.

This standalone Go program first retrieves the public discovery inventory for schema inspection, then checks a local review artifact. Its JSON fields belong to this example; they are not a vendor response schema. A provider adapter must produce the artifact from a complete listing and retain the original response separately. The program outputs the inventory on standard error and a candidate identity on standard output. It never issues a destructive request.

package main import ( "encoding/json" "fmt" "io" "net/http" "os" "strconv" "strings" "time" ) type Record struct { ID string `json:"id"` Type string `json:"type"` Name string `json:"name"` Content string `json:"content"` } type Review struct { Zone string `json:"zone"` ExpectedType string `json:"expected_type"` ExpectedName string `json:"expected_name"` ExpectedContent string `json:"expected_content"` Records []Record `json:"records"` } func inspectDiscovery() error { base := strings.TrimRight(os.Getenv("INFRAI_API_BASE"), "/") key := os.Getenv("INFRAI_API_KEY") if base == "" || key == "" { return fmt.Errorf("set INFRAI_API_BASE and INFRAI_API_KEY") } client := &http.Client{Timeout: 15 * time.Second} for attempt := 0; attempt < 3; attempt++ { req, err := http.NewRequest(http.MethodGet, base+"/discovery", nil) if err != nil { return err } req.Header.Set("Authorization", "Bearer "+key) resp, err := client.Do(req) if err != nil { return err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return readErr } if resp.StatusCode == http.StatusTooManyRequests { if attempt == 2 { return fmt.Errorf("discovery rate limited after 3 attempts: %s", body) } delay := time.Second * time.Duration(1<<attempt) retry := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 { requested := time.Duration(seconds) * time.Second if requested > delay { delay = requested } } else if deadline, err := http.ParseTime(retry); err == nil { if requested := time.Until(deadline); requested > delay { delay = requested } } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("discovery HTTP %d: %s", resp.StatusCode, body) } if !json.Valid(body) { return fmt.Errorf("discovery returned invalid JSON") } _, err = fmt.Fprintln(os.Stderr, string(body)) return err } return fmt.Errorf("discovery retry limit reached") } func run() error { if err := inspectDiscovery(); err != nil { return err } var review Review if err := json.NewDecoder(os.Stdin).Decode(&review); err != nil { return fmt.Errorf("decode review: %w", err) } if review.Zone == "" || review.ExpectedType == "" || review.ExpectedName == "" || review.ExpectedContent == "" { return fmt.Errorf("missing required approval evidence") } var matches []Record for _, record := range review.Records { if record.Type == review.ExpectedType && record.Name == review.ExpectedName { matches = append(matches, record) } } if len(matches) != 1 { return fmt.Errorf("refuse deletion: expected 1 match, found %d", len(matches)) } target := matches[0] if target.ID == "" || target.Content != review.ExpectedContent { return fmt.Errorf("refuse deletion: missing identity or changed content") } return json.NewEncoder(os.Stdout).Encode(struct { Zone string `json:"zone"` Before Record `json:"before"` }{Zone: review.Zone, Before: target}) } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } 

Save this as main.go and run it with go run main.go, supplying the review JSON on standard input. Set INFRAI_API_BASE to the provider's versioned API base and INFRAI_API_KEY to your key in the environment. Discovery itself is public; this example uses the worker's explicit authentication convention. The GET request is read-only, and retries honor Retry-After while backing off. For the clinic example, expected_type is TXT, expected_name is _ownership.clinic.example, and expected_content is onboarding-proof-old. The adapter supplies the actual zone identifier and listed records. A record containing onboarding-proof-current must fail even if its name is exactly right.

Exact matching makes representation a deliberate boundary. Normalize the approved name and listed name consistently in the adapter before this check; don't broaden a failed match into a substring search. The program requires nonempty expected content, which suits this proof-record example. It is not a universal record validator. Its reduced record structure is also insufficient for exact restoration: retain the complete provider entry, not just this projection.

Listing is evidence, not a lock. Keep the read-to-delete interval short and serialize competing changes within the onboarding workflow. Re-list immediately before delayed execution or retry, and stop if the evidence changed. Application serialization cannot prevent an administrator from making an independent change. These checks therefore have a limitation: they do not establish an atomic compare-and-delete guarantee.

Choose the interface around the existing change owner

The operational choice is where the zone already lives and which system owns the approval evidence. Evaluate the alternatives against the same clinic cleanup request, including the boundary between an individual record and a record set. Do not assume the identity model transfers unchanged between providers.

Option Fit to evaluate Boundary to verify before adoption
Cloudflare DNS An existing Cloudflare zone and its current administration workflow Confirm how the listing, exact record identity, and complete audit evidence reach the worker.
Amazon Route 53 A zone already governed through the team's AWS change process Inspect record-set deletion semantics before mapping an individual cleanup intent.
Google Cloud DNS A zone already governed through the team's Google Cloud workflow Review how record sets and change operations map to the entry approved for removal.
Infrai A worker that benefits from a plain REST API, callable over HTTP without installing an SDK One key, one bill across 295 routes and 20 modules can reduce credential management for DNS and surrounding backend services. Public discovery exposes request and response schemas.

These are integration criteria, not a ranking of DNS performance. Keep Cloudflare DNS, Amazon Route 53, or Google Cloud DNS when its established change process gives the team the clearest ownership trail. An additional API boundary introduces a mapping to review. The trade-off is explicit: a common HTTP interface and one credential can reduce client and credential management, but neither replaces the zone's record model or the worker's evidence checks. A team that needs only its existing DNS integration may have little reason to introduce that boundary.

Runnable examples in 10 languages provide another practical check on the adapter contract when the onboarding worker and an operator's inspection tool use different languages. They help with request construction; they cannot decide whether a clinic's current proof belongs to the cleanup attempt.

For a Node.js implementation, translate the evidence checks into the worker's language after reading the chosen provider's schema. Do not translate the example's local JSON names into request parameters by assumption. The useful portability is the refusal rule.

Verify the outcome before advancing onboarding

After the delete response, list again and inspect the intended zone. Verify that the selected entry is absent and that evidence needed by the active ownership attempt remains as intended. Keep these outcomes distinct: cleanup completed, ownership evidence accepted, onboarding completed. Removing an obsolete proof does not establish control of a domain.

A timeout creates uncertainty.

On retry, the idempotency reflex is to reconcile first. If the exact old entry is absent, record that observed state without deleting a replacement. If it remains and still matches the approved evidence, proceed through the same gates. If multiple entries match or the content changed, leave onboarding pending for review. This costs another read, but prevents a duplicate delivery from turning stale intent into a second destructive action. HTTP DELETE alone does not make that business operation idempotent.

Retain which onboarding attempt requested removal, which zone was inspected, which complete entry was selected, what the delete returned, and what the subsequent listing showed. An accepted request and an observed final state answer different operational questions. Retain both.

Restore without replaying stale intent

If the wrong entry was removed, pause cleanup for that onboarding attempt and inspect current records before restoration. Re-create the deleted entry from the complete saved before-state using the provider's documented create operation. Do not overwrite a newer proof simply to make the old snapshot reappear. Where current state conflicts with the saved entry, require new approval.

Then repeat ownership verification before allowing onboarding to finish. The rollback objective is a correct published state with an explainable ownership decision. An empty job queue is only an execution detail.

References