# WhatsApp reference

> Every WhatsApp endpoint with parameters, request and response fields, required scope and a curl example.

Every WhatsApp endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer <API key>`. Read endpoints need `whatsapp:read` (or `:write`), write endpoints need `whatsapp:write`; the bare `whatsapp` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).

**71 endpoints**

| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/whatsapp/v1/auto-responses` | ListAutoResponses | read |
| `POST` | `/whatsapp/v1/auto-responses` | CreateAutoResponse | write |
| `DELETE` | `/whatsapp/v1/auto-responses/{autoResponseId}` | DeleteAutoResponse | write |
| `PUT` | `/whatsapp/v1/auto-responses/{autoResponseId}` | UpdateAutoResponse | write |
| `GET` | `/whatsapp/v1/blocked-numbers` | ListBlockedNumbers | read |
| `POST` | `/whatsapp/v1/blocked-numbers` | BlockNumber | write |
| `DELETE` | `/whatsapp/v1/blocked-numbers/{mobileNumber}` | UnblockNumber | write |
| `GET` | `/whatsapp/v1/campaigns` | ListCampaigns | read |
| `POST` | `/whatsapp/v1/campaigns` | CreateCampaign | write |
| `GET` | `/whatsapp/v1/campaigns/{campaignId}` | GetCampaign | read |
| `POST` | `/whatsapp/v1/campaigns/{campaignId}:cancel` | CancelCampaign | write |
| `POST` | `/whatsapp/v1/campaigns/{campaignId}:start` | StartCampaign | write |
| `POST` | `/whatsapp/v1/campaigns/{campaignId}/recipients:add` | AddCampaignRecipients | write |
| `GET` | `/whatsapp/v1/chats` | ListChats | read |
| `POST` | `/whatsapp/v1/chats/{contact}:assign` | AssignChat | write |
| `POST` | `/whatsapp/v1/chats/{contact}:markRead` | MarkChatRead | write |
| `GET` | `/whatsapp/v1/chats/{contact}/messages` | ListChatMessages | read |
| `POST` | `/whatsapp/v1/chats/{contact}/messages` | SendChatMessage | write |
| `POST` | `/whatsapp/v1/commerce/catalogs` | CreateCatalog | write |
| `POST` | `/whatsapp/v1/commerce/catalogs:connect` | ConnectCatalog | write |
| `GET` | `/whatsapp/v1/commerce/product-batches` | ListProductBatches | read |
| `POST` | `/whatsapp/v1/commerce/product-batches` | CreateProductBatch | write |
| `DELETE` | `/whatsapp/v1/commerce/product-batches/{productBatchId}` | DeleteProductBatch | write |
| `GET` | `/whatsapp/v1/commerce/product-batches/{productBatchId}` | GetProductBatch | read |
| `POST` | `/whatsapp/v1/commerce/product-batches/{productBatchId}:setLive` | SetProductBatchLive | write |
| `GET` | `/whatsapp/v1/commerce/settings` | GetCommerceSettings | read |
| `PUT` | `/whatsapp/v1/commerce/settings` | SetCommerceSettings | write |
| `GET` | `/whatsapp/v1/contact-attributes` | ListContactAttributes | read |
| `POST` | `/whatsapp/v1/contact-attributes` | CreateContactAttribute | write |
| `DELETE` | `/whatsapp/v1/contact-attributes/{name}` | DeleteContactAttribute | write |
| `GET` | `/whatsapp/v1/contact-attributes/{name}/contacts` | ListContactsForAttribute | read |
| `GET` | `/whatsapp/v1/contact-groups` | ListGroups | read |
| `POST` | `/whatsapp/v1/contact-groups` | CreateGroup | write |
| `DELETE` | `/whatsapp/v1/contact-groups/{groupId}` | DeleteGroup | write |
| `PATCH` | `/whatsapp/v1/contact-groups/{groupId}` | UpdateGroup | write |
| `GET` | `/whatsapp/v1/contact-groups/{groupId}/members` | ListGroupContacts | read |
| `PUT` | `/whatsapp/v1/contact-groups/{groupId}/members` | SetGroupMembers | write |
| `POST` | `/whatsapp/v1/contact-groups/{groupId}/members:add` | AddGroupContacts | write |
| `GET` | `/whatsapp/v1/contacts` | ListContacts | read |
| `POST` | `/whatsapp/v1/contacts` | CreateContact | write |
| `POST` | `/whatsapp/v1/contacts:bulkImport` | BulkImportContacts | write |
| `GET` | `/whatsapp/v1/contacts:byPhone` | GetContactByPhone | read |
| `POST` | `/whatsapp/v1/contacts:setTags` | SetContactTags | write |
| `DELETE` | `/whatsapp/v1/contacts/{contactId}` | DeleteContact | write |
| `PATCH` | `/whatsapp/v1/contacts/{contactId}` | UpdateContact | write |
| `GET` | `/whatsapp/v1/flows` | ListFlows | read |
| `POST` | `/whatsapp/v1/flows` | CreateFlow | write |
| `DELETE` | `/whatsapp/v1/flows/{flowId}` | DeleteFlow | write |
| `GET` | `/whatsapp/v1/flows/{flowId}` | GetFlow | read |
| `PUT` | `/whatsapp/v1/flows/{flowId}` | UpdateFlow | write |
| `POST` | `/whatsapp/v1/flows/{flowId}:duplicate` | DuplicateFlow | write |
| `POST` | `/whatsapp/v1/flows/{flowId}:setActive` | SetFlowActive | write |
| `GET` | `/whatsapp/v1/inbound-messages` | ListInboundMessages | read |
| `GET` | `/whatsapp/v1/media` | ListMedia | read |
| `POST` | `/whatsapp/v1/media` | UploadMedia | write |
| `DELETE` | `/whatsapp/v1/media/{mediaId}` | DeleteMedia | write |
| `GET` | `/whatsapp/v1/message-reports` | ListMessageReports | read |
| `GET` | `/whatsapp/v1/message-stats` | GetMessageStats | read |
| `GET` | `/whatsapp/v1/messages` | ListMessages | read |
| `POST` | `/whatsapp/v1/messages` | SendMessage | write |
| `GET` | `/whatsapp/v1/numbers` | ListNumbers | read |
| `POST` | `/whatsapp/v1/numbers:connect` | ConnectNumber | write |
| `POST` | `/whatsapp/v1/numbers/{phoneNumberId}:disconnect` | DisconnectNumber | write |
| `GET` | `/whatsapp/v1/opt-out-config` | GetOptOutConfig | read |
| `PUT` | `/whatsapp/v1/opt-out-config` | SetOptOutConfig | write |
| `GET` | `/whatsapp/v1/templates` | ListTemplates | read |
| `POST` | `/whatsapp/v1/templates` | CreateTemplate | write |
| `DELETE` | `/whatsapp/v1/templates/{templateName}` | DeleteTemplate | write |
| `GET` | `/whatsapp/v1/templates/{templateName}` | GetTemplate | read |
| `PATCH` | `/whatsapp/v1/templates/{templateName}:archive` | ArchiveTemplate | write |
| `PUT` | `/whatsapp/v1/webhook` | SetWebhookConfig | write |

## GET /whatsapp/v1/auto-responses

**ListAutoResponses** · needs `whatsapp:read` (or write)

===================================================================
Auto-responses - keyword -> canned text reply
===================================================================
Lists the auto-responses of a number (the complete list, unpaginated).

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `ListAutoResponsesResponse`

| Field | Type | Description |
|---|---|---|
| `autoResponses` | AutoResponse[] |  |
| `autoResponses[].id` | string (int64) |  |
| `autoResponses[].title` | string |  |
| `autoResponses[].matchType` | string | "exact" or "contains". |
| `autoResponses[].keywords` | string[] |  |
| `autoResponses[].responseType` | string |  |
| `autoResponses[].responseText` | string |  |
| `autoResponses[].active` | boolean |  |
| `autoResponses[].createdAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/auto-responses" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/auto-responses

**CreateAutoResponse** · needs `whatsapp:write`

Creates an auto-response and returns its id. Not idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `title` | string | Internal label. |
| `matchType` | string | "exact" or "contains". |
| `keywords` | string[] | Incoming-message keywords that trigger the reply. |
| `responseText` | string | The reply text. |
| `active` | boolean |  |

**Response** `AutoResponseResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string (int64) | Id of the created auto-response (set by create). |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/auto-responses" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","title":"…","matchType":"…","keywords":[],"responseText":"…","active":false}'
```

## DELETE /whatsapp/v1/auto-responses/{autoResponseId}

**DeleteAutoResponse** · needs `whatsapp:write`

Deletes an auto-response. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `autoResponseId` | string (int64) |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `AutoResponseResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string (int64) | Id of the created auto-response (set by create). |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/auto-responses/AUTORESPONSEID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PUT /whatsapp/v1/auto-responses/{autoResponseId}

**UpdateAutoResponse** · needs `whatsapp:write`

Replaces an auto-response's settings (send every field). Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `autoResponseId` | string (int64) |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `title` | string |  |
| `matchType` | string |  |
| `keywords` | string[] |  |
| `responseText` | string |  |
| `active` | boolean |  |

**Response** `AutoResponseResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string (int64) | Id of the created auto-response (set by create). |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/auto-responses/AUTORESPONSEID" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","title":"…","matchType":"…","keywords":[],"responseText":"…","active":false}'
```

## GET /whatsapp/v1/blocked-numbers

**ListBlockedNumbers** · needs `whatsapp:read` (or write)

Lists blocked (opted-out) numbers: no template or campaign message is
sent to them. Paginated.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `pageSize` | integer | 0 = 100; maximum 1000. |
| `pageToken` | string |  |

**Response** `ListBlockedNumbersResponse`

| Field | Type | Description |
|---|---|---|
| `numbers` | BlockedNumber[] |  |
| `numbers[].mobileNumber` | string |  |
| `numbers[].createdAt` | string |  |
| `nextPageToken` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/blocked-numbers" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/blocked-numbers

**BlockNumber** · needs `whatsapp:write`

Blocks a number, as if the customer had opted out. Idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `mobileNumber` | string | E.164 digits ("+" optional). |

**Response** `BlockNumberResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/blocked-numbers" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","mobileNumber":"…"}'
```

## DELETE /whatsapp/v1/blocked-numbers/{mobileNumber}

**UnblockNumber** · needs `whatsapp:write`

Unblocks a number so it can receive messages again. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `mobileNumber` | string | E.164 digits; in REST put it URL-encoded in the path ("%2B1555..."). |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `UnblockNumberResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/blocked-numbers/MOBILENUMBER" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/campaigns

**ListCampaigns** · needs `whatsapp:read` (or write)

Lists the organization's campaigns, newest first (at most the 200 most
recent are reachable), without the delivery breakdown (use GetCampaign
for that).

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | 0 = 50; maximum 200. |
| `pageToken` | string |  |

**Response** `ListCampaignsResponse`

| Field | Type | Description |
|---|---|---|
| `campaigns` | CampaignSummary[] |  |
| `campaigns[].id` | string |  |
| `campaigns[].name` | string |  |
| `campaigns[].templateName` | string |  |
| `campaigns[].status` | string |  |
| `campaigns[].total` | integer | Recipient counters; total = pending + sending + sent + failed + skipped. |
| `campaigns[].pending` | integer |  |
| `campaigns[].sending` | integer |  |
| `campaigns[].sent` | integer | Accepted by Meta (this does not yet mean delivered to the phone). |
| `campaigns[].failed` | integer |  |
| `campaigns[].skipped` | integer | Not attempted (opted out, cancelled, out of credits). |
| `campaigns[].error` | string | Campaign-level error, when status is failed. |
| `campaigns[].createdAt` | string |  |
| `campaigns[].startedAt` | string |  |
| `campaigns[].finishedAt` | string |  |
| `campaigns[].ratePerSec` | integer | The configured send-rate cap, messages per second. |
| `campaigns[].avgRatePerSec` | number | Observed throughput since start (0 before it starts) and estimated seconds to finish (-1 when unknown). |
| `campaigns[].etaSeconds` | string (int64) |  |
| `campaigns[].scheduledAt` | string |  |
| `campaigns[].delivered` | integer | Delivery results from Meta's webhooks. Filled by GetCampaign only; list and start responses leave them 0. delivered or read |
| `campaigns[].read` | integer |  |
| `campaigns[].deliveryFailed` | integer |  |
| `nextPageToken` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/campaigns" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/campaigns

**CreateCampaign** · needs `whatsapp:write`

Creates a campaign in `draft` status. Validates the template (must be
APPROVED), media and carousel settings once for all recipients. Not
idempotent: every call creates a new campaign, so after a timeout call
ListCampaigns before retrying. Errors: INVALID_ARGUMENT (missing
templateName, bad media), NOT_FOUND (unknown template or number),
FAILED_PRECONDITION (template not approved), RESOURCE_EXHAUSTED (too
many campaigns already running).

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Number to send from; see the shared conventions above. |
| `name` | string | Human-readable campaign name (shown in reports; also usable as the campaignName filter of ListMessageReports). |
| `templateName` | string | Name of an APPROVED template (see ListTemplates). Required. |
| `language` | string | Template language code, e.g. "en_US". Needed when the template exists in several languages. |
| `category` | string | Template category recorded for reports (MARKETING, UTILITY, AUTHENTICATION); also drives billing. |
| `mediaType` | string | For a template with a media header: image, video or document. Then give exactly one of mediaId (from UploadMedia/ListMedia) or mediaUrl. |
| `mediaId` | string |  |
| `mediaUrl` | string |  |
| `cardMedia` | CarouselCardMedia[] | Per-card media for a carousel template, one entry per card in order. Leave empty for non-carousel templates. |
| `cardMedia[].mediaType` | string |  |
| `cardMedia[].mediaId` | string |  |
| `cardMedia[].mediaUrl` | string |  |
| `cardMedia[].buttonVars` | object |  |
| `ratePerSec` | integer | Maximum send rate in messages per second. 0 = server default; values above the server maximum are clamped (the response tells the real rate). |
| `scheduledAt` | string | RFC 3339. Empty = send as soon as StartCampaign is called; otherwise the campaign waits in the queue until this time. |

**Response** `CreateCampaignResponse`

| Field | Type | Description |
|---|---|---|
| `campaignId` | string | Id to use in all later campaign calls. |
| `ratePerSec` | integer | The rate (messages per second) the campaign will actually run at. |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/campaigns" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d @body.json
```

## GET /whatsapp/v1/campaigns/{campaignId}

**GetCampaign** · needs `whatsapp:read` (or write)

Reads one campaign with live progress counters, delivery results from
Meta's webhooks (delivered/read/deliveryFailed) and the first 100
per-recipient send failures. NOT_FOUND for a campaign that belongs to
another organization.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `campaignId` | string |  |

**Response** `GetCampaignResponse`

| Field | Type | Description |
|---|---|---|
| `campaign` | CampaignSummary |  |
| `campaign.id` | string |  |
| `campaign.name` | string |  |
| `campaign.templateName` | string |  |
| `campaign.status` | string |  |
| `campaign.total` | integer | Recipient counters; total = pending + sending + sent + failed + skipped. |
| `campaign.pending` | integer |  |
| `campaign.sending` | integer |  |
| `campaign.sent` | integer | Accepted by Meta (this does not yet mean delivered to the phone). |
| `campaign.failed` | integer |  |
| `campaign.skipped` | integer | Not attempted (opted out, cancelled, out of credits). |
| `campaign.error` | string | Campaign-level error, when status is failed. |
| `campaign.createdAt` | string |  |
| `campaign.startedAt` | string |  |
| `campaign.finishedAt` | string |  |
| `campaign.ratePerSec` | integer | The configured send-rate cap, messages per second. |
| `campaign.avgRatePerSec` | number | Observed throughput since start (0 before it starts) and estimated seconds to finish (-1 when unknown). |
| `campaign.etaSeconds` | string (int64) |  |
| `campaign.scheduledAt` | string |  |
| `campaign.delivered` | integer | Delivery results from Meta's webhooks. Filled by GetCampaign only; list and start responses leave them 0. delivered or read |
| `campaign.read` | integer |  |
| `campaign.deliveryFailed` | integer |  |
| `failures` | CampaignFailure[] | The first 100 recipients that failed, with the reason. |
| `failures[].mobile` | string |  |
| `failures[].error` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/campaigns/CAMPAIGNID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/campaigns/{campaignId}:cancel

**CancelCampaign** · needs `whatsapp:write`

Cancels a campaign: messages not yet sent will not be sent. Messages
already sent cannot be recalled. Idempotent; `cancelled` is false if
the campaign had already finished.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `campaignId` | string |  |

**Response** `CancelCampaignResponse`

| Field | Type | Description |
|---|---|---|
| `cancelled` | boolean | false if the campaign had already finished. |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/campaigns/CAMPAIGNID:cancel" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/campaigns/{campaignId}:start

**StartCampaign** · needs `whatsapp:write`

Starts a draft campaign (or queues it until its scheduledAt). A
campaign that is not a startable draft (already started, or unknown to
your organization) returns an error; see the Connect/gRPC code.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `campaignId` | string |  |

**Response** `StartCampaignResponse`

| Field | Type | Description |
|---|---|---|
| `campaign` | CampaignSummary |  |
| `campaign.id` | string |  |
| `campaign.name` | string |  |
| `campaign.templateName` | string |  |
| `campaign.status` | string |  |
| `campaign.total` | integer | Recipient counters; total = pending + sending + sent + failed + skipped. |
| `campaign.pending` | integer |  |
| `campaign.sending` | integer |  |
| `campaign.sent` | integer | Accepted by Meta (this does not yet mean delivered to the phone). |
| `campaign.failed` | integer |  |
| `campaign.skipped` | integer | Not attempted (opted out, cancelled, out of credits). |
| `campaign.error` | string | Campaign-level error, when status is failed. |
| `campaign.createdAt` | string |  |
| `campaign.startedAt` | string |  |
| `campaign.finishedAt` | string |  |
| `campaign.ratePerSec` | integer | The configured send-rate cap, messages per second. |
| `campaign.avgRatePerSec` | number | Observed throughput since start (0 before it starts) and estimated seconds to finish (-1 when unknown). |
| `campaign.etaSeconds` | string (int64) |  |
| `campaign.scheduledAt` | string |  |
| `campaign.delivered` | integer | Delivery results from Meta's webhooks. Filled by GetCampaign only; list and start responses leave them 0. delivered or read |
| `campaign.read` | integer |  |
| `campaign.deliveryFailed` | integer |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/campaigns/CAMPAIGNID:start" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/campaigns/{campaignId}/recipients:add

**AddCampaignRecipients** · needs `whatsapp:write`

Adds recipients to a `draft` campaign (up to 5000 per call; call
repeatedly for larger audiences). Numbers already on the campaign are
counted as duplicates and opted-out numbers are skipped, so retrying a
chunk is safe.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `campaignId` | string | Campaign id from CreateCampaign. Must still be in `draft` status. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `recipients` | CampaignRecipient[] | Up to 5000 recipients per call. |
| `recipients[].mobile` | string | Recipient WhatsApp number in E.164 digits ("+" optional). |
| `recipients[].bodyParams` | string[] | Values for the template body variables {{1}}, {{2}}... in order. |
| `recipients[].buttonUrlParams` | object | Dynamic URL button values, keyed by the button's 0-based index in the template's button list. For a carousel they apply to every card's button. |

**Response** `AddCampaignRecipientsResponse`

| Field | Type | Description |
|---|---|---|
| `accepted` | integer | Recipients newly added by this call. |
| `duplicates` | integer | Recipients already on the campaign (ignored). |
| `skippedOptedOut` | integer | Recipients not added because they are blocked / opted out. |
| `total` | integer | Recipients now on the campaign in total. |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/campaigns/CAMPAIGNID/recipients:add" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipients":[]}'
```

## GET /whatsapp/v1/chats

**ListChats** · needs `whatsapp:read` (or write)

===================================================================
Team Inbox chats - human conversations with customers
===================================================================
Lists conversations (one per customer number) with the last message,
unread count and assignee, most recently active first.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `pageSize` | integer | 0 = 100; maximum 500. |
| `pageToken` | string |  |
| `assigneeFilter` | string | Empty = all chats, "unassigned", or the user id of one member. "mine" is not available to API keys (they have no user). |

**Response** `ListChatsResponse`

| Field | Type | Description |
|---|---|---|
| `chats` | ChatSummary[] |  |
| `chats[].contact` | string | Customer number, E.164 digits. Use it as `contact` in the chat calls. |
| `chats[].lastMessage` | string |  |
| `chats[].lastDirection` | string |  |
| `chats[].lastAt` | string |  |
| `chats[].unreadCount` | integer |  |
| `chats[].name` | string | WhatsApp profile name; empty if never seen. |
| `chats[].assigneeId` | string | User id of the assignee; empty = unassigned. |
| `nextPageToken` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/chats" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/chats/{contact}:assign

**AssignChat** · needs `whatsapp:write`

Assigns a conversation to one organization member or clears the
assignment. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contact` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `assigneeId` | string | User id of an organization member; empty = unassign. API keys have no user, so "me" is not available to them. |

**Response** `AssignChatResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/chats/CONTACT:assign" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","assigneeId":"…"}'
```

## POST /whatsapp/v1/chats/{contact}:markRead

**MarkChatRead** · needs `whatsapp:write`

Clears the unread badge of one conversation. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contact` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `MarkChatReadResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/chats/CONTACT:markRead" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…"}'
```

## GET /whatsapp/v1/chats/{contact}/messages

**ListChatMessages** · needs `whatsapp:read` (or write)

Reads one conversation's messages (inbound and outbound). The first
page holds the newest messages; nextPageToken leads to older ones.
Within a page messages are ordered oldest to newest.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contact` | string | Customer number (E.164 digits). Required. |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `pageSize` | integer | 0 = 200; maximum 500. |
| `pageToken` | string |  |

**Response** `ListChatMessagesResponse`

| Field | Type | Description |
|---|---|---|
| `messages` | ChatMessage[] |  |
| `messages[].direction` | string |  |
| `messages[].body` | string |  |
| `messages[].msgType` | string |  |
| `messages[].status` | string | Delivery status of outbound messages; empty for inbound. |
| `messages[].createdAt` | string |  |
| `outsideServiceWindow` | boolean | True when the customer's last inbound message is more than 24 hours old: free-text replies are then refused by WhatsApp and only an approved template (SendMessage) can restart the conversation. |
| `nextPageToken` | string | Token for the next OLDER page. |

```bash
curl "https://api.pingx.ai/whatsapp/v1/chats/CONTACT/messages" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/chats/{contact}/messages

**SendChatMessage** · needs `whatsapp:write`

Sends a free-text reply to a customer. Only allowed inside the 24-hour
customer-service window (see ListChatMessages.outsideServiceWindow);
outside it the call returns success=false and you must send an approved
template with SendMessage instead. Billed like SendMessage. Not
idempotent: retrying after a timeout can deliver the reply twice.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contact` | string | Customer number (E.164 digits). Required. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `body` | string | Text of the reply. Required. |
| `phoneNumberId` | string |  |

**Response** `pingxWhatsappV1SendChatMessageResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean | false (with `message` explaining) when outside the 24-hour window or Meta/billing refused the send. |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/chats/CONTACT/messages" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body":"…","phoneNumberId":"…"}'
```

## POST /whatsapp/v1/commerce/catalogs

**CreateCatalog** · needs `whatsapp:write`

Creates a new Meta catalog on the organization's business and connects
it. Not idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `name` | string |  |

**Response** `CreateCatalogResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `catalogId` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/commerce/catalogs" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","name":"…"}'
```

## POST /whatsapp/v1/commerce/catalogs:connect

**ConnectCatalog** · needs `whatsapp:write`

Connects an existing Meta catalog to a number. Idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `catalogId` | string | One of GetCommerceSettings.availableCatalogs. |
| `catalogName` | string |  |

**Response** `CommerceResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/commerce/catalogs:connect" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","catalogId":"…","catalogName":"…"}'
```

## GET /whatsapp/v1/commerce/product-batches

**ListProductBatches** · needs `whatsapp:read` (or write)

Lists product batches (the complete list).

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `ListProductBatchesResponse`

| Field | Type | Description |
|---|---|---|
| `batches` | ProductBatch[] |  |
| `batches[].id` | string |  |
| `batches[].name` | string |  |
| `batches[].catalogId` | string |  |
| `batches[].wabaId` | string |  |
| `batches[].productCount` | integer |  |
| `batches[].live` | boolean | Whether the products are available in the catalog. |
| `batches[].createdAt` | string |  |
| `batches[].updatedAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/commerce/product-batches" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/commerce/product-batches

**CreateProductBatch** · needs `whatsapp:write`

Creates a batch of products: every item is pushed to the connected Meta
catalog in one call and the batch is recorded only if that succeeds
(Meta errors, e.g. a missing catalog permission, are returned as-is).
Not idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `name` | string |  |
| `items` | ProductBatchItem[] |  |
| `items[].retailerId` | string | Your own unique product id (SKU). |
| `items[].name` | string |  |
| `items[].description` | string |  |
| `items[].price` | string | Price as a decimal string, e.g. "19.99". |
| `items[].currency` | string | ISO 4217 code, e.g. "USD". |
| `items[].imageUrl` | string | Public HTTPS image URL. |
| `items[].category` | string |  |
| `items[].brand` | string |  |

**Response** `CreateProductBatchResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `productBatchId` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/commerce/product-batches" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","name":"…","items":[]}'
```

## DELETE /whatsapp/v1/commerce/product-batches/{productBatchId}

**DeleteProductBatch** · needs `whatsapp:write`

Deletes a product batch. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `productBatchId` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `CommerceResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/commerce/product-batches/PRODUCTBATCHID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/commerce/product-batches/{productBatchId}

**GetProductBatch** · needs `whatsapp:read` (or write)

Reads one product batch with its products.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `productBatchId` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `GetProductBatchResponse`

| Field | Type | Description |
|---|---|---|
| `batch` | ProductBatch |  |
| `batch.id` | string |  |
| `batch.name` | string |  |
| `batch.catalogId` | string |  |
| `batch.wabaId` | string |  |
| `batch.productCount` | integer |  |
| `batch.live` | boolean | Whether the products are available in the catalog. |
| `batch.createdAt` | string |  |
| `batch.updatedAt` | string |  |
| `items` | ProductBatchItem[] |  |
| `items[].retailerId` | string | Your own unique product id (SKU). |
| `items[].name` | string |  |
| `items[].description` | string |  |
| `items[].price` | string | Price as a decimal string, e.g. "19.99". |
| `items[].currency` | string | ISO 4217 code, e.g. "USD". |
| `items[].imageUrl` | string | Public HTTPS image URL. |
| `items[].category` | string |  |
| `items[].brand` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/commerce/product-batches/PRODUCTBATCHID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/commerce/product-batches/{productBatchId}:setLive

**SetProductBatchLive** · needs `whatsapp:write`

Publishes (live=true) or withdraws (live=false) a batch's products in
the catalog. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `productBatchId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `live` | boolean |  |

**Response** `CommerceResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/commerce/product-batches/PRODUCTBATCHID:setLive" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","live":false}'
```

## GET /whatsapp/v1/commerce/settings

**GetCommerceSettings** · needs `whatsapp:read` (or write)

===================================================================
Commerce - catalog, commerce settings and product batches
===================================================================
Reads the connected catalog and commerce settings of a number, plus the
catalogs available to connect.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `GetCommerceSettingsResponse`

| Field | Type | Description |
|---|---|---|
| `catalogId` | string | Connected catalog; empty if none. |
| `catalogName` | string |  |
| `catalogVisible` | boolean |  |
| `cartEnabled` | boolean |  |
| `availableCatalogs` | CommerceCatalogRef[] | Catalogs on the business that can be connected. |
| `availableCatalogs[].id` | string |  |
| `availableCatalogs[].name` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/commerce/settings" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PUT /whatsapp/v1/commerce/settings

**SetCommerceSettings** · needs `whatsapp:write`

Updates catalog visibility and cart settings of a number. Both fields
are always applied: read first if you only want to change one.
Idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `catalogVisible` | boolean | Show the catalog icon in the chat. |
| `cartEnabled` | boolean | Enable the shopping cart. |

**Response** `CommerceResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/commerce/settings" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","catalogVisible":false,"cartEnabled":false}'
```

## GET /whatsapp/v1/contact-attributes

**ListContactAttributes** · needs `whatsapp:read` (or write)

Contact attribute registry: a per-org catalog of customFields keys in
use — advisory, not a schema (contacts.customFields stays free-form).
Backs Manage Contacts > Manage Attributes and the Flow Builder's
attribute pickers.

**Response** `ListContactAttributesResponse`

| Field | Type | Description |
|---|---|---|
| `attributes` | ContactAttribute[] |  |
| `attributes[].name` | string |  |
| `attributes[].contactCount` | string (int64) |  |
| `attributes[].createdAt` | string |  |
| `attributes[].updatedAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contact-attributes" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/contact-attributes

**CreateContactAttribute** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |

**Response** `CreateContactAttributeResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contact-attributes" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…"}'
```

## DELETE /whatsapp/v1/contact-attributes/{name}

**DeleteContactAttribute** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `name` | string |  |

**Response** `DeleteContactAttributeResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/contact-attributes/NAME" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/contact-attributes/{name}/contacts

**ListContactsForAttribute** · needs `whatsapp:read` (or write)

Contacts that have a value set for one registered attribute — "view
contacts" from Manage Attributes.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `name` | string |  |

**Response** `ListContactsForAttributeResponse`

| Field | Type | Description |
|---|---|---|
| `contacts` | Contact[] |  |
| `contacts[].id` | string |  |
| `contacts[].name` | string |  |
| `contacts[].phone` | string |  |
| `contacts[].customFields` | object |  |
| `contacts[].createdAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contact-attributes/NAME/contacts" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/contact-groups

**ListGroups** · needs `whatsapp:read` (or write)

**Response** `ListGroupsResponse`

| Field | Type | Description |
|---|---|---|
| `groups` | Group[] |  |
| `groups[].id` | string |  |
| `groups[].name` | string |  |
| `groups[].contactCount` | integer |  |
| `groups[].createdAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contact-groups" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/contact-groups

**CreateGroup** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |

**Response** `CreateGroupResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `group` | Group |  |
| `group.id` | string |  |
| `group.name` | string |  |
| `group.contactCount` | integer |  |
| `group.createdAt` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contact-groups" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…"}'
```

## DELETE /whatsapp/v1/contact-groups/{groupId}

**DeleteGroup** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `groupId` | string |  |

**Response** `DeleteGroupResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/contact-groups/GROUPID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PATCH /whatsapp/v1/contact-groups/{groupId}

**UpdateGroup** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `groupId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |

**Response** `UpdateGroupResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PATCH "https://api.pingx.ai/whatsapp/v1/contact-groups/GROUPID" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…"}'
```

## GET /whatsapp/v1/contact-groups/{groupId}/members

**ListGroupContacts** · needs `whatsapp:read` (or write)

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `groupId` | string |  |

**Response** `ListGroupContactsResponse`

| Field | Type | Description |
|---|---|---|
| `contacts` | Contact[] |  |
| `contacts[].id` | string |  |
| `contacts[].name` | string |  |
| `contacts[].phone` | string |  |
| `contacts[].customFields` | object |  |
| `contacts[].createdAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contact-groups/GROUPID/members" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PUT /whatsapp/v1/contact-groups/{groupId}/members

**SetGroupMembers** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `groupId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `contactIds` | string[] |  |

**Response** `SetGroupMembersResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/contact-groups/GROUPID/members" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contactIds":[]}'
```

## POST /whatsapp/v1/contact-groups/{groupId}/members:add

**AddGroupContacts** · needs `whatsapp:write`

AddGroupContacts additively inserts contactIds into a group's
membership (existing members untouched) — unlike SetGroupMembers, which
replaces the whole list. Atomic server-side, so it's safe to call
concurrently from two clients without a lost-update race.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `groupId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `contactIds` | string[] |  |

**Response** `AddGroupContactsResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contact-groups/GROUPID/members:add" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contactIds":[]}'
```

## GET /whatsapp/v1/contacts

**ListContacts** · needs `whatsapp:read` (or write)

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `search` | string |  |
| `limit` | integer |  |

**Response** `ListContactsResponse`

| Field | Type | Description |
|---|---|---|
| `contacts` | Contact[] |  |
| `contacts[].id` | string |  |
| `contacts[].name` | string |  |
| `contacts[].phone` | string |  |
| `contacts[].customFields` | object |  |
| `contacts[].createdAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contacts" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/contacts

**CreateContact** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |
| `phone` | string |  |
| `customFields` | object |  |

**Response** `CreateContactResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `contact` | Contact |  |
| `contact.id` | string |  |
| `contact.name` | string |  |
| `contact.phone` | string |  |
| `contact.customFields` | object |  |
| `contact.createdAt` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contacts" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…","phone":"…","customFields":{}}'
```

## POST /whatsapp/v1/contacts:bulkImport

**BulkImportContacts** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `contacts` | Contact[] |  |
| `contacts[].id` | string |  |
| `contacts[].name` | string |  |
| `contacts[].phone` | string |  |
| `contacts[].customFields` | object |  |
| `contacts[].createdAt` | string |  |

**Response** `BulkImportContactsResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `importedCount` | integer |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contacts:bulkImport" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contacts":[]}'
```

## GET /whatsapp/v1/contacts:byPhone

**GetContactByPhone** · needs `whatsapp:read` (or write)

Reads one contact by WhatsApp number (any format; matched on its digits)
with its labels, and every label the organization uses (for pickers).

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phone` | string | digits, with or without "+" / spaces |

**Response** `GetContactByPhoneResponse`

| Field | Type | Description |
|---|---|---|
| `found` | boolean |  |
| `contact` | Contact |  |
| `contact.id` | string |  |
| `contact.name` | string |  |
| `contact.phone` | string |  |
| `contact.customFields` | object |  |
| `contact.createdAt` | string |  |
| `tags` | string[] |  |
| `knownTags` | string[] |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/contacts:byPhone" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/contacts:setTags

**SetContactTags** · needs `whatsapp:write`

Adds and/or removes plain labels ("tags") on the contact for a WhatsApp
number, creating the contact when the number is new. Adding a label the
contact already has, or removing one it does not have, is a no-op, so it
is safe to call repeatedly and concurrently. This is the call to label
customers from your own systems.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phone` | string |  |
| `add` | string[] |  |
| `remove` | string[] |  |
| `name` | string |  |

**Response** `SetContactTagsResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `contact` | Contact |  |
| `contact.id` | string |  |
| `contact.name` | string |  |
| `contact.phone` | string |  |
| `contact.customFields` | object |  |
| `contact.createdAt` | string |  |
| `tags` | string[] |  |
| `created` | boolean |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/contacts:setTags" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone":"…","add":[],"remove":[],"name":"…"}'
```

## DELETE /whatsapp/v1/contacts/{contactId}

**DeleteContact** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contactId` | string |  |

**Response** `DeleteContactResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/contacts/CONTACTID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PATCH /whatsapp/v1/contacts/{contactId}

**UpdateContact** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `contactId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |
| `phone` | string |  |
| `customFields` | object |  |

**Response** `UpdateContactResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PATCH "https://api.pingx.ai/whatsapp/v1/contacts/CONTACTID" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…","phone":"…","customFields":{}}'
```

## GET /whatsapp/v1/flows

**ListFlows** · needs `whatsapp:read` (or write)

Lists flows (summaries without the graph; the complete list).

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `ListFlowsResponse`

| Field | Type | Description |
|---|---|---|
| `flows` | FlowSummary[] |  |
| `flows[].id` | string |  |
| `flows[].name` | string |  |
| `flows[].channel` | string | "whatsapp". |
| `flows[].matchType` | string | The Start node's trigger: "exact" or "contains". |
| `flows[].keywords` | string[] |  |
| `flows[].active` | boolean | Only active flows respond to customers. |
| `flows[].createdAt` | string |  |
| `flows[].updatedAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/flows" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/flows

**CreateFlow** · needs `whatsapp:write`

Creates an empty, inactive flow and returns its id. Not idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `name` | string | Required. |
| `channel` | string | Defaults to "whatsapp". |

**Response** `FlowResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string | Id of the created flow (set by create). |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/flows" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","name":"…","channel":"…"}'
```

## DELETE /whatsapp/v1/flows/{flowId}

**DeleteFlow** · needs `whatsapp:write`

Deletes a flow. Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `flowId` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `FlowResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string | Id of the created flow (set by create). |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/flows/FLOWID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/flows/{flowId}

**GetFlow** · needs `whatsapp:read` (or write)

Reads one flow including its full graph.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `flowId` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Query parameter in REST. |

**Response** `GetFlowResponse`

| Field | Type | Description |
|---|---|---|
| `flow` | Flow | Flow is the full persisted flow including its graph. graph format (the Flow Builder's React Flow JSON, stored verbatim): {"nodes": [{"id": "n1", "type": "<type>", "position": {"x":0,"y":0}, "data": {...}}], "edges": [{"id": "e1", "source": "n1", "target": "n2", "sourceHandle": null, "targetHandle": null}]} "position" is only used by the visual editor. Exactly one "start" node is required and must have keywords. "sourceHandle" selects the branch of multi-output nodes: "true"/"false" for condition, the button/row "id" for buttons and list, "giveUp" for question after maxAttempts invalid replies. Node types and their "data" fields: start matchType (exact\|contains), keywords[] sendMessage text question question, captureAttribute, attributeFormat (text\|number\|email\|phone), validationError, maxAttempts input prompt, captureAttribute buttons text, buttons[{id,label}] list text, buttonLabel, sections[{title, rows[{id,title,description}]}] dynamicList text, buttonLabel, sectionTitle, sourceContextKey, idField, titleField, descriptionField, captureAttribute media mediaType (image\|video\|audio\|document), mediaId \| mediaUrl, caption multiMedia items[{mediaType, mediaId, mediaUrl, caption}] askMedia prompt, captureAttribute, allowedTypes[], validationError askLocation prompt, captureLocationAttribute, captureAddressAttribute askAddress prompt, captureAttribute, validationError template templateName, language, bodyVars[] condition variable, operator (exists\|notExists\|equals\|notEquals\| contains\|notContains\|greaterThan\|lessThan\|timeIn\|dateIn), value, valueEnd setAttribute attribute, value addTag groupId (a contact group id; see ListGroups) delay amount, unit (seconds\|minutes\|hours\|days) apiRequest method, url, headers{}, body, saveResponseTo connectFlow targetFlowId catalogMessage text, footer, thumbnailProductRetailerId product productRetailerId, bodyText, footerText multiProducts headerText, bodyText, footerText, sections[{title, productRetailerIds[]}] orderDetails prompt, captureAttribute Text fields may reference captured attributes with {{attribute}} variables. The safest way to author a graph is to GetFlow an existing flow built in the dashboard and copy its shapes. |
| `flow.id` | string |  |
| `flow.name` | string |  |
| `flow.channel` | string |  |
| `flow.matchType` | string |  |
| `flow.keywords` | string[] |  |
| `flow.graph` | object | See the format above. |
| `flow.active` | boolean |  |
| `flow.createdAt` | string |  |
| `flow.updatedAt` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/flows/FLOWID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PUT /whatsapp/v1/flows/{flowId}

**UpdateFlow** · needs `whatsapp:write`

Saves a flow's name, trigger and graph, replacing what was stored. The
graph is fully validated (INVALID_ARGUMENT lists the problems).
Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `flowId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `name` | string |  |
| `matchType` | string | "exact" or "contains" (the Start node's trigger). |
| `keywords` | string[] |  |
| `graph` | object | Full replacement graph; see Flow. |

**Response** `FlowResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string | Id of the created flow (set by create). |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/flows/FLOWID" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","name":"…","matchType":"…","keywords":[],"graph":{}}'
```

## POST /whatsapp/v1/flows/{flowId}:duplicate

**DuplicateFlow** · needs `whatsapp:write`

Copies a flow (inactive, named "<original> Copy"). Not idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `flowId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `DuplicateFlowResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `flowId` | string | Id of the new flow. |
| `name` | string | "<original> Copy". |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/flows/FLOWID:duplicate" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…"}'
```

## POST /whatsapp/v1/flows/{flowId}:setActive

**SetFlowActive** · needs `whatsapp:write`

Switches a flow on or off. Activation re-validates the flow and can
fail with INVALID_ARGUMENT (graph problems are listed) or NOT_FOUND.
Idempotent.

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `flowId` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `active` | boolean |  |

**Response** `FlowResult`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `id` | string | Id of the created flow (set by create). |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/flows/FLOWID:setActive" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumberId":"…","active":false}'
```

## GET /whatsapp/v1/inbound-messages

**ListInboundMessages** · needs `whatsapp:read` (or write)

Customer messages/replies received on the connected number(s), newest
first (the dashboard's Inbound Messages report). Paginated.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `pageSize` | integer | 0 = 50; clamped to [1, 200]. |
| `pageToken` | string |  |
| `query` | string | Free-text match on sender or message text. |
| `from` | string | RFC 3339 range on received time; empty = open-ended. |
| `to` | string |  |
| `includeTotal` | boolean |  |

**Response** `ListInboundMessagesResponse`

| Field | Type | Description |
|---|---|---|
| `rows` | InboundMessageRow[] |  |
| `rows[].messageId` | string |  |
| `rows[].sender` | string | Sender number, E.164 digits. |
| `rows[].receivedAt` | string |  |
| `rows[].msgType` | string | text \| button \| interactive \| image \| ... |
| `rows[].preview` | string | Best-effort text preview of the content. |
| `nextPageToken` | string |  |
| `totalMatching` | string (int64) |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/inbound-messages" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/media

**ListMedia** · needs `whatsapp:read` (or write)

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `ListMediaResponse`

| Field | Type | Description |
|---|---|---|
| `media` | MediaItem[] |  |
| `media[].mediaId` | string |  |
| `media[].mediaType` | string |  |
| `media[].identifier` | string |  |
| `media[].description` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/media" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/media

**UploadMedia** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `mediaType` | string |  |
| `identifier` | string |  |
| `description` | string |  |
| `fileName` | string |  |
| `file` | string (base64) |  |
| `phoneNumberId` | string |  |

**Response** `UploadMediaResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `media` | MediaItem |  |
| `media.mediaId` | string |  |
| `media.mediaType` | string |  |
| `media.identifier` | string |  |
| `media.description` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/media" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mediaType":"…","identifier":"…","description":"…","fileName":"…","file":"…","phoneNumberId":"…"}'
```

## DELETE /whatsapp/v1/media/{mediaId}

**DeleteMedia** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `mediaId` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `DeleteMediaResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/media/MEDIAID" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/message-reports

**ListMessageReports** · needs `whatsapp:read` (or write)

===================================================================
Message reports and inbound messages
===================================================================
Per-message delivery log (the dashboard's Report page) with filters.
This is the API equivalent of the dashboard's CSV export, which is
browser-session only: walk nextPageToken until it is empty to export
everything in a time range. Use ListMessages for a simple "latest N
sends" view.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Number filter; empty = all connected numbers. |
| `pageSize` | integer | 0 = 50; clamped to [1, 200]. |
| `pageToken` | string |  |
| `query` | string | Free-text match on campaign name, template name or recipient. |
| `category` | string | MARKETING \| UTILITY \| AUTHENTICATION; empty = any. |
| `status` | string | sent \| delivered \| read \| failed; "pending" = no delivery webhook yet; empty = any. |
| `campaignName` | string | Substring filter on the campaign name (independent of `query`). |
| `from` | string | RFC 3339 range on sent time; empty = open-ended. |
| `to` | string |  |
| `includeTotal` | boolean | If true, totalMatching is filled (extra cost on large ranges). |

**Response** `ListMessageReportsResponse`

| Field | Type | Description |
|---|---|---|
| `rows` | MessageReportRow[] |  |
| `rows[].providerMessageId` | string | WhatsApp message id ("wamid..."). |
| `rows[].campaignName` | string | Empty for one-off sends. |
| `rows[].templateName` | string |  |
| `rows[].category` | string |  |
| `rows[].language` | string |  |
| `rows[].recipient` | string | Recipient number, E.164 digits. |
| `rows[].sentAt` | string |  |
| `rows[].status` | string | sent \| delivered \| read \| failed; empty = no delivery webhook yet. |
| `rows[].errorReason` | string |  |
| `rows[].bodyPreview` | string | The rendered message text. |
| `nextPageToken` | string |  |
| `totalMatching` | string (int64) | Only when includeTotal was set. |

```bash
curl "https://api.pingx.ai/whatsapp/v1/message-reports" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/message-stats

**GetMessageStats** · needs `whatsapp:read` (or write)

Aggregate delivery funnel (initiated/sent/delivered/read/failed/replies)
for a time range plus a 7-day daily breakdown.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Empty = across every connected number. |
| `category` | string | empty = any |
| `status` | string | empty = any |
| `campaignName` | string | substring filter |
| `from` | string | RFC 3339 range. Both required. |
| `to` | string |  |

**Response** `GetMessageStatsResponse`

| Field | Type | Description |
|---|---|---|
| `initiated` | string (int64) |  |
| `sent` | string (int64) |  |
| `delivered` | string (int64) |  |
| `read` | string (int64) |  |
| `failed` | string (int64) |  |
| `replies` | string (int64) |  |
| `dailyCounts` | DailyCount[] | Messages per day for the last 7 calendar days. |
| `dailyCounts[].day` | string |  |
| `dailyCounts[].count` | string (int64) |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/message-stats" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/messages

**ListMessages** · needs `whatsapp:read` (or write)

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `limit` | integer |  |

**Response** `ListMessagesResponse`

| Field | Type | Description |
|---|---|---|
| `messages` | MessageRow[] |  |
| `messages[].providerMessageId` | string |  |
| `messages[].templateName` | string |  |
| `messages[].recipient` | string |  |
| `messages[].sentAt` | string |  |
| `messages[].status` | string |  |
| `messages[].errorReason` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/messages" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/messages

**SendMessage** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string | Required once the org has more than one connected number. |
| `to` | string |  |
| `text` | Text |  |
| `text.body` | string |  |
| `text.header` | string |  |
| `text.footer` | string |  |
| `text.previewUrl` | boolean |  |
| `buttons` | ReplyButtons |  |
| `buttons.body` | string |  |
| `buttons.header` | string |  |
| `buttons.footer` | string |  |
| `buttons.buttons` | Button[] |  |
| `list` | ListMessage |  |
| `list.header` | string |  |
| `list.body` | string |  |
| `list.footer` | string |  |
| `list.buttonLabel` | string |  |
| `list.sections` | ListSection[] |  |
| `location` | channelV1Location |  |
| `location.latitude` | number |  |
| `location.longitude` | number |  |
| `location.name` | string |  |
| `location.address` | string |  |
| `media` | Media |  |
| `media.mediaUrl` | string |  |
| `media.mediaId` | string |  |
| `media.mediaType` | string |  |
| `media.caption` | string |  |
| `media.documentName` | string |  |
| `template` | channelV1Template |  |
| `template.templateName` | string |  |
| `template.bodyVars` | string[] |  |
| `template.header` | string |  |
| `template.buttonVars` | object |  |
| `template.buttonUrlPath` | string |  |
| `template.mediaType` | string |  |
| `template.mediaUrl` | string |  |
| `template.mediaId` | string |  |
| `template.language` | string | Meta requires the template's language code to match how the template was registered (e.g. "en_US"). Empty defaults to en_US, which is wrong for any template created in another language — callers should set it. |
| `template.cards` | channelV1CarouselCard[] |  |

**Response** `SendMessageResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `providerMessageId` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/messages" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d @body.json
```

## GET /whatsapp/v1/numbers

**ListNumbers** · needs `whatsapp:read` (or write)

**Response** `pingxWhatsappV1ListNumbersResponse`

| Field | Type | Description |
|---|---|---|
| `numbers` | Number[] |  |
| `numbers[].phoneNumberId` | string |  |
| `numbers[].wabaId` | string |  |
| `numbers[].displayNumber` | string |  |
| `numbers[].verifiedName` | string |  |
| `numbers[].isDefault` | boolean |  |
| `numbers[].qualityRating` | string |  |
| `numbers[].messagingLimitTier` | string |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/numbers" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/numbers:connect

**ConnectNumber** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `embeddedSignupCode` | string | Embedded Signup mode: set embeddedSignupCode (+ wabaId/phoneNumberId from the same signup event). Manual mode: set accessToken instead of embeddedSignupCode, with the same wabaId/phoneNumberId. |
| `wabaId` | string |  |
| `phoneNumberId` | string |  |
| `businessId` | string |  |
| `accessToken` | string |  |

**Response** `ConnectNumberResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/numbers:connect" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"embeddedSignupCode":"…","wabaId":"…","phoneNumberId":"…","businessId":"…","accessToken":"…"}'
```

## POST /whatsapp/v1/numbers/{phoneNumberId}:disconnect

**DisconnectNumber** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `DisconnectNumberResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/numbers/PHONENUMBERID:disconnect" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/opt-out-config

**GetOptOutConfig** · needs `whatsapp:read` (or write)

===================================================================
Opt-out / opt-in handling and blocked numbers
===================================================================
Reads the keyword configuration that makes customers opt out of (e.g.
"STOP") or back into (e.g. "START") your messages.

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `GetOptOutConfigResponse`

| Field | Type | Description |
|---|---|---|
| `matchType` | string | "exact" (the whole message equals a keyword) or "contains". |
| `optoutKeywords` | string[] |  |
| `optoutResponse` | string | Reply sent when a customer opts out. |
| `optoutActive` | boolean |  |
| `optinKeywords` | string[] |  |
| `optinResponse` | string | Reply sent when a customer opts back in. |
| `optinActive` | boolean |  |

```bash
curl "https://api.pingx.ai/whatsapp/v1/opt-out-config" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PUT /whatsapp/v1/opt-out-config

**SetOptOutConfig** · needs `whatsapp:write`

Replaces the whole opt-out/opt-in configuration of a number
(read-modify-write: send every field). Idempotent.

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |
| `matchType` | string | "exact" or "contains"; empty = "exact". |
| `optoutKeywords` | string[] |  |
| `optoutResponse` | string |  |
| `optoutActive` | boolean |  |
| `optinKeywords` | string[] |  |
| `optinResponse` | string |  |
| `optinActive` | boolean |  |

**Response** `SetOptOutConfigResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/opt-out-config" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d @body.json
```

## GET /whatsapp/v1/templates

**ListTemplates** · needs `whatsapp:read` (or write)

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `ListTemplatesResponse`

| Field | Type | Description |
|---|---|---|
| `templates` | pingxWhatsappV1Template[] |  |
| `templates[].name` | string |  |
| `templates[].language` | string |  |
| `templates[].category` | string |  |
| `templates[].status` | string |  |
| `templates[].body` | string |  |
| `templates[].header` | string |  |
| `templates[].footer` | string |  |
| `templates[].msgType` | string |  |
| `templates[].buttons` | TemplateButton[] |  |
| `templates[].archived` | boolean |  |
| `templates[].mediaType` | string |  |
| `templates[].rejectedReason` | string | Set only when status is REJECTED — Meta's reason for rejecting it. |
| `templates[].qualityScore` | string |  |
| `templates[].id` | string | Meta's template ID, assigned when the template is created. Empty for templates Meta has not issued an ID for. It identifies one language variant within one WABA and changes if the template is deleted and recreated, so treat it as an opaque display/lookup value, not a stable primary key; templates are still addressed by name (see DeleteTemplate). |
| `templates[].createdAt` | string | RFC 3339 time the template was submitted from the dashboard. Empty for templates created outside the dashboard, since Meta does not return one. |
| `templates[].carouselCardCount` | string (int64) |  |
| `templates[].carouselCardTexts` | string[] | Each card's body text, in card order; empty for a card with no text. |

```bash
curl "https://api.pingx.ai/whatsapp/v1/templates" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## POST /whatsapp/v1/templates

**CreateTemplate** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |
| `language` | string |  |
| `category` | string |  |
| `msgType` | string |  |
| `header` | string |  |
| `headerSample` | string |  |
| `body` | string |  |
| `footer` | string |  |
| `mediaType` | string |  |
| `buttons` | TemplateButton[] |  |
| `buttons[].type` | string |  |
| `buttons[].text` | string |  |
| `buttons[].url` | string |  |
| `buttons[].sample` | string |  |
| `buttons[].phoneNumber` | string |  |
| `headerSampleFileData` | string (base64) |  |
| `headerSampleFileName` | string |  |
| `phoneNumberId` | string |  |
| `addSecurityRecommendation` | boolean | AUTHENTICATION category only — the only two pieces of an AUTHENTICATION template Meta lets the caller configure; everything else about that category (header/body/footer text, OTP button) is fixed by Meta. |
| `codeExpirationMinutes` | integer | Minutes before the OTP expires, shown in the message footer. 0 = unset (Meta omits the expiration line). Meta accepts 1-90. |
| `bodyExample` | string[] | One sample value per {{n}} placeholder detected in body, in order. |
| `cards` | pingxWhatsappV1CarouselCard[] |  |
| `cards[].headerFormat` | string |  |
| `cards[].headerSampleFileData` | string (base64) |  |
| `cards[].headerSampleFileName` | string |  |
| `cards[].text` | string |  |

**Response** `CreateTemplateResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `template` | pingxWhatsappV1Template |  |
| `template.name` | string |  |
| `template.language` | string |  |
| `template.category` | string |  |
| `template.status` | string |  |
| `template.body` | string |  |
| `template.header` | string |  |
| `template.footer` | string |  |
| `template.msgType` | string |  |
| `template.buttons` | TemplateButton[] |  |
| `template.archived` | boolean |  |
| `template.mediaType` | string |  |
| `template.rejectedReason` | string | Set only when status is REJECTED — Meta's reason for rejecting it. |
| `template.qualityScore` | string |  |
| `template.id` | string | Meta's template ID, assigned when the template is created. Empty for templates Meta has not issued an ID for. It identifies one language variant within one WABA and changes if the template is deleted and recreated, so treat it as an opaque display/lookup value, not a stable primary key; templates are still addressed by name (see DeleteTemplate). |
| `template.createdAt` | string | RFC 3339 time the template was submitted from the dashboard. Empty for templates created outside the dashboard, since Meta does not return one. |
| `template.carouselCardCount` | string (int64) |  |
| `template.carouselCardTexts` | string[] | Each card's body text, in card order; empty for a card with no text. |

```bash
curl -X POST "https://api.pingx.ai/whatsapp/v1/templates" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d @body.json
```

## DELETE /whatsapp/v1/templates/{templateName}

**DeleteTemplate** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `templateName` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `language` | string |  |
| `phoneNumberId` | string |  |

**Response** `DeleteTemplateResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X DELETE "https://api.pingx.ai/whatsapp/v1/templates/TEMPLATENAME" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## GET /whatsapp/v1/templates/{templateName}

**GetTemplate** · needs `whatsapp:read` (or write)

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `templateName` | string |  |

**Query parameters**

| Name | Type | Description |
|---|---|---|
| `phoneNumberId` | string |  |

**Response** `GetTemplateResponse`

| Field | Type | Description |
|---|---|---|
| `template` | pingxWhatsappV1Template |  |
| `template.name` | string |  |
| `template.language` | string |  |
| `template.category` | string |  |
| `template.status` | string |  |
| `template.body` | string |  |
| `template.header` | string |  |
| `template.footer` | string |  |
| `template.msgType` | string |  |
| `template.buttons` | TemplateButton[] |  |
| `template.archived` | boolean |  |
| `template.mediaType` | string |  |
| `template.rejectedReason` | string | Set only when status is REJECTED — Meta's reason for rejecting it. |
| `template.qualityScore` | string |  |
| `template.id` | string | Meta's template ID, assigned when the template is created. Empty for templates Meta has not issued an ID for. It identifies one language variant within one WABA and changes if the template is deleted and recreated, so treat it as an opaque display/lookup value, not a stable primary key; templates are still addressed by name (see DeleteTemplate). |
| `template.createdAt` | string | RFC 3339 time the template was submitted from the dashboard. Empty for templates created outside the dashboard, since Meta does not return one. |
| `template.carouselCardCount` | string (int64) |  |
| `template.carouselCardTexts` | string[] | Each card's body text, in card order; empty for a card with no text. |

```bash
curl "https://api.pingx.ai/whatsapp/v1/templates/TEMPLATENAME" \
  -H "Authorization: Bearer $PINGX_API_KEY"
```

## PATCH /whatsapp/v1/templates/{templateName}:archive

**ArchiveTemplate** · needs `whatsapp:write`

**Path parameters**

| Name | Type | Description |
|---|---|---|
| `templateName` | string |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `language` | string |  |
| `archived` | boolean |  |
| `phoneNumberId` | string | Which WABA's template to archive. Empty uses the org's default number. |

**Response** `ArchiveTemplateResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |

```bash
curl -X PATCH "https://api.pingx.ai/whatsapp/v1/templates/TEMPLATENAME:archive" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"language":"…","archived":false,"phoneNumberId":"…"}'
```

## PUT /whatsapp/v1/webhook

**SetWebhookConfig** · needs `whatsapp:write`

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `url` | string |  |

**Response** `SetWebhookConfigResponse`

| Field | Type | Description |
|---|---|---|
| `success` | boolean |  |
| `message` | string |  |
| `signingSecret` | string |  |

```bash
curl -X PUT "https://api.pingx.ai/whatsapp/v1/webhook" \
  -H "Authorization: Bearer $PINGX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"…"}'
```


