API Reference: Waits

Complete reference for the Waits API including endpoints, request/response schemas, and examples.

Authentication

All wait endpoints require a valid API key passed in the Authorization header as Bearer <token>.
POST/api/v1/waits

Create a wait on an inbox. Poll or stream the wait to receive the extracted result when the email arrives.

Request Body

NameTypeRequiredDescription
inboxIdstringRequiredThe inbox to monitor for incoming emails.
typestringRequiredWait type. One of otp, magic_link, password_reset, email, check.
timeoutSecondsintegerRequiredMaximum seconds to wait before timing out.(default: 120)
sessionIdstringOptionalAssociate this wait with an existing session.
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,
"sessionId": "sess_abc"
}'

Responses

HTTP 201
{
"id": "wait_789",
"inboxId": "inb_123",
"type": "otp",
"status": "pending",
"timeoutSeconds": 120,
"createdAt": "2024-06-12T10:00:05Z",
"expiresAt": "2024-06-12T10:02:05Z",
"result": null,
"sessionId": "sess_abc"
}
GET/api/v1/waits/{id}

Get the current status of a wait. Poll this endpoint to check if the wait is completed, timed out, or still pending.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe unique wait ID.
bash
curl -s https://agentinbox.in/api/v1/waits/wait_789 \
-H "Authorization: Bearer $AgentInbox_API_KEY"

Responses

HTTP 200
{
"id": "wait_789",
"inboxId": "inb_123",
"type": "otp",
"status": "pending",
"timeoutSeconds": 120,
"createdAt": "2024-06-12T10:00:05Z",
"expiresAt": "2024-06-12T10:02:05Z",
"result": null,
"sessionId": "sess_abc"
}
DELETE/api/v1/waits/{id}

Cancel an active wait. This immediately stops the wait and sets its status to canceled.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe unique wait ID to cancel.
bash
curl -X DELETE https://agentinbox.in/api/v1/waits/wait_789 \
-H "Authorization: Bearer $AgentInbox_API_KEY"

Responses

HTTP 204
// No body
GET/api/v1/waits/{id}/stream

Stream wait status updates via Server-Sent Events (SSE). Receive real-time updates without polling.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe unique wait ID to stream.
bash
curl -N -H "Authorization: Bearer $AgentInbox_API_KEY" \
https://agentinbox.in/api/v1/waits/wait_789/stream

Responses

HTTP 200
event: status_update
data: {"status":"pending","result":null}
event: status_update
data: {"status":"completed","result":{"type":"otp","value":"123456","confidence":0.98}}

Polling vs Streaming

Use polling (GET by ID) for simple scripts and streaming (GET /stream) for real-time applications. Streaming reduces latency and API calls.

Schema: Wait

The Wait object represents an asynchronous expectation for an incoming email.

Wait Object
{
"id": string,
"inboxId": string,
"type": "otp" | "magic_link" | "password_reset" | "email" | "check",
"status": "pending" | "completed" | "timed_out" | "canceled",
"timeoutSeconds": number,
"createdAt": string,
"expiresAt": string,
"result": {
"type": string,
"value": string,
"confidence": number
} | null,
"sessionId": string | null
}

Related Documentation