> ## 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 Go

> Check whether a queued WhatsApp API request was sent, and read its response, from Golang. Poll queued requests by UUID with the Hypersender Go 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 `queued_request_uuid`. 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
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.GetQueuedRequest(ctx, "a0816120-7e37-4e8b-8cf3-92deb2cdc133")
> if err != nil {
>     log.Fatal(err)
> }
>
> // Check if the request is completed
> if res["response_status"] != nil {
>     // Request completed
>     fmt.Println("Status:", res["response_status"])
>     fmt.Println("Response:", res["response_body"])
> } else {
>     // Still processing
>     fmt.Println("Request is still being processed...")
> }
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | uuid | string | yes | The UUID of the queued request to retrieve |

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

> [!NOTE]
>
> The `response_status`, `response_body`, and `response_header` will be `nil` while the request is still being processed.

## Response Fields

The SDK returns the API's JSON as a `hypersender.Result` (a `map[string]any`), so the fields keep the API's snake\_case names. JSON numbers decode as `float64` and objects as `map[string]any`.

| Field | Type | Description |
| - | - | - |
| `uuid` | string | The unique identifier for this queued request |
| `request` | map\[string]any | The original request payload you submitted |
| `response_status` | float64 \| nil | HTTP status code of the processed request. `nil` while still processing |
| `response_body` | map\[string]any \| nil | The actual API response. Contains message details on success, error details on failure. `nil` while processing |
| `response_header` | map\[string]any \| nil | Response headers from the processed request. `nil` while processing |

## Polling Example

If you need to wait for a request to complete, you can implement polling with exponential backoff:

```go theme={null}
package main

import (
    "context"
    "errors"
    "fmt"
    "log"
    "time"

    "github.com/hypersender/hypersender-go"
)

func waitForCompletion(ctx context.Context, client *hypersender.Client, uuid string, maxAttempts int) (hypersender.Result, error) {
    for attempt := 0; attempt < maxAttempts; attempt++ {
        res, err := client.WhatsApp.GetQueuedRequest(ctx, uuid)
        if err != nil {
            return nil, err
        }

        if res["response_status"] != nil {
            return res, nil // Request completed
        }

        // Exponential backoff: 100ms, 200ms, 400ms, 800ms...
        time.Sleep(100 * time.Millisecond << attempt)
    }

    return nil, errors.New("request did not complete in time")
}

func main() {
    ctx := context.Background()
    client := hypersender.NewClient()

    sent, err := client.WhatsApp.SendTextSafe(ctx, "20123456789@c.us", "Hello!", nil)
    if err != nil {
        log.Fatal(err)
    }

    uuid, _ := sent["queued_request_uuid"].(string)

    res, err := waitForCompletion(ctx, client, uuid, 10)
    if err != nil {
        log.Fatal(err)
    }

    if status, _ := res["response_status"].(float64); status == 200 {
        body, _ := res["response_body"].(map[string]any)
        fmt.Println("Message sent! ID:", body["message_id"])
    } else {
        fmt.Println("Failed with status:", res["response_status"])
    }
}
```


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