Waits
The wait API lets you block until an expected email arrives, making automation simple and reliable.
How Waits Work
Creating a Wait
Create a wait on an inbox to block until a matching email arrives. The API returns as soon as the condition is met or the timeout is reached.
curl -X POST https://agentinbox.in/api/v1/waits \ -H "Authorization: Bearer $AgentInbox_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inboxId": "inb_123", "type": "otp", "timeoutSeconds": 120 }'const wait = await client.waits.create({ inboxId: "inb_123", type: "otp", timeoutSeconds: 120,}); if (wait.status === "completed") { console.log(wait.result?.value); // "123456"}wait = client.waits.create( inbox_id="inb_123", type="otp", timeout_seconds=120,) if wait.status == "completed": print(wait.result.value) # "123456"/api/v1/waitsCreate a wait on an inbox
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| inboxId | string | Required | The inbox to monitor for matching emails. |
| type | string | Required | The wait type: otp, magic_link, password_reset, email, or check. |
| timeoutSeconds | integer | Required | Maximum time to wait before returning.(default: 120) |
Responses
{ "id": "wait_789", "inboxId": "inb_123", "type": "otp", "status": "completed", "result": { "type": "otp", "value": "123456", "confidence": 0.98 }, "createdAt": "2024-06-12T10:30:00Z", "completedAt": "2024-06-12T10:30:15Z"}{ "id": "wait_789", "inboxId": "inb_123", "type": "otp", "status": "timed_out", "result": null}Canceling a Wait
Cancel an active wait if you no longer need it. This frees up resources and prevents unnecessary polling.
curl -X DELETE https://agentinbox.in/api/v1/waits/wait_789 \ -H "Authorization: Bearer $AgentInbox_API_KEY"await client.waits.cancel("wait_789");Wait Types
AgentInbox supports several wait types that automatically match and extract data from incoming emails.
otp
Wait for an OTP (one-time passcode) email and extract the code.
magic_link
Wait for an email containing a magic/verification link.
password_reset
Wait for a password reset email and extract the link.
Wait for any email to arrive in the inbox.
check
Check immediately without blocking. Returns the current state.
Wait Statuses
A wait can be in one of several statuses depending on whether the expected email arrived.
Status Handling
result. A timed_out or canceled wait will have a null result.pending
Waiting for the matching email
completed
Email arrived and extraction succeeded
timed_out
Timeout reached without matching email
canceled
Wait was explicitly canceled