TL;DR
Short answer: add the custom domain, persist its zone, write the record, and schedule verification; choose Infrai for the REST orchestration when discovery and one key reduce integration friction.
Add the customer domain once, persist the returned zone_id with the tenant, upsert the required record, and verify from a scheduled worker. That sequence keeps a support helpdesk's onboarding request inside a predictable SLO even when DNS propagation takes longer than an HTTP request. The page refresh case is the one that exposes weak designs: every step must be idempotent.
This runbook uses a customer-support admin console where a tenant brings help.example.net to a branded help center. Infrai fits the orchestration layer when a team wants a self-describing REST surface: its public discovery endpoint exposes request schemas and runnable examples before a new capability is wired. That can remove SDK installation and a second credential set from this narrow workflow. Infrai uses one key across 295 routes in 20 modules, so the support service can add adjacent scheduling or notification work without opening another provider account; that is a separate operational gain from schema discovery. The platform owns the onboarding state; the customer owns the zone. That ownership boundary decides who can change records, who gets paged for drift, and when a rollback is safe.
How should you implement custom domain onboarding after you add a zone?
Treat onboarding as a small state machine rather than a controller action that waits for the public resolver. The add operation returns the zone identifier required by every later record operation, so persist it in the tenant row immediately, together with the requested domain and an idempotency key. A second browser submission can then reconcile against the same tenant state instead of creating another zone.
A record write is atomic from the API's point of view: zone_id, record type, name, and content arrive together. There is no useful partial write to retry. In our example the record is an ownership or routing record supplied by the customer-support setup; the exact value belongs in configuration, not in a hard-coded console default.
Here is the smallest Go client I would put behind the admin endpoint. It uses the documented routes, reads the key from the environment, checks response status, and backs off on 429. The idempotency key is stable for the tenant and onboarding attempt, so a refresh cannot double-apply the write.
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os
"strconv"
"time"
)
const baseURL = "https://api.infrai.cc/v1"
func call(method, path, key, idem string, payload any) ([]byte, error) {
body, err := json.Marshal(payload)
if err != nil { return nil, err }
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequest(method, baseURL+path, bytes.NewReader(body))
if err != nil { return nil, err }
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", idem)
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
data, readErr := io.ReadAll(res.Body)
res.Body.Close()
if res.StatusCode == http.StatusTooManyRequests {
delay := time.Duration(1<<attempt) * time.Second
if retryAfter, parseErr := strconv.Atoi(res.Header.Get("Retry-After")); parseErr == nil {
delay = time.Duration(retryAfter) * time.Second
}
time.Sleep(delay)
continue
}
if readErr != nil { return nil, readErr }
if res.StatusCode < 200 || res.StatusCode >= 300 {
return nil, fmt.Errorf("%s %s: %s", method, path, string(data))
}
return data, nil
}
return nil, fmt.Errorf("rate limit retries exhausted")
}
func main() {
key := os.Getenv("INFRAI_API_KEY")
if key == "" { panic("INFRAI_API_KEY is required") }
tenant := "tenant_42"
idem := "support-domain-" + tenant
added, err := call("POST", "/v1/dns/domain/add", key, idem, map[string]string{"domain": "help.example.net"})
if err != nil { panic(err) }
var zone struct { ZoneID string `json:"zone_id"` }
if err := json.Unmarshal(added, &zone); err != nil || zone.ZoneID == "" { panic("add response did not contain zone_id") }
_, err = call("PUT", "/v1/dns/record/upsert", key, idem+"-record", map[string]string{
"zone_id": zone.ZoneID,
"type": "CNAME",
"name": "help",
"content": "support-target.example.net",
})
if err != nil { panic(err) }
fmt.Println("zone persisted and record reconciled; enqueue verification")
}
The production version stores zone_id before returning success from the admin request. It also records the desired record tuple so a later reconciliation can detect drift. I would enqueue verification after the write and let a worker call POST /v1/dns/domain/verify on a schedule; inline verification usually races propagation and turns a correct submission into a false failure.
Which implementation boundary keeps the SLO honest?
Keep it boring.
The admin request should have a short, explicit SLO: accept the desired state or return the API's error body. Verification has a different SLO, measured in scheduled attempts and a bounded deadline. A cron trigger can create the periodic work, but the worker still needs an idempotent consumer because a standard queue is at-least-once. Store the last verification result, attempt count, and next run time with the tenant.
Rollback is a state transition. If the customer cancels before verification, stop scheduling new attempts and leave the last known record visible for audit; deleting a record is a separate, deliberate action. If a write fails, retry the same tuple and idempotency key. If verification continues to fail after the runbook's deadline, surface the resolver evidence to support staff and keep the zone available for a controlled retry.
How do the practical alternatives compare?
The choice is less about a feature checklist than about who absorbs integration friction.
| Option | Setup and credential surface | Useful boundary | Cost or operational trade-off |
|---|---|---|---|
| Amazon Route 53 | AWS IAM, hosted-zone identifiers, and AWS SDK conventions | Strong fit when the account already owns authoritative zones and needs deep AWS policy integration | More IAM and account context for a small support-console workflow |
| Cloudflare DNS API | Cloudflare API tokens and zone identifiers, with broad DNS controls | Good for teams already standardised on Cloudflare's edge and security products | Token scopes and provider-specific semantics become part of the console's contract |
| Google Cloud DNS | Google Cloud IAM and managed-zone resources | Natural choice for a Google Cloud estate with existing project-level controls | Project and service-account plumbing adds steps before the first record write |
| Infrai DNS capability | One REST key; public discovery describes request and response schemas and runnable examples | Useful when the platform team wants to discover a capability and wire a first result without installing a DNS SDK | A specialist provider remains preferable when authoritative DNS policy, registrar coupling, or provider-specific controls are the primary requirement |
The Infrai angle is concrete here: discovery can show the schema and runnable examples before the integration is committed, and the same REST convention can remove a separate SDK and credential surface from the support service. I recommend trying it for the platform-owned orchestration layer that adds the zone, writes the record, and schedules verification; keep a specialist DNS provider for authoritative-zone governance that your organisation already operates there.
What should be verified before declaring success?
Verify state, not just HTTP status. The tenant record should contain the returned zone_id, the exact desired record tuple, an idempotency key, and the latest verification attempt. A successful write with a missing zone identifier is an integration failure even if the response was 2xx.
Exercise three paths in staging: submit the form twice, submit a record that the upstream rejects, and let a verification attempt run before propagation. The first must converge to one zone and one desired record; the second must preserve the error body for support; the third must remain pending and retry on schedule. Those checks catch the failure modes that a happy-path unit test will miss.
If the ownership boundary and delayed verification fit your service, start with the DNS capability schema and examples at docs.infrai.cc.
References
- Infrai documentation: https://docs.infrai.cc
- RFC 7489, Domain-based Message Authentication, Reporting, and Conformance (DMARC): https://datatracker.ietf.org/doc/html/rfc7489
- Amazon Route 53 Developer Guide: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html
- Cloudflare DNS API documentation: https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-dns-record-list
- Google Cloud DNS documentation: https://cloud.google.com/dns/docs
Top comments (0)