> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypersender.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WhatsApp Queued Requests in Node.js

> Check whether a queued WhatsApp API request was sent, and read its response, from Node.js. Poll queued requests by UUID with the Hypersender Node.js SDK.

## 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 `queuedRequestUuid`. Use this method to check the actual response of your queued request.

> [!NOTE]
>
> Learn more about the V2 queued request system in the [Queued Requests Documentation](https://docs.hypersender.com/v2/api-reference/whatsapp/queued-requests.md).

## Get Queued Request

Retrieve the status and response of a queued API request using its UUID.

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.whatsapp().getQueuedRequest(
>   "a0816120-7e37-4e8b-8cf3-92deb2cdc133",
> );
>
> // Check if the request is completed
> if (result.responseStatus != null) {
>   // Request completed
>   console.log(`Status: ${result.responseStatus}`);
>   console.log(`Response: ${JSON.stringify(result.responseBody)}`);
> } else {
>   // Still processing
>   console.log("Request is still being processed...");
> }
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | queuedRequestUuid | string | yes | The UUID of the queued request to retrieve (passed as the first argument) |

> [tab] Response
>
> ```json theme={null}
> {
>   "uuid": "a0816120-7e37-4e8b-8cf3-92deb2cdc133",
>   "request": {
>     "chatId": "111111111111@c.us",
>     "text": "Hello world!"
>   },
>   "responseStatus": 200,
>   "responseBody": {
>     "messageId": "AAAAAA0000BBBBB00CCCCCC"
>   },
>   "responseHeader": {}
> }
> ```

> [!NOTE]
>
> The `responseStatus`, `responseBody`, and `responseHeader` will be `null` while the request is still being processed.

## Response Fields

The SDK maps the API's snake\_case fields to camelCase properties on the returned object.

| Field | Type | Description |
| - | - | - |
| `uuid` | string | The unique identifier for this queued request |
| `request` | object | The original request payload you submitted |
| `responseStatus` | number \| null | HTTP status code of the processed request. `null` while still processing |
| `responseBody` | object \| null | The actual API response. Contains message details on success, error details on failure. `null` while processing |
| `responseHeader` | object \| 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:

```typescript theme={null}
import { Hypersender } from "hypersender-node";

async function waitForCompletion(uuid: string, maxAttempts = 10) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const result = await Hypersender.whatsapp().getQueuedRequest(uuid);

    if (result.responseStatus != null) {
      return result; // Request completed
    }

    // Exponential backoff: 100ms, 200ms, 400ms, 800ms...
    await new Promise((resolve) => setTimeout(resolve, 100 * 2 ** attempt));
  }

  throw new Error("Request did not complete in time");
}

// Usage
const sent = await Hypersender.whatsapp().sendTextSafe({
  chatId: "20123456789@c.us",
  text: "Hello!",
});

const result = await waitForCompletion(sent.queuedRequestUuid);

if (result.responseStatus === 200) {
  console.log(`Message sent! ID: ${result.responseBody?.messageId}`);
} else {
  console.log(`Failed with status: ${result.responseStatus}`);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.