Open the claim socket
const url = 'https://api.clearance.rest/numbers/providers/mobile/claim/socket?ticket=cst_3f9a%E2%80%A6';const options = {method: 'GET'};
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/providers/mobile/claim/socket?ticket=cst_3f9a%E2%80%A6'Upgrades to a WebSocket that keeps a QR code fresh and tells you when it is scanned. It replaces the 30-second one-off QR of POST /providers/mobile/claim/rest: the server rotates the QR before it expires and sends events as they happen, so your front end reacts without polling or reloading.
Auth is the ticket query parameter only. This endpoint does not accept X-API-Key or api_key. Get a ticket from POST /providers/mobile/claim/ticket. A missing, invalid, expired or used ticket gets 401. A failure before the upgrade shows in a browser only as a failed connection.
Server-to-client events are JSON text frames with a type:
type |
When | Fields |
|---|---|---|
session |
Once, on connect | session_id, ttl_ms |
qr |
On connect and on every rotation | token, qr_payload, issued_at, expires_at |
scanned |
The current QR was scanned | at, number_id, phone_number, carrier_name |
assigned |
Right after scanned, when the number is attached |
at, unchanged, plus the number’s fields |
error |
Right after scanned, if attaching failed |
code, message |
After assigned, the server stops rotating and closes the socket with code 1000. To attach another number, connect again with a new ticket. If you close the socket without an assignment, the QR in flight is invalidated immediately. Reply to a ping text frame with pong for a liveness check.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”A ticket from POST /providers/mobile/claim/ticket.
Responses
Section titled “Responses”Switching protocols. The WebSocket is open.
The ticket is missing, invalid, expired or already used.
The request was not a WebSocket upgrade.