Waits

The wait API lets you block until an expected email arrives, making automation simple and reliable.

How Waits Work

When you create a wait, AgentInbox monitors the inbox for matching emails. The API returns as soon as the condition is met or the timeout is reached.

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.

bash
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
}'
POST/api/v1/waits

Create a wait on an inbox

Parameters

NameTypeRequiredDescription
inboxIdstringRequiredThe inbox to monitor for matching emails.
typestringRequiredThe wait type: otp, magic_link, password_reset, email, or check.
timeoutSecondsintegerRequiredMaximum time to wait before returning.(default: 120)

Responses

HTTP 201
{
"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"
}

Canceling a Wait

Cancel an active wait if you no longer need it. This frees up resources and prevents unnecessary polling.

bash
curl -X DELETE https://agentinbox.in/api/v1/waits/wait_789 \
-H "Authorization: Bearer $AgentInbox_API_KEY"

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.

email

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

Always check the status before accessing 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

Next Steps