# WhatsApp Business Cloud API Automation (`c4rbanak/whatsapp-business-cloud-api-automation`) Actor

Connect your applications to WhatsApp effortlessly using this high-performance Apify Actor powered by the official Meta WhatsApp Business Cloud API. Perfect for e-commerce notifications, transactional alerts, multi-channel marketing campaigns, and customer support workflows.

- **URL**: https://apify.com/c4rbanak/whatsapp-business-cloud-api-automation.md
- **Developed by:** [onur kaplan](https://apify.com/c4rbanak) (community)
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 message sents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## WhatsApp Business Platform API

Use this Actor to **build your own WhatsApp Business product** — connect customers’ numbers, create templates, send messages — without applying as a Meta Tech Provider. Traffic goes through the Meta-approved [watext.io](https://watext.io) Cloud API app.

**You pay on Apify.** There is no watext.io signup and no API key. Direct REST to watext.io is disabled. **Meta tokens never appear in Actor input.**

Each Apify user gets a workspace. Each WhatsApp number you connect belongs to that workspace.

### Build your own panel

1. Run this Actor with `createConnectSession` and a `returnUrl` on your site
2. Open the returned **watext.io** URL in the browser — Facebook login runs there
3. Run `createTemplate` / `syncTemplates` / `send`

### One-time setup

Rent this Actor on Apify. That is the whole setup. Do not paste a Meta token or a watext.io key.

### Actions

| `action` | What it does |
| --- | --- |
| `getConfig` | Meta `appId` + Embedded Signup `config_id` - only if you run `FB.login` on your own domain |
| `createConnectSession` | Returns a `https://watext.io/connect/whatsapp?session=…` URL. Open it in a popup or redirect |
| `connectNumber` | Finish connect from your own `FB.login`: `code`, `wabaId`, `phoneNumberId` |
| `listNumbers` | Numbers in your workspace (no tokens) |
| `disconnectNumber` | Drop Cloud API access for a number (`id`) |
| `getTemplateOptions` | Languages, categories, formats, header types, buttons - same as the New template screen |
| `createTemplate` | Full template builder submit (language, format, header type/media, buttons, catalog/carousel/LTO) |
| `saveTemplate` | Save as draft without submitting to Meta |
| `syncTemplates` | Refresh template approval status from Meta |
| `listTemplates` | Templates, statuses, and builder fields |
| `send` | Send an approved template or a 24-hour session text |

#### Connect WhatsApp (hosted Facebook login)

Do not run `FB.login` on your SaaS domain. Apify cannot open Facebook popups. Your backend asks for a session, then the **browser** opens watext.io:

```json
{
  "action": "createConnectSession",
  "returnUrl": "https://your-saas.com/settings/whatsapp"
}
```

Open `url` from the result (`https://watext.io/connect/whatsapp?session=…`). Listen for `postMessage` from `https://watext.io` (`watext-whatsapp-connected`) or handle `returnUrl?whatsapp=connected&id=…`.

`connectNumber` is only for the rare case where your domain is already on the Meta app allowlist and you run Embedded Signup yourself.

#### Create a template

Same as the watext **New template** screen - including **Add button → Copy offer code** (coupon). Every builder button type is valid: URL, phone, WhatsApp call, quick reply, copy code.

```json
{
  "action": "createTemplate",
  "name": "spring_sale_2026",
  "language": "en",
  "category": "MARKETING",
  "format": "standard",
  "headerType": "image",
  "headerMedia": "https://cdn.example.com/hero.jpg",
  "body": "Hello {{1}}, use code SAVE20 at checkout.",
  "footer": "Powered by Watext.io",
  "buttons": [
    { "type": "URL", "text": "Shop", "url": "https://example.com" },
    { "type": "PHONE_NUMBER", "text": "Call", "phone_number": "+905321234567" },
    { "type": "VOICE_CALL", "text": "WhatsApp", "ttl_minutes": 10080 },
    { "type": "QUICK_REPLY", "text": "Help" },
    { "type": "COPY_CODE", "text": "Copy code", "example": "SAVE20" }
  ]
}
```

`COPY_CODE` is the coupon / offer-code button from the builder (`example` = “Offer code example”). Shorthand: `"copyCode": "SAVE20"` (or `couponCode`) adds that button if you omit it from `buttons`.

Limited-time offer (builder LTO: offer text, expiration, copy code, URL):

```json
{
  "action": "createTemplate",
  "name": "flash_sale_lto",
  "language": "en",
  "category": "MARKETING",
  "format": "limited_time_offer",
  "body": "Offer ends soon.",
  "ltoText": "Expiring offer!",
  "ltoHasExpiration": true,
  "ltoCopyCodeExample": "OFFER25",
  "ltoUrlButtonText": "Shop now",
  "ltoUrl": "https://example.com/offer?code={{1}}",
  "ltoUrlExample": "https://example.com/offer?ref=abc",
  "ltoHeaderFormat": "IMAGE",
  "ltoHeaderMedia": "https://cdn.example.com/lto.jpg"
}
```

Catalog uses `catalogId`. Carousel uses `carouselCards`. `saveAsDraft: true` is **Save as draft**. `GET /api/v1/templates/options` is the same options list the New template screen loads.

#### Send

```json
{
  "action": "send",
  "to": "+905321234567",
  "templateName": "welcome_message",
  "languageCode": "en",
  "parameters": ["Ahmet"]
}
```

### Input fields

| Field | Required | Description |
| --- | --- | --- |
| `action` | Yes | Prefer setting it explicitly (`createConnectSession`, `createTemplate`, `send`, …) |
| `code`, `wabaId`, `phoneNumberId` | `connectNumber` | From Embedded Signup if you run Facebook login yourself |
| `returnUrl` | `createConnectSession` | Required https URL on your site. After connect we redirect here with `?whatsapp=connected&id=` |
| `id` | `disconnectNumber` | Number id from `listNumbers` |
| `name`, `language`, `category`, `format`, `headerType`, `body` | `createTemplate` | Same as the New template form |
| `headerMedia` | image/video/pdf/gif | data URL or https URL; or `draft.headerMediaHandle` after `/templates/media` |
| `buttons` | No | `URL`, `PHONE_NUMBER`, `VOICE_CALL`, `QUICK_REPLY`, `COPY_CODE` (coupon; `example` is the code) |
| `copyCode` / `couponCode` | No | Adds the Copy offer code button (`SAVE20`) if it is not already in `buttons` |
| `catalogId`, `carouselCards`, `ltoCopyCodeExample`, `draft` | catalog/carousel/LTO | Same fields as the builder |
| `saveAsDraft` | No | `true` = Save as draft |
| `to`, `templateName` or `text` | `send` | Recipient + approved template or session text |
| `from` | No | Number id when the workspace has more than one line |

Direct REST to watext.io is disabled (402). Call this Actor from your backend. See [api/README.md](../README.md) in the repo.

### Pricing

On Apify, a successful `send` may be charged as `message-sent`. Connect/template calls are not that event. Meta conversation fees are billed by Meta on the WhatsApp Business Account you connected.

### Policy

- Recipients must be valid international WhatsApp numbers
- Templates must be approved before `send`
- Session `text` only works inside the 24-hour window
- Do not use this for spam or anything that violates WhatsApp Business Policy

### Troubleshooting

| Error | What to do |
| --- | --- |
| `API keys from watext.io are disabled` | Do not send `apiKey`. Run the Actor on Apify. |
| `This Actor must run on Apify` | Use Apify Console / API, not a local script without `APIFY_USER_ID` |
| `No connected WhatsApp number` | `createConnectSession`, open the returned URL, then retry |
| `Approved template … was not found` | `createTemplate` + `syncTemplates`, wait for `APPROVED` |
| HTML 502 / Cloudflare | watext.io API blocked or down - retry later |
| `input_schema.json is not json file` | Rebuild from latest `main`. Schema on 0.2.2+ is valid JSON |

# Changelog

This Actor's version history is a separate document: https://apify.com/c4rbanak/whatsapp-business-cloud-api-automation/changelog.md

# Actor input Schema

## `action` (type: `string`):

Platform action. Prefer createConnectSession so Facebook login runs on watext.io (no partner domain allowlist). createTemplate / syncTemplates for templates, send to deliver.

## `returnUrl` (type: `string`):

Required for createConnectSession. After WhatsApp connects, the browser is sent back here with ?whatsapp=connected\&id=…

## `code` (type: `string`):

OAuth code from FB.login after Embedded Signup. Only needed if you run Facebook login on your own domain instead of createConnectSession.

## `wabaId` (type: `string`):

whatsapp\_business\_account\_id from the Embedded Signup WA\_EMBEDDED\_SIGNUP message.

## `phoneNumberId` (type: `string`):

phone\_number\_id from the Embedded Signup WA\_EMBEDDED\_SIGNUP message.

## `id` (type: `string`):

Connected number id from listNumbers. Used by disconnectNumber.

## `name` (type: `string`):

Lowercase template name, e.g. spring\_sale\_2026. Meta name is normalized from this.

## `category` (type: `string`):

Same as the builder: MARKETING, UTILITY, or AUTHENTICATION.

## `language` (type: `string`):

Meta template language code, e.g. tr, en\_US, de. Full list: getTemplateOptions / GET /api/v1/templates/options.

## `format` (type: `string`):

Same as the builder: Standard, Catalog, Carousel, Limited time offers.

## `headerType` (type: `string`):

none, text, image (JPEG/PNG), video (MP4/3GPP), document (PDF), or gif.

## `header` (type: `string`):

Used when headerType is text.

## `headerMedia` (type: `string`):

data URL or https URL for image/video/document/gif. Or upload via POST /api/v1/templates/media and set headerMediaHandle in draft.

## `body` (type: `string`):

Body text. Variables {{1}} or {{name}}. Formatting: *bold*, *italic*, ~strikethrough~.

## `footer` (type: `string`):

Optional footer, max 60 characters.

## `buttons` (type: `array`):

URL, PHONE\_NUMBER, VOICE\_CALL, QUICK\_REPLY, COPY\_CODE. Example: \[{"type":"QUICK\_REPLY","text":"Help"}]

## `copyCode` (type: `string`):

Same as Add button → Copy offer code in the builder. Adds a COPY\_CODE button with this example (e.g. SAVE20). For LTO templates this is the Copy code example field.

## `catalogId` (type: `string`):

Required for format catalog. From getTemplateOptions.catalogs after connect.

## `draft` (type: `object`):

Same payload as the watext New template screen (NewTemplateDraft). Overrides flat fields. Use this for carousel cards, LTO, and media handles.

## `saveAsDraft` (type: `boolean`):

If true, do not submit to Meta (same as Save as draft in the builder).

## `to` (type: `string`):

International WhatsApp number, e.g. +905321234567. Required when action is send.

## `templateName` (type: `string`):

Approved template on the connected number. Required for send unless you send a 24-hour session text.

## `languageCode` (type: `string`):

Template language code, e.g. tr or en\_US.

## `parameters` (type: `array`):

Positional body variables mapped to {{1}}, {{2}}, and so on.

## `text` (type: `string`):

Free-form text. Only works inside the 24-hour customer service window. Ignored if templateName is set.

## `from` (type: `string`):

Optional. One of your number ids from listNumbers. Leave empty to use the workspace default.

## Actor input object example

```json
{
  "action": "getConfig",
  "category": "UTILITY",
  "language": "tr",
  "format": "standard",
  "headerType": "none",
  "copyCode": "SAVE20",
  "saveAsDraft": false,
  "to": "+905321234567",
  "templateName": "welcome_message",
  "languageCode": "tr",
  "parameters": [
    "Ahmet"
  ]
}
```

# Actor output Schema

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

No description

# 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 = {
    "action": "getConfig",
    "language": "tr",
    "copyCode": "SAVE20",
    "to": "+905321234567",
    "templateName": "welcome_message",
    "languageCode": "tr",
    "parameters": [
        "Ahmet"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("c4rbanak/whatsapp-business-cloud-api-automation").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 = {
    "action": "getConfig",
    "language": "tr",
    "copyCode": "SAVE20",
    "to": "+905321234567",
    "templateName": "welcome_message",
    "languageCode": "tr",
    "parameters": ["Ahmet"],
}

# Run the Actor and wait for it to finish
run = client.actor("c4rbanak/whatsapp-business-cloud-api-automation").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "action": "getConfig",
  "language": "tr",
  "copyCode": "SAVE20",
  "to": "+905321234567",
  "templateName": "welcome_message",
  "languageCode": "tr",
  "parameters": [
    "Ahmet"
  ]
}' |
apify call c4rbanak/whatsapp-business-cloud-api-automation --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,c4rbanak/whatsapp-business-cloud-api-automation"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/z8UMdb83HAVivpTLZ/builds/cNsIn7AHQtlSpHwbT/openapi.json
