Overview
In V2, all API requests are processed through a queued system for improved reliability and performance. When you make any API request (send message, react, etc.), you receive an immediate response with a queued_request_uuid. Use this method to check the actual response of your queued request.
Get Queued Request
Retrieve the status and response of a queued API request using its UUID.
Basic Usage
Parameters
Response
use Hypersender\ Hypersender ;
$response = Hypersender :: whatsapp ()
-> getQueuedRequest (
uuid : 'a0816120-7e37-4e8b-8cf3-92deb2cdc133' ,
);
// Check if the request is completed
$data = $response -> json ();
if ( $data [ 'response_status' ] !== null ) {
// Request completed
echo "Status: " . $data [ 'response_status' ];
echo "Response: " . json_encode ( $data [ 'response_body' ]);
} else {
// Still processing
echo "Request is still being processed..." ;
}
Parameter Type Required Description uuid string yes The UUID of the queued request to retrieve
{
"uuid" : "a0816120-7e37-4e8b-8cf3-92deb2cdc133" ,
"request" : {
"chatId" : "[email protected] " ,
"text" : "Hello world!"
},
"response_status" : 200 ,
"response_body" : {
"message_id" : "AAAAAA0000BBBBB00CCCCCC"
},
"response_header" : {}
}
The response_status, response_body, and response_header will be null while the request is still being processed.
Response Fields
Field Type Description uuidstring The unique identifier for this queued request requestobject The original request payload you submitted response_statusinteger | null HTTP status code of the processed request. null while still processing response_bodyobject | null The actual API response. Contains message details on success, error details on failure. null while processing response_headerobject | null Response headers from the processed request. null while processing
Polling Example
If you need to wait for a request to complete, you can implement polling with exponential backoff:
use Hypersender\ Hypersender ;
function waitForCompletion ( string $uuid , int $maxAttempts = 10 ) : array
{
$attempt = 0 ;
while ( $attempt < $maxAttempts ) {
$response = Hypersender :: whatsapp ()
-> getQueuedRequest ( uuid : $uuid );
$data = $response -> json ();
if ( $data [ 'response_status' ] !== null ) {
return $data ; // Request completed
}
// Exponential backoff: 100ms, 200ms, 400ms, 800ms...
usleep ( 100000 * pow ( 2 , $attempt ));
$attempt ++ ;
}
throw new \Exception ( 'Request did not complete in time' );
}
// Usage
$sendResponse = Hypersender :: whatsapp ()
-> safeSendTextMessage (
chat_id : '[email protected] ' ,
text : 'Hello!' ,
);
$uuid = $sendResponse -> json ()[ 'queued_request_uuid' ];
$result = waitForCompletion ( $uuid );
if ( $result [ 'response_status' ] === 200 ) {
echo "Message sent! ID: " . $result [ 'response_body' ][ 'message_id' ];
} else {
echo "Failed with status: " . $result [ 'response_status' ];
}
For production applications, consider using webhooks instead of polling to receive real-time notifications when messages are sent, delivered, or fail.