Wait for an email
const url = 'https://api.clearance.rest/emails/wait';const options = {method: 'GET', headers: {'X-API-Key': '<X-API-Key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.clearance.rest/emails/wait \ --header 'X-API-Key: <X-API-Key>'Returns the newest email that matches the filters. If a matching email already arrived the response is immediate; otherwise the request stays open until one arrives, the X-Service-Timeout (ms, at most 5 minutes) elapses (HTTP 200 with success: false and error.code: wait_timeout) or the client disconnects. Every delivered email is charged once.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Only emails sent to this address.
Only emails from this address.
Only emails received at or after this time (seconds, milliseconds or microseconds since the epoch).
Filter: only emails whose text, html or subject matches.
Extracts a value (first capture group, else the whole match) into code.
Mark the email as read after the response (requires the project setting and the mailbox permission). The response tells whether it was scheduled.
Header Parameters
Section titled “Header Parameters”Maximum time to wait in milliseconds (positive integer). Without it the request waits at most 5 minutes; a larger value is capped at 5 minutes.
Responses
Section titled “Responses”Default Response
object
Present only when code_regex was given; null when nothing matched.
UTC timestamp (ISO 8601).
object
An attachment of a delivered email; download it with emails.getAttachment.
object
Download URL (requires the API key).
Present only when mark_as_read=true was requested.
Amount charged for this delivery (USD); 0 when the email was already charged.
Available team balance after the delivery (USD).
Returned with HTTP 200 when nothing matched before the wait time ran out.
object
object
The wait ended without a match.
Human-readable message.
Example
{ "success": true, "mark_as_read": "scheduled"}Default Response
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false, "error": { "code": "validation_error" }}Default Response
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false, "error": { "code": "missing_api_key" }}Default Response
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false, "error": { "code": "insufficient_balance" }}Default Response
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false, "error": { "code": "team_suspended" }}