# Automate WhatsApp in One API (`leadsbrary/automate-whatsapp-in-one-api`) Actor

Unlock WhatsApp automation in minutes: connect once via QR, then run messaging, media sends, number verification, chat exports, backups, and job tracking from one production-ready Control Center + API. Built for CRM, support, sales, and ops teams that need speed, reliability, and scale.

- **URL**: https://apify.com/leadsbrary/automate-whatsapp-in-one-api.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (community)
- **Categories:** Automation, Lead generation, Open source
- **Stats:** 8 total users, 5 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 message-results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Automate WhatsApp in One API

Run WhatsApp operations from one actor: connect once, keep session alive, and execute export/send/verify/backup workflows from a modern UI or a clean HTTP API.

### Why This Actor

- One QR onboarding flow, then persistent session reuse
- Real operational dashboard (`/ui`) for non-technical users
- API-first automation for scripts, CRMs, and backend services
- Built-in command jobs for async tasks and polling
- Designed for production reliability (timeouts, fallbacks, resilient responses)

### Product Snapshot

![WhatsApp Control Center UI](https://api.apify.com/v2/key-value-stores/Zq7brB9OvYzugdbCj/records/whatsapp-control-center-ui.png)

### End-to-End Process

#### 1. Start actor

Launch the actor. It initializes the Control Center and prints:

- UI URL
- Access token location (`CONTROL_ACCESS.txt`)
- QR status updates

#### 2. Link WhatsApp account

Scan the QR from logs or UI:

1. WhatsApp on phone
2. Settings -> Linked Devices
3. Link a Device
4. Scan QR

#### 3. Session persistence

After successful link, session state is saved. Next runs restore automatically in most cases.

#### 4. Operate from UI or API

- UI for interactive operations
- REST API for automation
- Jobs API for command tracking

### Core Endpoints

| Endpoint | Method | Purpose |
|---|---|---|
| `/ui` | GET | Control Center dashboard |
| `/status` | GET | Session and connection status |
| `/qr` | GET | Current QR as PNG |
| `/start` | POST | Start/restart session bootstrap |
| `/chats` | GET | List chats (`limit` supported) |
| `/messages` | POST | Export messages |
| `/send` | POST | Send messages/media |
| `/numbers` | POST | Verify phone numbers |
| `/contacts` | POST | Save/sync contacts |
| `/backup` | POST | Build backup artifacts |
| `/jobs` | GET | List jobs |
| `/jobs/:id` | GET | Poll job status/result |
| `/logout` | POST | Disconnect + clear session |

### Quick Start API

#### Status

```bash
curl -s -H "Authorization: Bearer $TOKEN" "$BASE_URL/status"
````

#### Two most recent chats

```bash
curl -s -H "Authorization: Bearer $TOKEN" "$BASE_URL/chats?limit=2"
```

#### Send message

```bash
curl -s -X POST "$BASE_URL/send" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "waitForResult": true,
    "confirmRecipientConsent": true,
    "sendMessages": [{"to":"33600000000@c.us","message":"Hello from API"}]
  }'
```

#### Verify number

```bash
curl -s -X POST "$BASE_URL/numbers" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "waitForResult": true,
    "confirmRecipientConsent": true,
    "phoneNumbers": ["+33600000000"]
  }'
```

### Reliability Highlights

- Dashboard QR recovery via SSE + status polling fallback
- Connected-state QR lock to avoid QR/check flicker
- `/chats?limit=N` returns latest `N` chats (most recent first)
- Non-blocking KV strategy for chat listing responses
- Per-chat timeout guards to avoid single-chat full-response stalls

### Backup ZIP Download Behavior

- Backup ZIP files are served through a direct download link returned in `job.progress.downloadPath` and in the final job result.
- Use the link shown in the UI result panel (`Download result`) for both conversation backup and full account backup.
- Backup ZIP links are session-scoped to the running Control Center process, so download the file during the active session.
- JSON artifacts (for example manifest/summary) remain available through `/download/{key}`.

### Security and Compliance

- Access token required on every request
- Consent confirmation supported for send/verify workflows
- Session token and QR should be treated as sensitive credentials
- Use only authorized accounts and compliant recipient lists

### Billing

This actor uses Apify pay-per-event billing through `Actor.charge`, so the price is defined by the event grid below. There is no hidden per-message compute tariff in the actor pricing itself: the run is billed when the code emits an event.

#### Event pricing

| Cost driver | What it means | Billing impact |
|---|---|---|
| `message-result` | 1 per exported message | `$0.001 / message` |
| `live-message-result` | 3 per live message saved or forwarded | `$0.003 / message` |
| `media-mb` | 25 per rounded-up MB | `$0.025 / MB` |
| `send-action` | 3 per text or media send | `$0.003 / send` |
| `number-check` | 2 per WhatsApp number | `$0.002 / number` |
| `contact-action` | 4 per contact save/edit | `$0.004 / contact` |
| `profile-result` | 2 per exported profile/contact | `$0.002 / profile` |
| `backup-package` | 500 per backup ZIP | `$0.50 / ZIP` |
| `live-minute` | 10 per started minute | `$0.01 / minute` |
| `command-action` | 5 per paid direct command | `$0.005 / command` |
| `list-chats-action` | 1 per list chats request | `$0.001 / request` |

#### Cost impact by action

| Action | What is billed | Typical cost pressure |
|---|---|---|
| Export messages | `message-result` events | `$0.001` per exported message |
| Save or forward live messages | `live-message-result` events | `$0.003` per live message |
| Send text | `send-action` events | `$0.003` per message sent |
| Send media or file | `send-action` + `media-mb` events | `$0.003` + `$0.025` per rounded-up MB |
| Verify numbers | `number-check` events | `$0.002` per number |
| Save or edit contacts | `contact-action` events | `$0.004` per contact |
| Export profiles / contacts | `profile-result` events | `$0.002` per profile |
| Build a backup ZIP | `backup-package` plus normal message/media/profile events inside the backup | `$0.50` per ZIP plus variable event cost |
| List chats | `list-chats-action` events | `$0.001` per request |
| Keep a live session open | `live-minute` events | `$0.01` per started minute |
| Run a paid direct command | `command-action` events | `$0.005` per command |

#### Practical rule of thumb

- The actor is not priced by generic runtime/memory in the product grid above.
- The bill comes from the specific events the code emits.
- A bigger file costs more because `media-mb` rounds up to the next MB.
- A live session costs more because `live-minute` is charged per started minute.
- A backup can cost multiple events because the ZIP has its own base fee and the included messages/media/profiles are still billed normally.

#### How to estimate cost

- Count the expected number of exported messages, live messages, sent messages, number checks, contact actions, profile exports, backup ZIPs, live minutes, and direct commands.
- Multiply each count by its unit price.
- Add `media-mb` for every rounded-up MB of media that is downloaded or uploaded.
- For backups, add the ZIP base price plus the underlying message/media/profile events.
- Use the Apify console usage and billing pages to verify the exact spend for your account.

#### Important notes

- WhatsApp itself is not billed by Apify inside this actor.
- Any proxy provider, external API, or downstream automation tool may add its own charges.
- The actor code already exposes the event grid above, so exact per-action pricing is known and should be kept in sync with `PRICING_EVENTS.json` and `src/main.js`.

### Suggested Use Cases

- Sales outreach operations
- Customer support workflows
- Lead qualification and enrichment
- Notification pipelines
- WhatsApp data export and archival
- Business continuity backup workflows

### Keywords

whatsapp api, whatsapp automation, whatsapp web, whatsapp session api, whatsapp session manager, whatsapp control center, whatsapp dashboard, qr login, linked devices, session persistence, whatsapp chats export, whatsapp messages export, whatsapp backup, whatsapp media export, whatsapp send api, whatsapp number verification, whatsapp contacts sync, whatsapp jobs api, apify actor, apify whatsapp, crm integration, webhook integration, live events, sse events, production ready, business messaging, lead generation, sales ops, support ops, outreach automation, contact validation, consent aware messaging, all in one whatsapp, whatsapp backend service

### Summary

This actor is an all-in-one WhatsApp operations layer for teams that need both UI control and API automation with production-focused behavior.

# Actor input Schema

## `confirmAuthorizedUse` (type: `boolean`):

Tick this to confirm you own this account or have explicit written authorization to connect it. Required before the actor will run.

## Actor input object example

```json
{
  "confirmAuthorizedUse": true
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset with one row per exported message, live message, sent message, number check, or contact action.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/automate-whatsapp-in-one-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/automate-whatsapp-in-one-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call leadsbrary/automate-whatsapp-in-one-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=leadsbrary/automate-whatsapp-in-one-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Automate WhatsApp in One API",
        "description": "Unlock WhatsApp automation in minutes: connect once via QR, then run messaging, media sends, number verification, chat exports, backups, and job tracking from one production-ready Control Center + API. Built for CRM, support, sales, and ops teams that need speed, reliability, and scale.",
        "version": "0.3",
        "x-build-id": "Zwa6tKjzY1xGdD57f"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/leadsbrary~automate-whatsapp-in-one-api/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-leadsbrary-automate-whatsapp-in-one-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/leadsbrary~automate-whatsapp-in-one-api/runs": {
            "post": {
                "operationId": "runs-sync-leadsbrary-automate-whatsapp-in-one-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/leadsbrary~automate-whatsapp-in-one-api/run-sync": {
            "post": {
                "operationId": "run-sync-leadsbrary-automate-whatsapp-in-one-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "confirmAuthorizedUse"
                ],
                "properties": {
                    "confirmAuthorizedUse": {
                        "title": "I confirm I am authorized to access this WhatsApp account",
                        "type": "boolean",
                        "description": "Tick this to confirm you own this account or have explicit written authorization to connect it. Required before the actor will run.",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
