Wait for an SMS
const url = 'https://api.clearance.rest/numbers/sms/wait?number=example';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/numbers/sms/wait?number=example' \ --header 'X-API-Key: <X-API-Key>'Long-poll: returns the newest matching SMS right away when one already arrived after timestamp, otherwise waits until one arrives (at most 5 minutes; X-Service-Timeout in milliseconds lowers the limit). Only messages delivered to your project match. When nothing arrives in time the response is 200 with success: false and error.code: wait_timeout.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Recipient number (E.164); encode + as %2B.
Only messages from this sender.
Only messages received after this time (seconds, milliseconds or microseconds since the epoch).
Only messages whose body matches.
Extract a code from the body (the first capture group, otherwise the whole match).
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
UTC timestamp (ISO 8601).
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}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": "team_suspended" }}