Questions · Updated 2026-09-28
How do I wait for a domain to verify from a script?
Wait for a domain to verify from a script by calling GET /domains/{id}/wait in a loop. Each call long-polls for up to timeout seconds and returns status, next_poll_seconds, deadline and progress; stop when status is verified or failed, then call POST /emails. Over MCP the same call is wait_for_domain.
Wait for a domain to verify from a script by looping on GET /domains/{id}/wait. Its summary: "Long-poll a domain until it is verified or failed, or until timeout (0–25 seconds). timeout=0 is a snapshot. Does not re-check DNS; the server checks on its own." Each reply carries status. Stop when it is verified or failed, and only then call POST /emails. There is no need to call POST /domains/{id}/verify on each pass: the wait call does not re-check DNS, and the server keeps checking on its own.
The call
The path takes the domain id or the domain name; the parameter's description is "Domain id (UUID) or name." timeout is an integer number of seconds inside the range the summary states, and omitting it uses the top of that range.
The reply has id, name, status (pending, verified, failed, partially_verified or partially_failed), next_poll_seconds, deadline, reason and progress. progress.required_verified of progress.required_total is how many required rows resolve. deadline is when the check window closes, and it is null once the domain is verified. reason is ok, not_found, unreachable, mismatch, dkim_key_mismatch or domain_check_window_expired, and it is the worst required record's reading.
The call returns before the timeout only when status is verified or failed. pending and the partial states come back when the timeout runs out, with next_poll_seconds saying when the server will look again.
curl -sS -X GET https://api.agentisend.com/domains/9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42/wait \
-H "Authorization: Bearer $AGENTISEND_API_KEY"200
{
"deadline": "string",
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"name": "yourdomain.com",
"next_poll_seconds": 1,
"progress": {},
"reason": "ok",
"status": "pending"
}The loop
- Call
GET /domains/{id}/wait. statusisverified: callPOST /emails.statusisfailed: stop.GET /domains/{id}names the record, a person corrects it at the DNS provider, andPOST /domains/{id}/verifyreopens the window. Looping on wait cannot change a failed domain, because a failed domain is not re-checked until verify is called.- Anything else: sleep for
next_poll_seconds, then go to 1. Give up atdeadline; after it, the status isfailedand step 3 applies.
The agent quickstart puts the rule in one sentence: "Do not retry the send in a loop — retry the verification, and only after the records are actually published." A send attempted before step 2 answers domain_not_verified, and its fix names the same endpoints as step 3.
Over MCP the tool is wait_for_domain. Its description: "Purpose: wait until a sending domain is verified or failed, without re-checking DNS yourself." It also says what to do with a pending reply: "If it is still pending, call again after next_poll_seconds, or send to an address ending in @simulator.agentisend.com meanwhile." MCP lists the tool and its scope.
Not polling at all
A running process can subscribe instead. POST /webhooks with domain.verified in events delivers the change when it happens; Domains and DNS says to subscribe to the domain.* events, and domain.failed on the same subscription is the other outcome. While waiting, a send to an address ending in @simulator.agentisend.com is accepted from any well-formed From and fires the same events a delivered send would, webhooks included.