# pingx.ai API: full documentation
Base URL: https://api.pingx.ai
# pingx.ai API
> Run the pingx.ai platform from your own systems with an API key: WhatsApp, voice calls, AI agents, analytics, memory and billing.
The pingx.ai API lets you run the whole platform from your own systems: send WhatsApp
messages and campaigns, place and review voice calls, configure AI agents and their
knowledge, and read analytics, memory and billing. Everything you can do in the app, you
can do with an API key.
**Base URL:** `https://api.pingx.ai`
## Quickstart
1. In the app, open **Settings > API Keys**, choose the access each area needs
(for example *Voice: Read & write*), and generate a key. It is shown once; copy it.
2. Call any endpoint with the key as a bearer token:
```bash
export PINGX_API_KEY=pk_live_xxxxxxxxxxxxxxxx
# List your WhatsApp numbers
curl https://api.pingx.ai/whatsapp/v1/numbers \
-H "Authorization: Bearer $PINGX_API_KEY"
# Place an AI call
curl -X POST https://api.pingx.ai/voice/v1/calls \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "agentId": "123", "phone": "+919876543210" }'
```
The organization comes from the key. You never send it, and ids from another organization
behave exactly like ids that do not exist.
## What you can do
| Area | Base path | What it covers |
|---|---|---|
| [WhatsApp](https://docs.pingx.ai/whatsapp.md) | `/whatsapp/v1` | Numbers, messages, templates, media, contacts and labels, groups, campaigns, reports, Team Inbox chats, opt-out, auto-responses, flows, commerce |
| [Voice](https://docs.pingx.ai/voice.md) | `/voice/v1` | Place AI and human-bridged calls, call history, transcripts, recordings, numbers, human operators |
| [Agents](https://docs.pingx.ai/agents.md) | `/agents/v1` | AI agents, knowledge bases and sources, web-chat links, custom fields, text chat |
| [Analytics](https://docs.pingx.ai/analytics.md) | `/analytics/v1` | NPS trend, branch leaderboard, custom metrics, call volume |
| [Contact memory](https://docs.pingx.ai/memory.md) | `/memory/v1` | What agents remember about contacts: inspect, correct, erase |
| [Billing](https://docs.pingx.ai/billing.md) | `/billing/v1` | Balance, credit changes, usage (read-only) |
Start with [Authentication and conventions](https://docs.pingx.ai/authentication.md) for scopes, errors, pagination
and formats. The [API reference](https://docs.pingx.ai/reference/whatsapp.md) lists every endpoint with its
parameters.
## For AI agents and tools
This documentation is also published in forms made for LLMs and code generators:
- [`/llms.txt`](/llms.txt): an index of every page, with one-line descriptions.
- [`/llms-full.txt`](/llms-full.txt): the whole documentation in one markdown file.
- Any page as markdown: add `.md` to its URL (for example `/voice.md`), or request it
with `Accept: text/markdown`.
- [`/openapi.json`](/openapi.json): the OpenAPI 2.0 (Swagger) specification for every endpoint.
---
# Authentication and conventions
> API keys, read/write scopes, request and response formats, pagination, errors and retries.
## API keys
Send your key on every request as a bearer token:
```
Authorization: Bearer pk_live_xxxxxxxxxxxxxxxx
```
Create and revoke keys under **Settings > API Keys** in the app. A key is shown once, when
you create it; only its first characters (the prefix) are shown afterwards. Treat it like a
password: use it from your servers, never from a browser or mobile app, and revoke it if it
leaks. Only organization admins can create keys.
Keys cannot create other keys.
## Scopes
Each key is limited to the areas, and the access level within each area, chosen when it was
created. A scope is `:read` or `:write`. Write includes read.
| Area | Scope prefix |
|---|---|
| WhatsApp | `whatsapp` |
| Voice calls | `voice` |
| Agents and knowledge | `agents` |
| Analytics | `analytics` |
| Contact memory | `memory` |
| Billing | `billing` |
A bare scope with no suffix (for example `whatsapp`) grants both read and write for that
area. Keys created before read and write existed carry the bare scope and keep working.
Which level a call needs depends on its name:
- Calls whose name starts with `Get`, `List`, `Search`, `Count`, `Export` or `Download`
only read, and need `:read` (or `:write`).
- Every other call needs `:write`. This includes calls that read but spend credits or AI
quota, such as sending a message or chatting with an agent.
A call outside the key's scopes is rejected with `403`. Each endpoint in the
[reference](https://docs.pingx.ai/reference/whatsapp.md) shows the level it needs.
## Requests and responses
- **REST + JSON.** Paths look like `/voice/v1/calls/{callId}`. Bodies are JSON; send
`Content-Type: application/json`.
- **Field names are camelCase** in JSON (`pageSize`, `agentId`).
- **64-bit integers are strings** in JSON responses (`"millicredits": "125000"`), so they
never lose precision.
- **Times** are RFC 3339 in UTC (`2026-11-19T09:30:00Z`).
- **Phone numbers** are E.164 (`+919876543210`). Separators such as spaces, dashes and
parentheses are accepted and stripped.
- **Unset fields** are omitted or empty; send only what you want to set.
- **Also callable as Connect/gRPC.** Every service is available at
`https://api.pingx.ai/pingx..v1./` over Connect, gRPC and gRPC-Web,
with the same key.
- Request bodies are limited to 32 MiB.
## Pagination
List calls take `pageSize` (usually default 50, maximum 200) and `pageToken`, and return
`nextPageToken`. Pass the returned token unchanged to get the next page; an empty
`nextPageToken` means you have the last page.
```bash
curl "https://api.pingx.ai/voice/v1/calls?pageSize=100" \
-H "Authorization: Bearer $PINGX_API_KEY"
curl "https://api.pingx.ai/voice/v1/calls?pageSize=100&pageToken=TOKEN_FROM_PREVIOUS" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
Tokens are opaque and tied to the query that produced them. A few lists return everything in
one response; their reference entry has no `pageToken`.
## Errors
Errors return a non-2xx HTTP status and a JSON body:
```json
{ "code": 5, "message": "agent not found", "details": [] }
```
| HTTP | Meaning | Typical cause |
|---|---|---|
| 400 | Invalid argument, or the resource is in the wrong state | Missing or malformed field; an action that is not allowed right now |
| 401 | Unauthenticated | Missing, malformed, revoked or unknown key |
| 403 | Permission denied | The key does not carry the scope the call needs |
| 404 | Not found | Unknown id, or an id that belongs to another organization |
| 409 | Conflict or aborted | A concurrent edit; reload and retry |
| 503 | Unavailable | A backend is briefly unavailable; safe to retry |
| 500 | Internal error | Retry; contact support if it persists |
Calls that move money or messages (sending, campaigns, placing calls) are charged to your
organization's balance exactly as they are in the app. A refused charge (for example
insufficient credits) is reported on the call or message itself; see the area's guide.
## Retrying safely
Reads are always safe to retry. For writes, prefer the idempotent forms the guides point
out (adding a label that is already there, or removing one that is not, does nothing).
Creating a resource twice creates two resources.
---
# WhatsApp API: campaigns, inbox, flows, commerce
> Campaigns, message reports, Team Inbox chats, opt-out, auto-responses, flows and commerce over the WhatsApp API.
Everything an operator does day to day in the dashboard is available over the
same API-key authenticated service, `pingx.whatsapp.v1.WhatsAppService`
(REST prefix `/whatsapp/v1/`, also callable as Connect/gRPC). This page covers
the calls added on top of numbers, messages, templates, media, webhook and
contacts. For contact labels see [contact-labels-api.md](https://docs.pingx.ai/contact-labels.md).
Base URL `https://api.pingx.ai`. Authenticate with an API key carrying the
`whatsapp` scope (or `whatsapp:read` / `whatsapp:write`):
```
Authorization: Bearer $PINGX_API_KEY
```
The organization always comes from the key; you never send it. A campaign,
chat, flow or batch id that belongs to another organization is reported as
`NOT_FOUND`.
## Conventions
* **Read vs write.** Calls whose RPC name starts with `Get`/`List` are reads
(HTTP GET, need `whatsapp:read`); everything else is a write (need
`whatsapp:write`). The bare `whatsapp` scope grants both.
* **Numbers.** `phone_number_id` selects which connected number to act on
(see `GET /whatsapp/v1/numbers`). Optional while you have one number,
required once you have several. In REST it is a query parameter for
GET/DELETE and a body field otherwise. Phone numbers are E.164 digits; a
leading `+` is accepted (URL-encode it as `%2B` inside a path).
* **Times** are RFC 3339 UTC (`2026-03-01T09:30:00Z`).
* **JSON names** are lowerCamelCase in REST (`pageSize`, `phoneNumberId`).
* **Pagination.** `page_size` + `page_token` in, `next_page_token` out. Pass
the token back unchanged; empty means last page. Tokens are opaque.
* **Request size** is capped at 32 MiB.
* **Errors** use standard codes: `INVALID_ARGUMENT` (bad input),
`NOT_FOUND`, `FAILED_PRECONDITION` (wrong state, e.g. template not
approved), `RESOURCE_EXHAUSTED`, `UNAUTHENTICATED`, `PERMISSION_DENIED`.
Some sends report a business refusal as `success:false` with a `message`
instead (e.g. outside the 24-hour window, insufficient credits).
* **Billing.** Template sends from campaigns and free-text replies from
`SendChatMessage` go through the same metering as `SendMessage` and the
dashboard, so credits are charged and enforced identically.
* **Idempotency.** Create/send calls are not idempotent; retry only after
checking (for example `ListCampaigns`). Set/Update/Delete/Block/Unblock/
Cancel/MarkRead calls are idempotent.
## Endpoints
| RPC | Method and path | Scope |
|---|---|---|
| CreateCampaign | `POST /campaigns` | write |
| AddCampaignRecipients | `POST /campaigns/{campaign_id}/recipients:add` | write |
| StartCampaign | `POST /campaigns/{campaign_id}:start` | write |
| GetCampaign | `GET /campaigns/{campaign_id}` | read |
| ListCampaigns | `GET /campaigns` | read |
| CancelCampaign | `POST /campaigns/{campaign_id}:cancel` | write |
| ListMessageReports | `GET /message-reports` | read |
| ListInboundMessages | `GET /inbound-messages` | read |
| GetMessageStats | `GET /message-stats` | read |
| ListChats | `GET /chats` | read |
| ListChatMessages | `GET /chats/{contact}/messages` | read |
| SendChatMessage | `POST /chats/{contact}/messages` | write |
| MarkChatRead | `POST /chats/{contact}:markRead` | write |
| AssignChat | `POST /chats/{contact}:assign` | write |
| GetOptOutConfig / SetOptOutConfig | `GET` / `PUT /opt-out-config` | read / write |
| ListBlockedNumbers | `GET /blocked-numbers` | read |
| BlockNumber | `POST /blocked-numbers` | write |
| UnblockNumber | `DELETE /blocked-numbers/{mobile_number}` | write |
| ListAutoResponses / CreateAutoResponse | `GET` / `POST /auto-responses` | read / write |
| UpdateAutoResponse / DeleteAutoResponse | `PUT` / `DELETE /auto-responses/{auto_response_id}` | write |
| ListFlows / CreateFlow | `GET` / `POST /flows` | read / write |
| GetFlow | `GET /flows/{flow_id}` | read |
| UpdateFlow / DeleteFlow | `PUT` / `DELETE /flows/{flow_id}` | write |
| DuplicateFlow | `POST /flows/{flow_id}:duplicate` | write |
| SetFlowActive | `POST /flows/{flow_id}:setActive` | write |
| GetCommerceSettings / SetCommerceSettings | `GET` / `PUT /commerce/settings` | read / write |
| ConnectCatalog | `POST /commerce/catalogs:connect` | write |
| CreateCatalog | `POST /commerce/catalogs` | write |
| ListProductBatches / CreateProductBatch | `GET` / `POST /commerce/product-batches` | read / write |
| GetProductBatch | `GET /commerce/product-batches/{product_batch_id}` | read |
| SetProductBatchLive | `POST /commerce/product-batches/{product_batch_id}:setLive` | write |
| DeleteProductBatch | `DELETE /commerce/product-batches/{product_batch_id}` | write |
All paths are under `/whatsapp/v1`.
## Campaigns
A campaign sends one approved template to many recipients, rate limited by a
background worker. Flow: create (draft), add recipients in chunks of up to
5000, start, then poll.
```bash
B=https://api.pingx.ai/whatsapp/v1
H="Authorization: Bearer $PINGX_API_KEY"
# 1. draft
curl -s -X POST $B/campaigns -H "$H" -H 'Content-Type: application/json' -d '{
"name": "March promo", "templateName": "promo_march", "language": "en_US",
"category": "MARKETING", "ratePerSec": 20 }'
# -> {"campaignId":"c_123","ratePerSec":20}
# 2. recipients (repeat for more chunks; duplicates and opted-out are skipped)
curl -s -X POST $B/campaigns/c_123/recipients:add -H "$H" -H 'Content-Type: application/json' -d '{
"recipients": [ {"mobile":"+15551234567","bodyParams":["Ana","20%"]} ] }'
# -> {"accepted":1,"duplicates":0,"skippedOptedOut":0,"total":1}
# 3. start, then poll
curl -s -X POST $B/campaigns/c_123:start -H "$H" -H 'Content-Type: application/json' -d '{}'
curl -s $B/campaigns/c_123 -H "$H" # status, counters, delivered/read, first 100 failures
curl -s -X POST $B/campaigns/c_123:cancel -H "$H" -H 'Content-Type: application/json' -d '{}'
```
Statuses: `draft`, `queued`, `running`, `completed`, `cancelled`, `failed`.
Set `scheduledAt` (RFC 3339) on create to hold the campaign until then.
`sent` means Meta accepted the message; `delivered`/`read`/`deliveryFailed`
(from `GetCampaign`) are the later webhook results. `ListCampaigns` returns the
200 most recent campaigns, newest first.
## Reports, stats and exports
`GET /message-reports` is the per-message delivery log. **It replaces the
dashboard's CSV export** (`/whatsapp/report/export.csv`), which only works
with a browser session: loop on `nextPageToken` to export a time range.
```bash
curl -s "$B/message-reports?from=2026-03-01T00:00:00Z&to=2026-04-01T00:00:00Z&status=failed&pageSize=200" -H "$H"
curl -s "$B/message-reports?pageToken=$TOKEN&pageSize=200" -H "$H" # next page; repeat the same filters
curl -s "$B/inbound-messages?from=2026-03-01T00:00:00Z&pageSize=50" -H "$H"
curl -s "$B/message-stats?from=2026-03-01T00:00:00Z&to=2026-03-08T00:00:00Z" -H "$H"
```
`GetMessageStats` needs both `from` and `to`; it returns the funnel
(initiated, sent, delivered, read, failed, replies) and a 7-day daily series.
## Team Inbox chats
```bash
curl -s "$B/chats?assigneeFilter=unassigned&pageSize=50" -H "$H"
curl -s "$B/chats/%2B15551234567/messages?pageSize=50" -H "$H" # newest page first
curl -s -X POST "$B/chats/%2B15551234567/messages" -H "$H" -H 'Content-Type: application/json' -d '{"body":"Thanks, on it!"}'
curl -s -X POST "$B/chats/%2B15551234567:markRead" -H "$H" -H 'Content-Type: application/json' -d '{}'
curl -s -X POST "$B/chats/%2B15551234567:assign" -H "$H" -H 'Content-Type: application/json' -d '{"assigneeId":"user_abc"}'
```
* Free-text replies work only inside the 24-hour window after the customer's
last message (`outsideServiceWindow` on the messages call tells you).
Outside it, `SendChatMessage` returns `success:false`; send an approved
template with `POST /messages` instead.
* API keys have no user: `assigneeFilter:"mine"` and `assigneeId:"me"` are
rejected. `assigneeId` must be a member of the organization and, on the
public API, is accepted only where the gateway has the member directory
configured; empty `assigneeId` always unassigns.
* Inbox agents (the restricted dashboard role) cannot use these public
routes; they use the dashboard's own inbox calls.
## Opt-out, blocked numbers, auto-responses
```bash
curl -s -X PUT $B/opt-out-config -H "$H" -H 'Content-Type: application/json' -d '{
"matchType":"exact","optoutKeywords":["STOP"],"optoutResponse":"You are unsubscribed.","optoutActive":true,
"optinKeywords":["START"],"optinResponse":"Welcome back!","optinActive":true }'
curl -s -X POST $B/blocked-numbers -H "$H" -H 'Content-Type: application/json' -d '{"mobileNumber":"+15551234567"}'
curl -s -X DELETE "$B/blocked-numbers/%2B15551234567" -H "$H"
curl -s -X POST $B/auto-responses -H "$H" -H 'Content-Type: application/json' -d '{
"title":"Opening hours","matchType":"contains","keywords":["hours"],"responseText":"We open 9-5.","active":true }'
```
`PUT` calls replace the whole configuration: send every field.
## Flows
Flows are multi-step automations started by a keyword. Typical sequence:
`POST /flows` (empty, inactive) then `PUT /flows/{id}` with the graph, then
`POST /flows/{id}:setActive {"active":true}`. `PUT` validates the whole graph
and returns `INVALID_ARGUMENT` listing the problems; activation validates
again.
The `graph` is the Flow Builder canvas JSON, stored verbatim:
```json
{
"nodes": [
{"id":"n1","type":"start","position":{"x":0,"y":0},"data":{"matchType":"exact","keywords":["hi"]}},
{"id":"n2","type":"buttons","position":{"x":0,"y":120},"data":{"text":"Pick one","buttons":[{"id":"a","label":"Sales"},{"id":"b","label":"Support"}]}},
{"id":"n3","type":"sendMessage","position":{"x":0,"y":240},"data":{"text":"Sales will call you."}}
],
"edges": [
{"id":"e1","source":"n1","target":"n2","sourceHandle":null,"targetHandle":null},
{"id":"e2","source":"n2","target":"n3","sourceHandle":"a","targetHandle":null}
]
}
```
One `start` node (with keywords) is required. `sourceHandle` picks the
branch: `true`/`false` for `condition`, the button or row `id` for `buttons`
and `list`. Node types and `data` fields are listed in the proto comment on
the `Flow` message (start, sendMessage, question, input, buttons, list,
dynamicList, media, multiMedia, askMedia, askLocation, askAddress, template,
condition, setAttribute, addTag, delay, apiRequest, connectFlow,
catalogMessage, product, multiProducts, orderDetails). The safest way to
author a graph is to `GET` one built in the dashboard and copy its shapes.
## Commerce
```bash
curl -s $B/commerce/settings -H "$H" # connected catalog + connectable catalogs
curl -s -X POST $B/commerce/catalogs:connect -H "$H" -H 'Content-Type: application/json' -d '{"catalogId":"123","catalogName":"Shop"}'
curl -s -X POST $B/commerce/product-batches -H "$H" -H 'Content-Type: application/json' -d '{
"name":"Spring","items":[{"retailerId":"sku-1","name":"Shirt","price":"19.99","currency":"USD","imageUrl":"https://example.com/a.jpg"}] }'
curl -s -X POST $B/commerce/product-batches/b1:setLive -H "$H" -H 'Content-Type: application/json' -d '{"live":true}'
```
Meta credentials are never returned by any call.
## Deliberately not in the API
* Setup of the account through the browser (embedded signup): use
`POST /numbers:connect`.
* `SendTestMessage`, `SendMetaTestMessage`: development helpers; use
`POST /messages` (real send) instead. Meta quality rating and messaging
tier are already on `GET /numbers`.
---
# Contact labels API
> Label customers from your own systems and read the labels back.
Label your customers from your own systems, and read the labels back. A
**label** (also called a tag) is a short piece of text on a contact, such as
`VIP` or `primary customer`. The same labels are shown and edited in the
**Customer details** panel next to every chat in the Team Inbox.
Labels are separate from the contact attributes that flows use
(`$contact.`): labelling a customer never changes flow data.
## Authentication
Use an API key with the **whatsapp** scope, sent as a bearer token. Create one
on the API Keys page of the app. The organization is taken from the key; you
never send it.
```
Authorization: Bearer pk_live_xxxxxxxxxxxxxxxx
```
Base URL: `https://api.pingx.ai`
## Add or remove labels
`POST /whatsapp/v1/contacts:setTags`
| Field | Type | Notes |
|---|---|---|
| `phone` | string, required | Any format; contacts are matched on the **digits** (8-15), so `+91 98111 11111` and `919811111111` are the same contact. |
| `add` | array of strings | Labels to add. |
| `remove` | array of strings | Labels to remove. A label cannot be in both `add` and `remove`. |
| `name` | string, optional | The contact's name. Only applied when non-empty. |
At least one of `add`, `remove` or `name` is required.
```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": "919811111111",
"name": "Asha Rao",
"add": ["VIP", "primary customer"],
"remove": ["trial"]
}'
```
Response (`created` is true when the number was new and the contact was made;
`tags` is the contact's full list after the change):
```json
{
"success": true,
"message": "contact updated",
"created": false,
"tags": ["primary customer", "VIP"],
"contact": { "id": "9f1c0c52-...", "name": "Asha Rao", "phone": "919811111111" }
}
```
How it behaves:
* **Safe to repeat.** Adding a label the contact already has, or removing one
it does not have, does nothing. Concurrent calls (several of your systems,
plus agents labelling in the inbox) never undo each other.
* **Case does not matter.** `vip` and `VIP` are the same label; the spelling
used first is kept. Extra spaces are collapsed (`"big spender"` becomes
`"big spender"`).
* **Limits.** A label is up to 40 characters; a contact has at most 50 labels.
A change that would exceed that is rejected and nothing is written.
* **It creates the contact** when the number is new.
## Read a contact's labels
`GET /whatsapp/v1/contacts:byPhone?phone=919811111111`
```bash
curl "https://api.pingx.ai/whatsapp/v1/contacts:byPhone?phone=919811111111" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
```json
{
"found": true,
"contact": { "id": "9f1c0c52-...", "name": "Asha Rao", "phone": "919811111111" },
"tags": ["primary customer", "VIP"],
"knownTags": ["Gold", "primary customer", "Trial", "VIP"]
}
```
`knownTags` is every label your organization uses, for pickers. `found` is
`false` (and `contact` absent) for an unknown number; that is a normal answer,
not an error.
## Errors
| HTTP | When |
|---|---|
| 400 | `phone` missing or not 8-15 digits; a blank, over-long or control-character label; a label in both `add` and `remove`; nothing to change; more than 50 labels on the contact. The `message` says which. |
| 401 | Missing, wrong or revoked API key, or a key without the `whatsapp` scope. |
Inbox agents can read and label the contact of the chat they have open (the
customer panel); they cannot use the rest of the contacts API.
---
# Voice API
> Place AI or human-bridged calls, follow and end them, read call history, transcripts and recordings, manage voice numbers and human operators.
Place AI or human-bridged phone calls, follow and end them, read call history
with transcripts and recordings, and manage your voice numbers and the people
your AI agents can escalate to. Everything an operator does with voice in the
app is available here.
## Authentication
Use an API key with the **voice** scope (or `voice:read` for read-only access,
`voice:write` for read and write), sent as a bearer token. Create one on the API
Keys page of the app. The organization is taken from the key; you never send it,
and ids that belong to another organization behave exactly like ids that do not
exist (`404`).
```
Authorization: Bearer pk_live_xxxxxxxxxxxxxxxx
```
Base URL: `https://api.pingx.ai`. The same service is also available over
Connect/gRPC at `pingx.voice.v1.VoiceService`.
Scope rule: `Get*`, `List*` and `Download*` calls need `voice:read`; every other
call needs `voice:write`.
Conventions: phone numbers are E.164 (`+919876543210`; spaces, dashes, dots and
parentheses are stripped); times are RFC3339 UTC; JSON field names are camelCase
over REST; every list takes `pageSize` (default 50, max 200) and `pageToken` and
returns `nextPageToken` (empty on the last page).
## Endpoints
| Method | Path | Scope | What it does |
|---|---|---|---|
| POST | `/voice/v1/calls` | write | `PlaceCall`: AI agent calls a customer |
| POST | `/voice/v1/human-calls` | write | `PlaceHumanCall`: bridge a human and a customer |
| GET | `/voice/v1/dials/{dialId}/status` | read | `GetCallStatus` |
| POST | `/voice/v1/dials/{dialId}:end` | write | `EndCall` |
| GET | `/voice/v1/calls` | read | `ListCalls` |
| GET | `/voice/v1/calls/{callId}` | read | `GetCall` |
| GET | `/voice/v1/calls/{callId}/transcript` | read | `GetCallTranscript` |
| GET | `/voice/v1/calls/{callId}/recording` | read | `DownloadCallRecording` (raw audio) |
| GET | `/voice/v1/numbers` | read | `ListNumbers` |
| POST | `/voice/v1/numbers` | write | `AddNumber` |
| DELETE | `/voice/v1/numbers/{numberId}` | write | `RemoveNumber` |
| POST | `/voice/v1/numbers/{numberId}:setDefault` | write | `SetDefaultNumber` |
| POST | `/voice/v1/numbers/{numberId}:setInboundAgent` | write | `SetInboundAgent` |
| GET | `/voice/v1/humans` | read | `ListHumans` |
| POST | `/voice/v1/humans` | write | `AddHuman` |
| PATCH | `/voice/v1/humans/{humanId}` | write | `UpdateHuman` (full replace of the fields) |
| DELETE | `/voice/v1/humans/{humanId}` | write | `RemoveHuman` |
| GET | `/voice/v1/human-assignments` | read | `ListHumanAssignments` |
| PUT | `/voice/v1/human-assignments/{agentId}/{humanId}` | write | `SetHumanAssignment` |
## Place a call
Calls are asynchronous. `PlaceCall` validates the request, queues the call and
returns a `dialId` immediately; the customer's phone rings a moment later.
Credit checks, number selection and registration checks happen at dial time, as
for calls placed from the app. A call refused (for example for insufficient credits) shows up
as `status: "failed"` with the reason in `outcome`.
```bash
curl -X POST https://api.pingx.ai/voice/v1/calls \
-H "Authorization: Bearer $PINGX_API_KEY" -H "Content-Type: application/json" \
-d '{"agentId": 12, "phone": "+919876543210", "name": "Asha K"}'
# {"dialId":"4821","status":"dialing"}
```
`PlaceCall` is **not idempotent**: each successful request places a new call.
After a timeout, check `GET /voice/v1/calls?leadId=` before retrying.
`agentId` comes from the Agents API.
Poll the status every 2-5 seconds:
```bash
curl https://api.pingx.ai/voice/v1/dials/4821/status -H "Authorization: Bearer $PINGX_API_KEY"
# {"status":"in_progress","outcome":"","callId":"9021","hasTranscript":false,...}
```
`status` is `dialing`, `in_progress`, `completed` or `failed`. `callId` appears
once the call exists. Hang up an active call:
```bash
curl -X POST https://api.pingx.ai/voice/v1/dials/4821:end -H "Authorization: Bearer $PINGX_API_KEY"
# {"ended":true}
```
### Human-bridged call
Rings one of your humans first, then the customer, and joins them. No AI speaks;
the call is still recorded, transcribed and scored. The human must be active and
have a `phone`.
```bash
curl -X POST https://api.pingx.ai/voice/v1/human-calls \
-H "Authorization: Bearer $PINGX_API_KEY" -H "Content-Type: application/json" \
-d '{"humanId": 7, "phone": "+919876543210"}'
```
## Call history, transcripts, recordings
```bash
# newest first; filters: agentId, humanId, leadId, startedAfter, startedBefore (RFC3339)
curl "https://api.pingx.ai/voice/v1/calls?pageSize=20&startedAfter=2026-03-01T00:00:00Z" \
-H "Authorization: Bearer $PINGX_API_KEY"
curl https://api.pingx.ai/voice/v1/calls/9021/transcript -H "Authorization: Bearer $PINGX_API_KEY"
# {"turns":[{"role":"assistant","text":"Hello, ..."},{"role":"user","text":"Hi"}]}
```
Each call has a `direction` (`outbound`, `inbound` or `human`), outcome, AI
summary, sentiment (1-5, 0 = unscored), your scored metrics, and
`hasTranscript` / `hasRecording`. Browser test calls made in the app are not
listed.
### Recording download
`DownloadCallRecording` returns the audio file itself (Ogg/Opus,
`Content-Type: audio/ogg`), authenticated by the same API key. There are no
signed URLs to fetch or expire:
```bash
curl -H "Authorization: Bearer $PINGX_API_KEY" -o call-9021.ogg \
https://api.pingx.ai/voice/v1/calls/9021/recording
```
Whole-file only (no HTTP Range). `404` if the call has no recording
(`hasRecording` is false) or is not yours; `412` if the file is over 32 MiB.
## Numbers
```bash
curl -X POST https://api.pingx.ai/voice/v1/numbers -H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" -d '{"number":"+14155550123","label":"Sales"}'
# a non-empty "syncError" means the number is saved but not yet dialable; it is retried automatically
# which AI agent answers inbound calls to this number (agentId 0 clears it; an
# unbound number refuses inbound calls)
curl -X POST https://api.pingx.ai/voice/v1/numbers/31:setInboundAgent \
-H "Authorization: Bearer $PINGX_API_KEY" -H "Content-Type: application/json" -d '{"agentId": 12}'
```
Only voice numbers are managed here; WhatsApp numbers live in the WhatsApp API.
## Humans and escalation
```bash
curl -X POST https://api.pingx.ai/voice/v1/humans -H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Raj","phone":"+911111111111","whatsappMobile":"+911111111111","purpose":"technician"}'
# allow agent 12 to escalate to human 7 over WhatsApp ("channel": "" revokes)
curl -X PUT https://api.pingx.ai/voice/v1/human-assignments/12/7 \
-H "Authorization: Bearer $PINGX_API_KEY" -H "Content-Type: application/json" -d '{"channel":"whatsapp"}'
```
## Errors
`400` invalid input, `401` bad key, `403` key lacks the scope, `404` unknown id
or another organization's id, `409` already exists, `412` precondition (human
has no phone, recording too large), `500` internal.
## Not in this API
- **Leads and pipeline decisions.** Not available yet. A call creates its own lead record;
`dialId` is that record's id.
- Browser (WebRTC) test calls and streaming.
- Agents and knowledge bases (Agents API).
---
# Agents API
> Configure AI agents, knowledge bases and sources, web-chat links and custom fields, and chat with an agent over text.
Configure AI agents (personas), their knowledge bases, scored custom fields and
web-chat share links, and chat with an agent over text, all with an API key.
The same API is also reachable over
Connect/gRPC at `/pingx.agents.v1.AgentsService/`.
## Auth and scopes
Send `Authorization: Bearer pk_live_...` (create keys under Settings > API Keys in the app).
The organization always comes from the key; there is no organization field in
any request, and ids of another organization answer `404` exactly like unknown
ids.
| Key scope | Allows |
|---|---|
| `agents:read` | `Get*` / `List*` RPCs (all `GET` endpoints) |
| `agents:write` | everything, including reads |
| `agents` | same as `agents:write` |
Classification is by RPC name (`Get`, `List`, `Search`, `Count`, `Export`,
`Download` prefixes are reads). `GenerateSystemPrompt` and `SendChatMessage`
are writes on purpose: they spend AI quota / append conversation turns.
## Conventions
- JSON field names are camelCase over REST (`systemPrompt`); `int64` ids are JSON strings.
- Lists take `pageSize` (default 50, max 200) and `pageToken`, and return `nextPageToken` (empty = last page).
- Errors: `400` invalid argument / failed precondition, `401` bad key, `403` missing scope, `404` unknown id, `409` aborted (script changed concurrently), `503` assistant unavailable.
- `PATCH` endpoints are partial: only the fields you send change.
## Endpoints
| Method | Path | Scope | Purpose |
|---|---|---|---|
| GET | `/agents/v1/agents` | read | List agents |
| POST | `/agents/v1/agents` | write | Create agent (name, systemPrompt, knowledgeBaseIds) |
| GET | `/agents/v1/agents/{agentId}` | read | Get agent |
| PATCH | `/agents/v1/agents/{agentId}` | write | Update agent (prompt, playbooks, script, voice, toggles, knowledge bases) |
| DELETE | `/agents/v1/agents/{agentId}` | write | Delete agent |
| POST | `/agents/v1/system-prompts:generate` | write | Draft a system prompt from a brief (AI) |
| GET | `/agents/v1/knowledge-bases` | read | List knowledge bases |
| POST | `/agents/v1/knowledge-bases` | write | Create knowledge base |
| GET | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | read | Get knowledge base with sources |
| PATCH | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | write | Rename |
| DELETE | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | write | Delete with its sources |
| GET | `/agents/v1/knowledge-bases/{knowledgeBaseId}/sources` | read | List sources |
| POST | `/agents/v1/knowledge-bases/{knowledgeBaseId}/sources` | write | Add a text / url / file / site source (async ingestion) |
| GET | `/agents/v1/knowledge-sources/{sourceId}` | read | Get source: **the ingestion poll** |
| PATCH | `/agents/v1/knowledge-sources/{sourceId}` | write | Edit a text source (re-ingests) |
| DELETE | `/agents/v1/knowledge-sources/{sourceId}` | write | Delete source |
| POST | `/agents/v1/knowledge-sources/{sourceId}:recrawl` | write | Re-crawl a site source |
| POST | `/agents/v1/agents/{agentId}/web-chat:enable` | write | Enable share link (idempotent) |
| POST | `/agents/v1/agents/{agentId}/web-chat:disable` | write | Revoke share link |
| GET | `/agents/v1/agents/{agentId}/web-chat` | read | Share-link state and token |
| GET | `/agents/v1/custom-fields` | read | List custom fields (`scopeType`, `agentId`) |
| POST | `/agents/v1/custom-fields` | write | Create custom field |
| PATCH | `/agents/v1/custom-fields/{customFieldId}` | write | Update label/description/range/position |
| DELETE | `/agents/v1/custom-fields/{customFieldId}` | write | Delete custom field |
| POST | `/agents/v1/chat/conversations` | write | Start a text conversation |
| POST | `/agents/v1/chat/conversations/{conversationId}/messages` | write | Send a message, get the full reply |
## Examples
```bash
export H='Authorization: Bearer pk_live_xxx'
export API=https://
# Create a knowledge base, add a site, poll until ingestion finishes
curl -s -H "$H" -H 'Content-Type: application/json' -d '{"name":"Help center"}' $API/agents/v1/knowledge-bases
curl -s -H "$H" -H 'Content-Type: application/json' \
-d '{"title":"Docs","site":{"url":"https://example.com/docs","maxPages":50}}' \
$API/agents/v1/knowledge-bases/12/sources
curl -s -H "$H" $API/agents/v1/knowledge-sources/34 # repeat until "ingestionFinished": true
# status: pending | crawling | ready | partial | failed; pagesDiscovered/Ingested/Failed show crawl progress
# Upload a file source (data is base64, max 10 MB, .txt/.md/.pdf)
curl -s -H "$H" -H 'Content-Type: application/json' \
-d "{\"file\":{\"filename\":\"faq.pdf\",\"data\":\"$(base64 -w0 faq.pdf)\"}}" \
$API/agents/v1/knowledge-bases/12/sources
# Draft a prompt, create the agent with the knowledge base, tweak it
curl -s -H "$H" -H 'Content-Type: application/json' \
-d '{"brief":"Friendly support agent for a bike shop"}' $API/agents/v1/system-prompts:generate
curl -s -H "$H" -H 'Content-Type: application/json' \
-d '{"name":"Bike support","systemPrompt":"You are ...","knowledgeBaseIds":["12"]}' $API/agents/v1/agents
curl -s -X PATCH -H "$H" -H 'Content-Type: application/json' \
-d '{"voiceGender":"male","fillerWordsEnabled":true,"knowledgeBaseIds":{"ids":["12"]}}' $API/agents/v1/agents/7
# Web chat share link
curl -s -X POST -H "$H" $API/agents/v1/agents/7/web-chat:enable
curl -s -X POST -H "$H" $API/agents/v1/agents/7/web-chat:disable
# Custom field scored per conversation
curl -s -H "$H" -H 'Content-Type: application/json' \
-d '{"scopeType":"agent","agentId":"7","key":"nps","label":"NPS","description":"0-10 likelihood to recommend","minValue":0,"maxValue":10}' \
$API/agents/v1/custom-fields
# Text chat: start, then send turns (the reply is returned whole)
curl -s -H "$H" -H 'Content-Type: application/json' -d '{"agentId":"7"}' $API/agents/v1/chat/conversations
curl -s -H "$H" -H 'Content-Type: application/json' -d '{"text":"What are your hours?"}' \
$API/agents/v1/chat/conversations/99/messages
```
## Notes and exclusions
- **Updating `script`** runs an AI normalization pass first (up to a few minutes); the processed text is stored. `409` means another save changed the script meanwhile: re-read and retry.
- **`supportEscalationEnabled`** needs JIRA and Google Chat connected in the app; otherwise `400`. The integrations themselves (and their tokens) are not exposed.
- **Create** only takes name, system prompt and knowledge bases; set everything else with `PATCH`.
- **Chat** replies are assembled server-side. `segments` are the separate bubbles; `text` joins them. Conversations are recorded as app ("studio") chats.
- **Web chat token** is a bearer capability to chat publicly with the agent; treat it as sensitive. Re-enabling after disabling mints a new token.
- **Not in this API**: test calls and browser WebRTC calls (voice API), `TranscribeBrief` (needs browser-recorded audio upload; use `GenerateSystemPrompt` with a text brief), JIRA / Google Chat integrations.
- Agents here have no language or tools/flows setting: those do not exist on the platform's agent model today.
---
# Analytics API
> NPS trend, branch leaderboard, custom call metrics and call volume.
Aggregated dashboard metrics for the organization behind your API key. Read-only.
- Base path: `/analytics/v1/` (REST) or Connect/gRPC `pingx.analytics.v1.AnalyticsService`.
- Auth: `Authorization: Bearer `; scope `analytics:read` (or `analytics`).
- Returns the same figures as the Analytics page in the app.
| RPC | REST | Scope |
|---|---|---|
| GetNpsTrend | `GET /analytics/v1/nps-trend?days=` | read |
| GetBranchLeaderboard | `GET /analytics/v1/branch-leaderboard?days=` | read |
| GetCustomMetrics | `GET /analytics/v1/custom-metrics?days=&agentId=&humanOperatorsOnly=` | read |
| GetCallVolume | `GET /analytics/v1/call-volume?days=` | read |
Conventions: `days` is a lookback in calendar days ending today (default 30, max 180, clamped; the
effective value is echoed as `days`). Points carry RFC 3339 dates. NPS is -100..100; a day or window
with `responses = 0` reports `nps = 0` (check `responses`). int64 values are JSON strings.
Out of scope: call listing/transcripts (voice API) and WhatsApp message stats (WhatsApp API).
---
# Contact memory API
> Inspect and correct what AI agents remember about contacts: facts, todos and suppressions.
Inspect and correct what the AI agents (personas) remember about contacts: facts, todos,
do-not-learn suppressions and the episodes they came from. Memory is per (contact, persona).
- Base path: `/memory/v1/`; Connect/gRPC `pingx.memory.v1.MemoryService`.
- Auth: `Authorization: Bearer `; `memory:read` for List/Get, `memory:write` for everything else
(`memory` = both). The org comes from the key only; another org's contact is "not found".
- Writes are applied synchronously. If the memory backend is briefly unavailable you get
UNAVAILABLE (503); it is safe to retry.
| RPC | REST | Scope |
|---|---|---|
| ListContactActivity | `GET /memory/v1/contacts?search=&includeTest=&pageSize=&pageToken=` | read |
| GetContactMemory | `GET /memory/v1/contacts/{contactId}/memory?agentId=` | read |
| GetFactProvenance | `GET /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}/provenance` | read |
| ListRecentMessages | `GET /memory/v1/contacts/{contactId}/messages?pageSize=` | read |
| ListTestContacts | `GET /memory/v1/test-contacts` | read |
| CreateTestContact | `POST /memory/v1/test-contacts` | write |
| ForgetFact | `POST .../personas/{agentId}/facts/{factId}:forget` | write |
| AmendFact | `POST .../personas/{agentId}/facts/{factId}:amend` | write |
| RenewFact | `POST .../personas/{agentId}/facts/{factId}:renew` | write |
| CloseTodo | `POST .../personas/{agentId}/todos/{todoId}:close` | write |
| ReopenTodo | `POST .../personas/{agentId}/todos/{todoId}:reopen` | write |
| LiftSuppression | `POST .../personas/{agentId}/suppressions:lift` | write |
| ForgetAllForPersona | `POST .../personas/{agentId}/memory:forgetAll` | write, destructive |
| ClearForPersona | `POST .../personas/{agentId}/memory:clear` | write, destructive |
| EraseSubject | `POST /memory/v1/contacts/{contactId}:erase` | write, destructive |
(`...` = `/memory/v1/contacts/{contactId}`.)
## Irreversible operations
`ForgetAllForPersona` (soft-deletes every active fact of one persona; no bulk undo), `ClearForPersona`
(hard-deletes one persona's facts, todos, rules and episodes) and `EraseSubject` (right to be forgotten,
all personas, writes an erasure marker) cannot be undone through the API. Each requires
`"confirm": true` in the body, otherwise INVALID_ARGUMENT and nothing is sent to the backend.
## Notes
- Write ids (`agentId`, `factId`, `todoId`) must be > 0; `AmendFact.factValue`, `CloseTodo.evidence`
and `LiftSuppression.factKey` are required; `RenewFact.expiresAt` must be RFC 3339.
- Pagination: `ListContactActivity` returns `nextPageToken` (opaque); `ListRecentMessages` is the N
most recent (`pageSize`, default 50, max 200), not paginated.
- Results of writes: `affected` rows; 0 means nothing matched.
---
# Billing API
> Read your organization's balance, credit changes and usage.
The organization's own billing view, read-only: wallet balance and mode, credit changes, usage.
- Base path: `/billing/v1/`; Connect/gRPC `pingx.billing.v1.BillingService`.
- Auth: `Authorization: Bearer `; scope `billing:read` (or `billing`). The service has no write
RPCs, so `billing:write` grants nothing extra.
- Money: integer **millicredits** (1 credit = 1000). int64 values are JSON strings. Timestamps RFC 3339.
- Pagination: `pageSize` (default 25, max 100) / `pageToken` -> `nextPageToken` (opaque, newest first;
a full final page may be followed by one empty page).
| RPC | REST | Scope |
|---|---|---|
| GetBilling | `GET /billing/v1/account` | read |
| ListCreditChanges | `GET /billing/v1/credit-changes?pageSize=&pageToken=` | read |
| GetUsageSummary | `GET /billing/v1/usage/summary?days=` (default 30, max 366) | read |
| ListUsage | `GET /billing/v1/usage/events?operation=&pageSize=&pageToken=` | read |
## Deliberate exclusions
No payment, top-up or checkout initiation, no change of billing mode, negative-credit limit, rates or
credits, no enforcer/rate tables, no staff identities (credit changes show the note, not who made
them), no metering that charged nothing. The Billing page in the app offers no write action either,
so nothing the page can do is missing here.
## Authorization
Billing is for organization admins. Only admins can create API keys, so a key can read the same data an
admin can. The organization always comes from the key.
---
# 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 `. 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": "", "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 " 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 | " 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":"…"}'
```
---
# Voice reference
> Every Voice endpoint with parameters, request and response fields, required scope and a curl example.
Every Voice endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer `. Read endpoints need `voice:read` (or `:write`), write endpoints need `voice:write`; the bare `voice` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).
**19 endpoints**
| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/voice/v1/calls` | ListCalls | read |
| `POST` | `/voice/v1/calls` | PlaceCall | write |
| `GET` | `/voice/v1/calls/{callId}` | GetCall | read |
| `GET` | `/voice/v1/calls/{callId}/recording` | DownloadCallRecording | read |
| `GET` | `/voice/v1/calls/{callId}/transcript` | GetCallTranscript | read |
| `POST` | `/voice/v1/dials/{dialId}:end` | EndCall | write |
| `GET` | `/voice/v1/dials/{dialId}/status` | GetCallStatus | read |
| `GET` | `/voice/v1/human-assignments` | ListHumanAssignments | read |
| `PUT` | `/voice/v1/human-assignments/{agentId}/{humanId}` | SetHumanAssignment | write |
| `POST` | `/voice/v1/human-calls` | PlaceHumanCall | write |
| `GET` | `/voice/v1/humans` | ListHumans | read |
| `POST` | `/voice/v1/humans` | AddHuman | write |
| `DELETE` | `/voice/v1/humans/{humanId}` | RemoveHuman | write |
| `PATCH` | `/voice/v1/humans/{humanId}` | UpdateHuman | write |
| `GET` | `/voice/v1/numbers` | ListNumbers | read |
| `POST` | `/voice/v1/numbers` | AddNumber | write |
| `DELETE` | `/voice/v1/numbers/{numberId}` | RemoveNumber | write |
| `POST` | `/voice/v1/numbers/{numberId}:setDefault` | SetDefaultNumber | write |
| `POST` | `/voice/v1/numbers/{numberId}:setInboundAgent` | SetInboundAgent | write |
## GET /voice/v1/calls
**ListCalls** · needs `voice:read` (or write)
ListCalls lists the organization's past and in-progress calls (AI agent
calls, inbound calls and human-bridged calls), newest first, optionally
filtered. Browser test calls from the app are not included. Transcript
text and audio are not returned here; use GetCallTranscript and
DownloadCallRecording.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Max calls per page. Default 50, max 200. |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
| `agentId` | string (int64) | Only calls handled by this AI agent. Optional (must belong to the organization). |
| `humanId` | string (int64) | Only bridged calls handled by this human. Optional. |
| `leadId` | string (int64) | Only the call(s) from this dial attempt (the dialId from PlaceCall). |
| `startedAfter` | string | Only calls started at or after this time (RFC3339). Optional. |
| `startedBefore` | string | Only calls started before this time (RFC3339). Optional. |
**Response** `ListCallsResponse`
| Field | Type | Description |
|---|---|---|
| `calls` | Call[] | |
| `calls[].callId` | string (int64) | Call id; used by GetCall, GetCallTranscript and DownloadCallRecording. |
| `calls[].direction` | string | "outbound" (AI agent dialed the customer), "inbound" (customer dialed one of the organization's numbers) or "human" (bridged human call). |
| `calls[].leadId` | string (int64) | The dialId returned when this call was placed via the API; 0 for inbound calls. |
| `calls[].agentId` | string (int64) | AI agent that handled the call; 0 for human-bridged calls. |
| `calls[].humanId` | string (int64) | Human who handled the call; 0 for AI calls. |
| `calls[].humanName` | string | Human's name for human-bridged calls; empty otherwise. |
| `calls[].customerName` | string | Customer name if known; may be empty. |
| `calls[].customerPhone` | string | Customer phone number, E.164 where known. |
| `calls[].startedAt` | string | When the call started (RFC3339, UTC). |
| `calls[].endedAt` | string | When it ended (RFC3339, UTC); empty while ongoing. |
| `calls[].outcome` | string | Free-text outcome (e.g. "link_sent", "declined"). |
| `calls[].sentimentScore` | integer | Sentiment 1 (negative) to 5 (positive); 0 = unscored. |
| `calls[].sentimentWentRight` | string | What went right / wrong, from the post-call sentiment analysis. |
| `calls[].sentimentWentWrong` | string | |
| `calls[].transcriptSummary` | string | AI summary of the conversation; empty if none captured. |
| `calls[].metrics` | ScoredMetric[] | The organization's custom scored metrics for this call. |
| `calls[].hasTranscript` | boolean | True if GetCallTranscript will return content. |
| `calls[].hasRecording` | boolean | True if DownloadCallRecording will return audio. |
| `nextPageToken` | string | Pass as pageToken for the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/voice/v1/calls" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/calls
**PlaceCall** · needs `voice:write`
PlaceCall starts an outbound phone call from an AI agent to a customer.
It validates that the agent belongs to the organization, then queues the
call and returns immediately with a dialId; the telephony layer rings the
customer asynchronously (credit checks, caller-ID/number selection and
number-sync checks happen there, exactly as for calls placed from the
the app). Poll GetCallStatus with the dialId to follow progress, and call
EndCall to hang up. Once the call has connected it appears in ListCalls /
GetCall (find it with ListCalls leadId = dialId).
Not idempotent: every successful request places a new call, so do not
blindly retry on a timeout; check ListCalls first. Billing is the same as
for the app calls; a call refused for insufficient credits is reported by
GetCallStatus as status "failed" with the reason in `outcome`.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `agentId` | string (int64) | The AI agent (persona) that will run the call. Required. Must belong to the organization (NOT_FOUND otherwise). |
| `phone` | string | Customer phone number to call, E.164 (e.g. "+919876543210"). Required. |
| `name` | string | Optional customer display name, shown in call history (max 120 chars). |
**Response** `PlaceCallResponse`
| Field | Type | Description |
|---|---|---|
| `dialId` | string (int64) | Handle for this dial attempt; pass it to GetCallStatus and EndCall, and use it as leadId in ListCalls to find the resulting call. |
| `status` | string | Always "dialing" on success (the call has been queued, not yet answered). |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/calls" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"agentId":"…","phone":"…","name":"…"}'
```
## GET /voice/v1/calls/{callId}
**GetCall** · needs `voice:read` (or write)
GetCall returns one call's details: parties, timing, outcome, AI summary,
sentiment and scored metrics, and whether a transcript and recording
exist. NOT_FOUND for an unknown id or another organization's call.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `callId` | string (int64) | |
**Response** `GetCallResponse`
| Field | Type | Description |
|---|---|---|
| `call` | Call | One call (AI agent call, inbound call, or human-bridged call). |
| `call.callId` | string (int64) | Call id; used by GetCall, GetCallTranscript and DownloadCallRecording. |
| `call.direction` | string | "outbound" (AI agent dialed the customer), "inbound" (customer dialed one of the organization's numbers) or "human" (bridged human call). |
| `call.leadId` | string (int64) | The dialId returned when this call was placed via the API; 0 for inbound calls. |
| `call.agentId` | string (int64) | AI agent that handled the call; 0 for human-bridged calls. |
| `call.humanId` | string (int64) | Human who handled the call; 0 for AI calls. |
| `call.humanName` | string | Human's name for human-bridged calls; empty otherwise. |
| `call.customerName` | string | Customer name if known; may be empty. |
| `call.customerPhone` | string | Customer phone number, E.164 where known. |
| `call.startedAt` | string | When the call started (RFC3339, UTC). |
| `call.endedAt` | string | When it ended (RFC3339, UTC); empty while ongoing. |
| `call.outcome` | string | Free-text outcome (e.g. "link_sent", "declined"). |
| `call.sentimentScore` | integer | Sentiment 1 (negative) to 5 (positive); 0 = unscored. |
| `call.sentimentWentRight` | string | What went right / wrong, from the post-call sentiment analysis. |
| `call.sentimentWentWrong` | string | |
| `call.transcriptSummary` | string | AI summary of the conversation; empty if none captured. |
| `call.metrics` | ScoredMetric[] | The organization's custom scored metrics for this call. |
| `call.hasTranscript` | boolean | True if GetCallTranscript will return content. |
| `call.hasRecording` | boolean | True if DownloadCallRecording will return audio. |
```bash
curl "https://api.pingx.ai/voice/v1/calls/CALLID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /voice/v1/calls/{callId}/recording
**DownloadCallRecording** · needs `voice:read` (or write)
DownloadCallRecording returns a call's audio recording (Ogg/Opus, content
type "audio/ogg") as the response body itself. Over REST this is the raw
audio file, so `curl -H "Authorization: Bearer pk_..." -o call.ogg
https://HOST/voice/v1/calls/123/recording` just works; over Connect/gRPC it
is a google.api.HttpBody message. The API key authenticates the download
directly: there are no signed or expiring URLs to manage. Whole-file
download only (no HTTP Range). NOT_FOUND when the call is unknown, belongs
to another organization, or has no recording (check Call.hasRecording);
FAILED_PRECONDITION if the file exceeds the 32 MiB download cap.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `callId` | string (int64) | |
**Response** `apiHttpBody`
| Field | Type | Description |
|---|---|---|
| `contentType` | string | The HTTP Content-Type header value specifying the content type of the body. |
| `data` | string (base64) | The HTTP request/response body as raw binary. |
| `extensions` | protobufAny[] | Application specific response metadata. Must be set in the first response for streaming APIs. |
| `extensions[].@type` | string | Identifies the type of the serialized Protobuf message with a URI reference consisting of a prefix ending in a slash and the fully-qualified type name. Example: type.googleapis.com/google.protobuf.StringValue This string must contain at least one `/` character, and the content after the last `/` must be the fully-qualified name of the type in canonical form, without a leading dot. Do not write a scheme on these URI references so that clients do not attempt to contact them. The prefix is arbitrary and Protobuf implementations are expected to simply strip off everything up to and including the last `/` to identify the type. `type.googleapis.com/` is a common default prefix that some legacy implementations require. This prefix does not indicate the origin of the type, and URIs containing it are not expected to respond to any requests. All type URL strings must be legal URI references with the additional restriction (for the text format) that the content of the reference must consist only of alphanumeric characters, percent-encoded escapes, and characters in the following set (not including the outer backticks): `/-.~_!$&()*+,;=`. Despite our allowing percent encodings, implementations should not unescape them to prevent confusion with existing parsers. For example, `type.googleapis.com%2FFoo` should be rejected. In the original design of `Any`, the possibility of launching a type resolution service at these type URLs was considered but Protobuf never implemented one and considers contacting these URLs to be problematic and a potential security issue. Do not attempt to contact type URLs. |
```bash
curl "https://api.pingx.ai/voice/v1/calls/CALLID/recording" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /voice/v1/calls/{callId}/transcript
**GetCallTranscript** · needs `voice:read` (or write)
GetCallTranscript returns a call's transcript as speaker-tagged turns
(voice markup such as "[laughs]" is stripped). A call that finished
without a transcript returns an empty list. NOT_FOUND for an unknown id or
another organization's call.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `callId` | string (int64) | |
**Response** `GetCallTranscriptResponse`
| Field | Type | Description |
|---|---|---|
| `turns` | TranscriptTurn[] | The conversation in order. Empty if the call has no transcript. |
| `turns[].role` | string | "assistant" (the AI agent or human operator side) or "user" (the customer). |
| `turns[].text` | string | What was said. |
```bash
curl "https://api.pingx.ai/voice/v1/calls/CALLID/transcript" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/dials/{dialId}:end
**EndCall** · needs `voice:write`
EndCall hangs up an in-progress call immediately (disconnects the customer
and the AI agent / human). Idempotent: ending a call that already ended
returns ended=false without error. NOT_FOUND for an unknown dialId or one
belonging to another organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `dialId` | string (int64) | dialId returned by PlaceCall or PlaceHumanCall. |
**Response** `EndCallResponse`
| Field | Type | Description |
|---|---|---|
| `ended` | boolean | True if an in-progress call was hung up; false if nothing was active. |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/dials/DIALID:end" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /voice/v1/dials/{dialId}/status
**GetCallStatus** · needs `voice:read` (or write)
GetCallStatus reports the live status of a call placed with PlaceCall or
PlaceHumanCall, identified by the dialId those returned. Poll every 2-5
seconds while status is "dialing" or "in_progress". NOT_FOUND for a dialId
that does not exist or belongs to another organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `dialId` | string (int64) | dialId returned by PlaceCall or PlaceHumanCall. |
**Response** `GetCallStatusResponse`
| Field | Type | Description |
|---|---|---|
| `status` | string | "dialing" (queued / ringing), "in_progress" (answered), "completed" or "failed" (could not be placed, or refused; see outcome). |
| `outcome` | string | Free-text outcome once known (e.g. "link_sent", "declined"), or the reason a call was refused (e.g. insufficient credits). Empty while ongoing. |
| `callId` | string (int64) | The call's id once the call exists (0 while still dialing). Use with GetCall / GetCallTranscript / DownloadCallRecording. |
| `hasTranscript` | boolean | True once a transcript is available. |
| `transcriptSummary` | string | Short AI summary of the conversation; empty until the call has finished post-processing. |
| `sentimentScore` | integer | Sentiment 1 (negative) to 5 (positive); 0 = not scored yet. |
```bash
curl "https://api.pingx.ai/voice/v1/dials/DIALID/status" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /voice/v1/human-assignments
**ListHumanAssignments** · needs `voice:read` (or write)
ListHumanAssignments lists which humans each AI agent may escalate to
(triage). An agent can only ever reach humans assigned to it.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Max assignments per page. Default 50, max 200. |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListHumanAssignmentsResponse`
| Field | Type | Description |
|---|---|---|
| `assignments` | HumanAssignment[] | |
| `assignments[].agentId` | string (int64) | |
| `assignments[].humanId` | string (int64) | |
| `assignments[].channel` | string | Currently always "whatsapp". |
| `assignments[].createdAt` | string | RFC3339, UTC. |
| `nextPageToken` | string | Pass as pageToken for the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/voice/v1/human-assignments" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PUT /voice/v1/human-assignments/{agentId}/{humanId}
**SetHumanAssignment** · needs `voice:write`
SetHumanAssignment allows (channel "whatsapp") or revokes (channel "")
an AI agent's escalation to a human. Idempotent. INVALID_ARGUMENT if the
agent is unknown or the human has no whatsappMobile.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Path parameter. |
| `humanId` | string (int64) | Path parameter. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `channel` | string | "whatsapp" to allow escalation; "" to revoke the assignment. |
**Response** `SetHumanAssignmentResponse`
| Field | Type | Description |
|---|---|---|
| `assignment` | HumanAssignment | The resulting assignment; unset when it was revoked. |
| `assignment.agentId` | string (int64) | |
| `assignment.humanId` | string (int64) | |
| `assignment.channel` | string | Currently always "whatsapp". |
| `assignment.createdAt` | string | RFC3339, UTC. |
```bash
curl -X PUT "https://api.pingx.ai/voice/v1/human-assignments/AGENTID/HUMANID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"channel":"…"}'
```
## POST /voice/v1/human-calls
**PlaceHumanCall** · needs `voice:write`
PlaceHumanCall starts a bridged call between one of the organization's
humans (see ListHumans) and a customer: the human's phone is dialed first,
then the customer's, and both are joined on one line. No AI persona
speaks; the call is silently recorded, transcribed and scored. Returns
immediately with a dialId, same lifecycle and polling as PlaceCall. The
human must have a phone number. Not idempotent.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `humanId` | string (int64) | The human to bridge in (from ListHumans). Required; must have a phone. |
| `phone` | string | Customer phone number to call, E.164. Required. |
| `name` | string | Optional customer display name (max 120 chars). |
**Response** `PlaceHumanCallResponse`
| Field | Type | Description |
|---|---|---|
| `dialId` | string (int64) | Handle for this dial attempt; see PlaceCallResponse.dialId. |
| `status` | string | Always "dialing" on success. |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/human-calls" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"humanId":"…","phone":"…","name":"…"}'
```
## GET /voice/v1/humans
**ListHumans** · needs `voice:read` (or write)
ListHumans lists the directory of people the business can reach by phone
(bridged human calls) and/or WhatsApp (AI agent escalations), oldest first.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Max humans per page. Default 50, max 200. |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListHumansResponse`
| Field | Type | Description |
|---|---|---|
| `humans` | Human[] | |
| `humans[].humanId` | string (int64) | |
| `humans[].name` | string | |
| `humans[].phone` | string | Dialed for bridged human calls, E.164; may be empty. |
| `humans[].whatsappMobile` | string | Where AI agents notify this human on WhatsApp, E.164; may be empty. |
| `humans[].purpose` | string | Optional role tag (e.g. "technician", "billing") AI agents can look people up by. |
| `humans[].active` | boolean | Whether this human can currently be dialed or notified. |
| `humans[].createdAt` | string | RFC3339, UTC. |
| `nextPageToken` | string | Pass as pageToken for the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/voice/v1/humans" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/humans
**AddHuman** · needs `voice:write`
AddHuman adds a person to the directory. At least one of phone or
whatsappMobile is required. ALREADY_EXISTS if the phone is already
registered.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | Required, max 60 chars. |
| `phone` | string | E.164; optional if whatsappMobile is set. |
| `whatsappMobile` | string | E.164; optional if phone is set. |
| `purpose` | string | Optional role tag, max 60 chars. |
**Response** `AddHumanResponse`
| Field | Type | Description |
|---|---|---|
| `human` | Human | A person in the directory. |
| `human.humanId` | string (int64) | |
| `human.name` | string | |
| `human.phone` | string | Dialed for bridged human calls, E.164; may be empty. |
| `human.whatsappMobile` | string | Where AI agents notify this human on WhatsApp, E.164; may be empty. |
| `human.purpose` | string | Optional role tag (e.g. "technician", "billing") AI agents can look people up by. |
| `human.active` | boolean | Whether this human can currently be dialed or notified. |
| `human.createdAt` | string | RFC3339, UTC. |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/humans" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…","phone":"…","whatsappMobile":"…","purpose":"…"}'
```
## DELETE /voice/v1/humans/{humanId}
**RemoveHuman** · needs `voice:write`
RemoveHuman deletes a human and their agent assignments. NOT_FOUND if
unknown or in another organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `humanId` | string (int64) | |
**Response** `RemoveHumanResponse`
```bash
curl -X DELETE "https://api.pingx.ai/voice/v1/humans/HUMANID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PATCH /voice/v1/humans/{humanId}
**UpdateHuman** · needs `voice:write`
UpdateHuman replaces a human's name, phone, whatsappMobile and purpose
(full replace, not a merge: send every field you want to keep).
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `humanId` | string (int64) | |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | Same rules as AddHumanRequest; all fields replace the stored values. |
| `phone` | string | |
| `whatsappMobile` | string | |
| `purpose` | string | |
**Response** `UpdateHumanResponse`
| Field | Type | Description |
|---|---|---|
| `human` | Human | A person in the directory. |
| `human.humanId` | string (int64) | |
| `human.name` | string | |
| `human.phone` | string | Dialed for bridged human calls, E.164; may be empty. |
| `human.whatsappMobile` | string | Where AI agents notify this human on WhatsApp, E.164; may be empty. |
| `human.purpose` | string | Optional role tag (e.g. "technician", "billing") AI agents can look people up by. |
| `human.active` | boolean | Whether this human can currently be dialed or notified. |
| `human.createdAt` | string | RFC3339, UTC. |
```bash
curl -X PATCH "https://api.pingx.ai/voice/v1/humans/HUMANID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…","phone":"…","whatsappMobile":"…","purpose":"…"}'
```
## GET /voice/v1/numbers
**ListNumbers** · needs `voice:read` (or write)
ListNumbers lists the organization's voice phone numbers (the numbers
calls are placed from and received on), default number first. WhatsApp
numbers are managed by the WhatsApp API, not here.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Max numbers per page. Default 50, max 200. |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `pingxVoiceV1ListNumbersResponse`
| Field | Type | Description |
|---|---|---|
| `numbers` | VoiceNumber[] | |
| `numbers[].numberId` | string (int64) | Id used by RemoveNumber, SetDefaultNumber and SetInboundAgent. |
| `numbers[].number` | string | The number, E.164. |
| `numbers[].label` | string | Optional human label (max 60 chars). |
| `numbers[].isDefault` | boolean | True for the number outbound calls use by default. |
| `numbers[].inboundAgentId` | string (int64) | AI agent answering inbound calls to this number; 0 = none (calls refused). |
| `numbers[].inboundAgentName` | string | Name of that agent; empty when unbound. |
| `numbers[].syncError` | string | Empty when the number is registered on the telephony trunk and dialable; otherwise why not (the number is refused for calls until fixed). |
| `numbers[].createdAt` | string | When it was registered (RFC3339, UTC). |
| `nextPageToken` | string | Pass as pageToken for the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/voice/v1/numbers" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/numbers
**AddNumber** · needs `voice:write`
AddNumber registers a phone number the organization owns on Pingx
Telephony so it can place and receive calls. The first number becomes the
default automatically. If registering it on the telephony trunk fails the
number is still saved and the returned syncError says why it is not yet
dialable (registration is retried automatically). ALREADY_EXISTS if the
number is already registered.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `number` | string | E.164 number to register. Required. |
| `label` | string | Optional label (max 60 chars). |
| `makeDefault` | boolean | Force this number to become the default even if others exist. |
**Response** `AddNumberResponse`
| Field | Type | Description |
|---|---|---|
| `number` | VoiceNumber | A voice phone number registered by the organization. |
| `number.numberId` | string (int64) | Id used by RemoveNumber, SetDefaultNumber and SetInboundAgent. |
| `number.number` | string | The number, E.164. |
| `number.label` | string | Optional human label (max 60 chars). |
| `number.isDefault` | boolean | True for the number outbound calls use by default. |
| `number.inboundAgentId` | string (int64) | AI agent answering inbound calls to this number; 0 = none (calls refused). |
| `number.inboundAgentName` | string | Name of that agent; empty when unbound. |
| `number.syncError` | string | Empty when the number is registered on the telephony trunk and dialable; otherwise why not (the number is refused for calls until fixed). |
| `number.createdAt` | string | When it was registered (RFC3339, UTC). |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/numbers" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"number":"…","label":"…","makeDefault":false}'
```
## DELETE /voice/v1/numbers/{numberId}
**RemoveNumber** · needs `voice:write`
RemoveNumber unregisters a voice number and removes it from the telephony
trunk; inbound calls to it stop being answered. NOT_FOUND when the number
is unknown (including already removed) or belongs to another organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `numberId` | string (int64) | |
**Response** `RemoveNumberResponse`
```bash
curl -X DELETE "https://api.pingx.ai/voice/v1/numbers/NUMBERID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/numbers/{numberId}:setDefault
**SetDefaultNumber** · needs `voice:write`
SetDefaultNumber makes a number the one outbound calls are placed from by
default. Idempotent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `numberId` | string (int64) | |
**Response** `SetDefaultNumberResponse`
```bash
curl -X POST "https://api.pingx.ai/voice/v1/numbers/NUMBERID:setDefault" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /voice/v1/numbers/{numberId}:setInboundAgent
**SetInboundAgent** · needs `voice:write`
SetInboundAgent chooses which AI agent answers cold inbound calls to a
number. agentId = 0 clears the binding, after which the number refuses
inbound calls (there is no fallback agent). Idempotent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `numberId` | string (int64) | |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `agentId` | string (int64) | AI agent to answer inbound calls; 0 clears the binding. Must belong to the organization. |
**Response** `SetInboundAgentResponse`
| Field | Type | Description |
|---|---|---|
| `number` | VoiceNumber | A voice phone number registered by the organization. |
| `number.numberId` | string (int64) | Id used by RemoveNumber, SetDefaultNumber and SetInboundAgent. |
| `number.number` | string | The number, E.164. |
| `number.label` | string | Optional human label (max 60 chars). |
| `number.isDefault` | boolean | True for the number outbound calls use by default. |
| `number.inboundAgentId` | string (int64) | AI agent answering inbound calls to this number; 0 = none (calls refused). |
| `number.inboundAgentName` | string | Name of that agent; empty when unbound. |
| `number.syncError` | string | Empty when the number is registered on the telephony trunk and dialable; otherwise why not (the number is refused for calls until fixed). |
| `number.createdAt` | string | When it was registered (RFC3339, UTC). |
```bash
curl -X POST "https://api.pingx.ai/voice/v1/numbers/NUMBERID:setInboundAgent" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"agentId":"…"}'
```
---
# Agents reference
> Every Agents endpoint with parameters, request and response fields, required scope and a curl example.
Every Agents endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer `. Read endpoints need `agents:read` (or `:write`), write endpoints need `agents:write`; the bare `agents` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).
**26 endpoints**
| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/agents/v1/agents` | ListAgents | read |
| `POST` | `/agents/v1/agents` | CreateAgent | write |
| `DELETE` | `/agents/v1/agents/{agentId}` | DeleteAgent | write |
| `GET` | `/agents/v1/agents/{agentId}` | GetAgent | read |
| `PATCH` | `/agents/v1/agents/{agentId}` | UpdateAgent | write |
| `GET` | `/agents/v1/agents/{agentId}/web-chat` | GetWebChatLink | read |
| `POST` | `/agents/v1/agents/{agentId}/web-chat:disable` | DisableWebChat | write |
| `POST` | `/agents/v1/agents/{agentId}/web-chat:enable` | EnableWebChat | write |
| `POST` | `/agents/v1/chat/conversations` | StartChatConversation | write |
| `POST` | `/agents/v1/chat/conversations/{conversationId}/messages` | SendChatMessage | write |
| `GET` | `/agents/v1/custom-fields` | ListCustomFields | read |
| `POST` | `/agents/v1/custom-fields` | CreateCustomField | write |
| `DELETE` | `/agents/v1/custom-fields/{customFieldId}` | DeleteCustomField | write |
| `PATCH` | `/agents/v1/custom-fields/{customFieldId}` | UpdateCustomField | write |
| `GET` | `/agents/v1/knowledge-bases` | ListKnowledgeBases | read |
| `POST` | `/agents/v1/knowledge-bases` | CreateKnowledgeBase | write |
| `DELETE` | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | DeleteKnowledgeBase | write |
| `GET` | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | GetKnowledgeBase | read |
| `PATCH` | `/agents/v1/knowledge-bases/{knowledgeBaseId}` | UpdateKnowledgeBase | write |
| `GET` | `/agents/v1/knowledge-bases/{knowledgeBaseId}/sources` | ListKnowledgeSources | read |
| `POST` | `/agents/v1/knowledge-bases/{knowledgeBaseId}/sources` | AddKnowledgeSource | write |
| `DELETE` | `/agents/v1/knowledge-sources/{sourceId}` | DeleteKnowledgeSource | write |
| `GET` | `/agents/v1/knowledge-sources/{sourceId}` | GetKnowledgeSource | read |
| `PATCH` | `/agents/v1/knowledge-sources/{sourceId}` | UpdateKnowledgeSource | write |
| `POST` | `/agents/v1/knowledge-sources/{sourceId}:recrawl` | RecrawlKnowledgeSource | write |
| `POST` | `/agents/v1/system-prompts:generate` | GenerateSystemPrompt | write |
## GET /agents/v1/agents
**ListAgents** · needs `agents:read` (or write)
Lists the organization's agents (personas), ordered by id.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Maximum agents to return (default 50, max 200). |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListAgentsResponse`
| Field | Type | Description |
|---|---|---|
| `agents` | Agent[] | |
| `agents[].id` | string (int64) | Agent id, unique within the platform. |
| `agents[].name` | string | Display name. |
| `agents[].systemPrompt` | string | Identity and context of the agent (who it is, what it represents), shared by chat and calls. Hard compliance rules and retrieved knowledge are added by the platform on top of this and are not part of it. |
| `agents[].knowledgeBaseIds` | string (int64)[] | Ids of the knowledge bases attached to this agent, in prompt order. |
| `agents[].chatInstructions` | string | Behaviour playbook for the text-chat channel (appended after systemPrompt). |
| `agents[].callInstructions` | string | Behaviour playbook for voice calls (appended after systemPrompt). Ignored for calls when script is set. |
| `agents[].script` | string | The organization's own call script (plain text, up to 20,000 characters), used instead of callInstructions on voice calls. Empty when unset. |
| `agents[].fillerWordsEnabled` | boolean | Voice calls only: speak with human-like filler words and self-corrections. |
| `agents[].voiceGender` | string | Voice for calls: "male" or "female". |
| `agents[].supportEscalationEnabled` | boolean | WhatsApp only: gives the agent support-escalation tools. Requires JIRA and Google Chat to be connected in the app. |
| `agents[].backgroundAudioEnabled` | boolean | Voice calls only: play a looped room-ambience bed under the agent's speech. |
| `agents[].backgroundAudioVolume` | string (int64) | Level of that bed as an integer percent, 0-100. |
| `nextPageToken` | string | Pass as pageToken to get the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/agents/v1/agents" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/agents
**CreateAgent** · needs `agents:write`
Creates an agent. Only name, systemPrompt and knowledgeBaseIds can be
set at creation; the other settings start at their defaults (generic chat
and call playbooks, female voice, filler words and background audio off)
and are changed afterwards with UpdateAgent. Not idempotent: each call
creates a new agent. INVALID_ARGUMENT if name is empty or a knowledge base
id is not in the organization.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | Display name (required, non-empty after trimming). |
| `systemPrompt` | string | Identity and context of the agent; may be empty and set later. |
| `knowledgeBaseIds` | string (int64)[] | Knowledge bases to attach, in prompt order; each must exist in the organization. |
**Response** `CreateAgentResponse`
| Field | Type | Description |
|---|---|---|
| `agent` | Agent | The created agent, with defaults filled in. |
| `agent.id` | string (int64) | Agent id, unique within the platform. |
| `agent.name` | string | Display name. |
| `agent.systemPrompt` | string | Identity and context of the agent (who it is, what it represents), shared by chat and calls. Hard compliance rules and retrieved knowledge are added by the platform on top of this and are not part of it. |
| `agent.knowledgeBaseIds` | string (int64)[] | Ids of the knowledge bases attached to this agent, in prompt order. |
| `agent.chatInstructions` | string | Behaviour playbook for the text-chat channel (appended after systemPrompt). |
| `agent.callInstructions` | string | Behaviour playbook for voice calls (appended after systemPrompt). Ignored for calls when script is set. |
| `agent.script` | string | The organization's own call script (plain text, up to 20,000 characters), used instead of callInstructions on voice calls. Empty when unset. |
| `agent.fillerWordsEnabled` | boolean | Voice calls only: speak with human-like filler words and self-corrections. |
| `agent.voiceGender` | string | Voice for calls: "male" or "female". |
| `agent.supportEscalationEnabled` | boolean | WhatsApp only: gives the agent support-escalation tools. Requires JIRA and Google Chat to be connected in the app. |
| `agent.backgroundAudioEnabled` | boolean | Voice calls only: play a looped room-ambience bed under the agent's speech. |
| `agent.backgroundAudioVolume` | string (int64) | Level of that bed as an integer percent, 0-100. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/agents" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…","systemPrompt":"…","knowledgeBaseIds":[]}'
```
## DELETE /agents/v1/agents/{agentId}
**DeleteAgent** · needs `agents:write`
Permanently deletes an agent (any agent, including the organization's last
one). Its web-chat link stops working. Not reversible. NOT_FOUND if the
agent does not exist (so a repeated delete returns NOT_FOUND).
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent to delete. |
**Response** `DeleteAgentResponse`
```bash
curl -X DELETE "https://api.pingx.ai/agents/v1/agents/AGENTID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /agents/v1/agents/{agentId}
**GetAgent** · needs `agents:read` (or write)
Returns one agent with its full configuration. NOT_FOUND if the agent does
not exist in the organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent to read. |
**Response** `GetAgentResponse`
| Field | Type | Description |
|---|---|---|
| `agent` | Agent | Agent is one saved persona. |
| `agent.id` | string (int64) | Agent id, unique within the platform. |
| `agent.name` | string | Display name. |
| `agent.systemPrompt` | string | Identity and context of the agent (who it is, what it represents), shared by chat and calls. Hard compliance rules and retrieved knowledge are added by the platform on top of this and are not part of it. |
| `agent.knowledgeBaseIds` | string (int64)[] | Ids of the knowledge bases attached to this agent, in prompt order. |
| `agent.chatInstructions` | string | Behaviour playbook for the text-chat channel (appended after systemPrompt). |
| `agent.callInstructions` | string | Behaviour playbook for voice calls (appended after systemPrompt). Ignored for calls when script is set. |
| `agent.script` | string | The organization's own call script (plain text, up to 20,000 characters), used instead of callInstructions on voice calls. Empty when unset. |
| `agent.fillerWordsEnabled` | boolean | Voice calls only: speak with human-like filler words and self-corrections. |
| `agent.voiceGender` | string | Voice for calls: "male" or "female". |
| `agent.supportEscalationEnabled` | boolean | WhatsApp only: gives the agent support-escalation tools. Requires JIRA and Google Chat to be connected in the app. |
| `agent.backgroundAudioEnabled` | boolean | Voice calls only: play a looped room-ambience bed under the agent's speech. |
| `agent.backgroundAudioVolume` | string (int64) | Level of that bed as an integer percent, 0-100. |
```bash
curl "https://api.pingx.ai/agents/v1/agents/AGENTID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PATCH /agents/v1/agents/{agentId}
**UpdateAgent** · needs `agents:write`
Partially updates an agent: only the fields present in the request change;
omitted fields keep their stored value. Idempotent. The script, when
changed, is normalized by an AI pass before saving (can take up to a few
minutes) and the processed text is what is stored. ABORTED if the script
was changed by another save while this one was being processed (re-read
and retry). FAILED_PRECONDITION when enabling supportEscalationEnabled
without JIRA and Google Chat connected in the app. NOT_FOUND for an
unknown agent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent to update. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | New display name; must be non-empty when provided. |
| `systemPrompt` | string | New system prompt. |
| `chatInstructions` | string | New chat playbook. |
| `callInstructions` | string | New call playbook. |
| `script` | string | New call script, up to 20,000 characters (an empty string clears it). Processed by an AI normalization pass before saving. |
| `fillerWordsEnabled` | boolean | Toggle filler words on voice calls. |
| `voiceGender` | string | "male" or "female"; any other value is stored as "female". |
| `supportEscalationEnabled` | boolean | Toggle support escalation (see Agent.supportEscalationEnabled). |
| `backgroundAudioEnabled` | boolean | Toggle the call background-audio bed. |
| `backgroundAudioVolume` | string (int64) | Background-audio level percent, 0-100 (INVALID_ARGUMENT above 100). |
| `knowledgeBaseIds` | KnowledgeBaseIds | When provided, REPLACES the attached knowledge bases with this ordered list (an empty list detaches all). Omit to keep the current attachments. |
| `knowledgeBaseIds.ids` | string (int64)[] | |
**Response** `UpdateAgentResponse`
| Field | Type | Description |
|---|---|---|
| `agent` | Agent | The agent after the update. |
| `agent.id` | string (int64) | Agent id, unique within the platform. |
| `agent.name` | string | Display name. |
| `agent.systemPrompt` | string | Identity and context of the agent (who it is, what it represents), shared by chat and calls. Hard compliance rules and retrieved knowledge are added by the platform on top of this and are not part of it. |
| `agent.knowledgeBaseIds` | string (int64)[] | Ids of the knowledge bases attached to this agent, in prompt order. |
| `agent.chatInstructions` | string | Behaviour playbook for the text-chat channel (appended after systemPrompt). |
| `agent.callInstructions` | string | Behaviour playbook for voice calls (appended after systemPrompt). Ignored for calls when script is set. |
| `agent.script` | string | The organization's own call script (plain text, up to 20,000 characters), used instead of callInstructions on voice calls. Empty when unset. |
| `agent.fillerWordsEnabled` | boolean | Voice calls only: speak with human-like filler words and self-corrections. |
| `agent.voiceGender` | string | Voice for calls: "male" or "female". |
| `agent.supportEscalationEnabled` | boolean | WhatsApp only: gives the agent support-escalation tools. Requires JIRA and Google Chat to be connected in the app. |
| `agent.backgroundAudioEnabled` | boolean | Voice calls only: play a looped room-ambience bed under the agent's speech. |
| `agent.backgroundAudioVolume` | string (int64) | Level of that bed as an integer percent, 0-100. |
```bash
curl -X PATCH "https://api.pingx.ai/agents/v1/agents/AGENTID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d @body.json
```
## GET /agents/v1/agents/{agentId}/web-chat
**GetWebChatLink** · needs `agents:read` (or write)
Returns whether the agent's web-chat link is enabled and its token. The
token is a bearer capability to chat with the agent publicly: treat it as
sensitive. NOT_FOUND for an unknown agent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent. |
**Response** `GetWebChatLinkResponse`
| Field | Type | Description |
|---|---|---|
| `link` | WebChatLink | WebChatLink is the web-chat share-link state of one agent. |
| `link.agentId` | string (int64) | The agent the link belongs to. |
| `link.enabled` | boolean | Whether the public chat page is currently enabled. |
| `link.token` | string | Opaque link token addressing the public chat page; empty when disabled. |
```bash
curl "https://api.pingx.ai/agents/v1/agents/AGENTID/web-chat" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/agents/{agentId}/web-chat:disable
**DisableWebChat** · needs `agents:write`
Revokes the agent's web-chat link immediately; the old token never works
again (re-enabling mints a new one). Idempotent: succeeds when no link is
active. NOT_FOUND for an unknown agent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent. |
**Response** `DisableWebChatResponse`
```bash
curl -X POST "https://api.pingx.ai/agents/v1/agents/AGENTID/web-chat:disable" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/agents/{agentId}/web-chat:enable
**EnableWebChat** · needs `agents:write`
Enables the agent's public web-chat page and returns its link token.
Idempotent: while a link is active the same token is returned; a new token
is minted only after DisableWebChat. NOT_FOUND for an unknown agent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent. |
**Response** `EnableWebChatResponse`
| Field | Type | Description |
|---|---|---|
| `link` | WebChatLink | WebChatLink is the web-chat share-link state of one agent. |
| `link.agentId` | string (int64) | The agent the link belongs to. |
| `link.enabled` | boolean | Whether the public chat page is currently enabled. |
| `link.token` | string | Opaque link token addressing the public chat page; empty when disabled. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/agents/AGENTID/web-chat:enable" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/chat/conversations
**StartChatConversation** · needs `agents:write`
Starts a text conversation with an agent and returns its id; send turns
with SendChatMessage. The server keeps the history. Not idempotent.
NOT_FOUND for an unknown agent.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Id of the agent to talk to. |
**Response** `StartChatConversationResponse`
| Field | Type | Description |
|---|---|---|
| `conversationId` | string (int64) | Id to pass to SendChatMessage. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/chat/conversations" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"agentId":"…"}'
```
## POST /agents/v1/chat/conversations/{conversationId}/messages
**SendChatMessage** · needs `agents:write`
Sends one user message and returns the agent's complete reply (the
request/response form of the streaming the app chat; the reply is
assembled server-side). Can take tens of seconds. Not idempotent: each
call appends a turn. NOT_FOUND if the conversation does not belong to the
organization; UNAVAILABLE if the assistant is temporarily unavailable.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `conversationId` | string (int64) | Conversation id from StartChatConversation. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `text` | string | The user's message (required, non-empty after trimming). |
**Response** `pingxAgentsV1SendChatMessageResponse`
| Field | Type | Description |
|---|---|---|
| `segments` | string[] | The reply as separate chat bubbles in order (a turn that searches the knowledge base mid-answer yields an acknowledgment bubble, then the grounded answer). |
| `text` | string | All segments joined with a blank line: the whole reply as one text. |
| `citations` | ChatCitation[] | Knowledge passages that grounded the reply, if any. |
| `citations[].knowledgeBaseName` | string | Knowledge base name. |
| `citations[].title` | string | Source title. |
| `citations[].url` | string | Source URL, when it has one. |
| `messageId` | string (int64) | Id of the stored assistant message. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/chat/conversations/CONVERSATIONID/messages" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"…"}'
```
## GET /agents/v1/custom-fields
**ListCustomFields** · needs `agents:read` (or write)
Lists custom fields visible for a scope (see ListCustomFieldsRequest),
default-scope fields first, then the scope's own, by position.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `scopeType` | string | "default" returns only the org-wide fields; "agent" (with agentId) returns org-wide plus that agent's own; "human_operators" returns org-wide plus the shared operator set. Required. |
| `agentId` | string (int64) | Required when scopeType is "agent". |
| `pageSize` | integer | Maximum fields to return (default 50, max 200). |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListCustomFieldsResponse`
| Field | Type | Description |
|---|---|---|
| `fields` | CustomField[] | Org-wide fields first, then the scope's own, by position. |
| `fields[].id` | string (int64) | Custom field id. |
| `fields[].scopeType` | string | "default" (org-wide), "agent" (one agent, see agentId) or "human_operators" (shared by human operators). |
| `fields[].agentId` | string (int64) | The agent, for scopeType "agent"; 0 otherwise. |
| `fields[].key` | string | Stable machine key (immutable), unique across scopes. |
| `fields[].label` | string | Display label. |
| `fields[].description` | string | What to measure and how to score it; guides the AI extraction. |
| `fields[].minValue` | integer | Lowest score. |
| `fields[].maxValue` | integer | Highest score (greater than minValue). |
| `fields[].position` | integer | Display order within its scope. |
| `nextPageToken` | string | Pass as pageToken to get the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/agents/v1/custom-fields" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/custom-fields
**CreateCustomField** · needs `agents:write`
Creates a custom field. The key is immutable afterwards and must be unique
across scope classes. INVALID_ARGUMENT for a bad scope, empty
key/label/description, minValue >= maxValue, or a key already in use;
NOT_FOUND for an unknown agentId.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `scopeType` | string | "default", "agent" or "human_operators". Required. |
| `agentId` | string (int64) | Required (and must belong to the organization) when scopeType is "agent". |
| `key` | string | Machine key, required, unique across the organization's scopes; immutable. |
| `label` | string | Display label, required. |
| `description` | string | What to measure and how to score it, required. |
| `minValue` | integer | Lowest score. |
| `maxValue` | integer | Highest score; must be greater than minValue. |
| `position` | integer | Display order within the scope. |
**Response** `CreateCustomFieldResponse`
| Field | Type | Description |
|---|---|---|
| `field` | CustomField | CustomField is a business-defined metric scored from each conversation (for example "Sentiment", 1-5). |
| `field.id` | string (int64) | Custom field id. |
| `field.scopeType` | string | "default" (org-wide), "agent" (one agent, see agentId) or "human_operators" (shared by human operators). |
| `field.agentId` | string (int64) | The agent, for scopeType "agent"; 0 otherwise. |
| `field.key` | string | Stable machine key (immutable), unique across scopes. |
| `field.label` | string | Display label. |
| `field.description` | string | What to measure and how to score it; guides the AI extraction. |
| `field.minValue` | integer | Lowest score. |
| `field.maxValue` | integer | Highest score (greater than minValue). |
| `field.position` | integer | Display order within its scope. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/custom-fields" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d @body.json
```
## DELETE /agents/v1/custom-fields/{customFieldId}
**DeleteCustomField** · needs `agents:write`
Deletes a custom field (stored historical values are left untouched).
NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `customFieldId` | string (int64) | Id of the custom field to delete. |
**Response** `DeleteCustomFieldResponse`
```bash
curl -X DELETE "https://api.pingx.ai/agents/v1/custom-fields/CUSTOMFIELDID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PATCH /agents/v1/custom-fields/{customFieldId}
**UpdateCustomField** · needs `agents:write`
Partially updates a custom field's label, description, range or position;
omitted fields keep their value. scope, agent and key cannot change.
Idempotent. NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `customFieldId` | string (int64) | Id of the custom field to update. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `label` | string | New label (non-empty). |
| `description` | string | New description (non-empty). |
| `minValue` | integer | New lowest score. |
| `maxValue` | integer | New highest score; the resulting range must satisfy minValue < maxValue. |
| `position` | integer | New display order. |
**Response** `UpdateCustomFieldResponse`
| Field | Type | Description |
|---|---|---|
| `field` | CustomField | CustomField is a business-defined metric scored from each conversation (for example "Sentiment", 1-5). |
| `field.id` | string (int64) | Custom field id. |
| `field.scopeType` | string | "default" (org-wide), "agent" (one agent, see agentId) or "human_operators" (shared by human operators). |
| `field.agentId` | string (int64) | The agent, for scopeType "agent"; 0 otherwise. |
| `field.key` | string | Stable machine key (immutable), unique across scopes. |
| `field.label` | string | Display label. |
| `field.description` | string | What to measure and how to score it; guides the AI extraction. |
| `field.minValue` | integer | Lowest score. |
| `field.maxValue` | integer | Highest score (greater than minValue). |
| `field.position` | integer | Display order within its scope. |
```bash
curl -X PATCH "https://api.pingx.ai/agents/v1/custom-fields/CUSTOMFIELDID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"label":"…","description":"…","minValue":0,"maxValue":0,"position":0}'
```
## GET /agents/v1/knowledge-bases
**ListKnowledgeBases** · needs `agents:read` (or write)
Lists the organization's knowledge bases (without their sources: use
GetKnowledgeBase or ListKnowledgeSources for those), ordered by id.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Maximum knowledge bases to return (default 50, max 200). |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListKnowledgeBasesResponse`
| Field | Type | Description |
|---|---|---|
| `knowledgeBases` | KnowledgeBase[] | Knowledge bases without their sources. |
| `knowledgeBases[].id` | string (int64) | Knowledge base id. |
| `knowledgeBases[].name` | string | Display name. |
| `knowledgeBases[].sourceCount` | integer | Number of sources in the knowledge base. |
| `knowledgeBases[].sources` | KnowledgeSource[] | The sources. Populated only by GetKnowledgeBase and by the create/update RPCs' responses; empty in ListKnowledgeBases. |
| `nextPageToken` | string | Pass as pageToken to get the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/agents/v1/knowledge-bases" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/knowledge-bases
**CreateKnowledgeBase** · needs `agents:write`
Creates an empty knowledge base. Attach it to agents through
CreateAgent/UpdateAgent knowledgeBaseIds. Not idempotent.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | Display name (required, non-empty after trimming). |
**Response** `CreateKnowledgeBaseResponse`
| Field | Type | Description |
|---|---|---|
| `knowledgeBase` | KnowledgeBase | KnowledgeBase groups sources that agents search to ground their answers. |
| `knowledgeBase.id` | string (int64) | Knowledge base id. |
| `knowledgeBase.name` | string | Display name. |
| `knowledgeBase.sourceCount` | integer | Number of sources in the knowledge base. |
| `knowledgeBase.sources` | KnowledgeSource[] | The sources. Populated only by GetKnowledgeBase and by the create/update RPCs' responses; empty in ListKnowledgeBases. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/knowledge-bases" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…"}'
```
## DELETE /agents/v1/knowledge-bases/{knowledgeBaseId}
**DeleteKnowledgeBase** · needs `agents:write`
Permanently deletes a knowledge base with all its sources and their
indexed content; agents lose the attachment. NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `knowledgeBaseId` | string (int64) | Id of the knowledge base to delete. |
**Response** `DeleteKnowledgeBaseResponse`
```bash
curl -X DELETE "https://api.pingx.ai/agents/v1/knowledge-bases/KNOWLEDGEBASEID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /agents/v1/knowledge-bases/{knowledgeBaseId}
**GetKnowledgeBase** · needs `agents:read` (or write)
Returns one knowledge base including all its sources and their ingestion
status. NOT_FOUND if it does not exist in the organization.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `knowledgeBaseId` | string (int64) | Id of the knowledge base. |
**Response** `GetKnowledgeBaseResponse`
| Field | Type | Description |
|---|---|---|
| `knowledgeBase` | KnowledgeBase | The knowledge base with all its sources. |
| `knowledgeBase.id` | string (int64) | Knowledge base id. |
| `knowledgeBase.name` | string | Display name. |
| `knowledgeBase.sourceCount` | integer | Number of sources in the knowledge base. |
| `knowledgeBase.sources` | KnowledgeSource[] | The sources. Populated only by GetKnowledgeBase and by the create/update RPCs' responses; empty in ListKnowledgeBases. |
```bash
curl "https://api.pingx.ai/agents/v1/knowledge-bases/KNOWLEDGEBASEID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PATCH /agents/v1/knowledge-bases/{knowledgeBaseId}
**UpdateKnowledgeBase** · needs `agents:write`
Renames a knowledge base. Idempotent. NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `knowledgeBaseId` | string (int64) | Id of the knowledge base to rename. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | New display name (required, non-empty after trimming). |
**Response** `UpdateKnowledgeBaseResponse`
| Field | Type | Description |
|---|---|---|
| `knowledgeBase` | KnowledgeBase | KnowledgeBase groups sources that agents search to ground their answers. |
| `knowledgeBase.id` | string (int64) | Knowledge base id. |
| `knowledgeBase.name` | string | Display name. |
| `knowledgeBase.sourceCount` | integer | Number of sources in the knowledge base. |
| `knowledgeBase.sources` | KnowledgeSource[] | The sources. Populated only by GetKnowledgeBase and by the create/update RPCs' responses; empty in ListKnowledgeBases. |
```bash
curl -X PATCH "https://api.pingx.ai/agents/v1/knowledge-bases/KNOWLEDGEBASEID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…"}'
```
## GET /agents/v1/knowledge-bases/{knowledgeBaseId}/sources
**ListKnowledgeSources** · needs `agents:read` (or write)
Lists the sources of one knowledge base, ordered by id. Use this (or
GetKnowledgeSource) to poll ingestion status.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `knowledgeBaseId` | string (int64) | Id of the knowledge base whose sources to list. |
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Maximum sources to return (default 50, max 200). |
| `pageToken` | string | nextPageToken from the previous response; empty for the first page. |
**Response** `ListKnowledgeSourcesResponse`
| Field | Type | Description |
|---|---|---|
| `sources` | KnowledgeSource[] | |
| `sources[].id` | string (int64) | Source id. |
| `sources[].knowledgeBaseId` | string (int64) | Id of the knowledge base it belongs to. |
| `sources[].sourceType` | string | "text" (a note), "url" (one page), "file" (uploaded document) or "site" (whole-site crawl). |
| `sources[].title` | string | Display title (defaults to the URL or file name). |
| `sources[].sourceUri` | string | The URL for url/site sources, the original file name for files, empty for text. |
| `sources[].status` | string | Ingestion status: "pending" (queued), "crawling" (site crawl running), "ready" (fully ingested), "partial" (site crawl finished with some pages failed) or "failed" (see error). |
| `sources[].error` | string | Why ingestion failed; empty unless status is "failed". |
| `sources[].content` | string | The note text, for "text" sources only (empty for the other types). |
| `sources[].pagesDiscovered` | integer | Site crawls only: pages found so far. |
| `sources[].pagesIngested` | integer | Site crawls only: pages successfully ingested so far. |
| `sources[].pagesFailed` | integer | Site crawls only: pages that failed. |
| `sources[].ingestionFinished` | boolean | True once ingestion has reached a final state (status ready, partial or failed): stop polling. |
| `nextPageToken` | string | Pass as pageToken to get the next page; empty on the last page. |
```bash
curl "https://api.pingx.ai/agents/v1/knowledge-bases/KNOWLEDGEBASEID/sources" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/knowledge-bases/{knowledgeBaseId}/sources
**AddKnowledgeSource** · needs `agents:write`
Adds a source to a knowledge base and starts ingesting it (extract, chunk,
embed) in the background. Returns immediately with status "pending"; poll
GetKnowledgeSource until ingestionFinished. Exactly one payload (text,
url, file or site) must be set. Not idempotent: each call adds a source.
INVALID_ARGUMENT for a missing payload/url/filename or a file over 10 MB;
NOT_FOUND if the knowledge base is unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `knowledgeBaseId` | string (int64) | Id of the knowledge base to add the source to. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `title` | string | Optional display title; defaults to "Note", the URL or the file name. |
| `text` | string | A text note (chunked and embedded like any source). |
| `url` | string | A single web page, fetched and extracted by the platform. |
| `file` | FileSource | An uploaded .txt, .md or .pdf file. |
| `file.filename` | string | File name; its extension picks the parser: .txt, .md or .pdf. |
| `file.data` | string (base64) | The raw file bytes (base64 in JSON), at most 10 MB. |
| `site` | SiteSource | A whole-site crawl. |
| `site.url` | string | Start URL of the crawl (required). |
| `site.maxPages` | integer | Maximum pages to crawl; 0 uses the server default. |
**Response** `AddKnowledgeSourceResponse`
| Field | Type | Description |
|---|---|---|
| `source` | KnowledgeSource | The new source, status "pending". Poll GetKnowledgeSource. |
| `source.id` | string (int64) | Source id. |
| `source.knowledgeBaseId` | string (int64) | Id of the knowledge base it belongs to. |
| `source.sourceType` | string | "text" (a note), "url" (one page), "file" (uploaded document) or "site" (whole-site crawl). |
| `source.title` | string | Display title (defaults to the URL or file name). |
| `source.sourceUri` | string | The URL for url/site sources, the original file name for files, empty for text. |
| `source.status` | string | Ingestion status: "pending" (queued), "crawling" (site crawl running), "ready" (fully ingested), "partial" (site crawl finished with some pages failed) or "failed" (see error). |
| `source.error` | string | Why ingestion failed; empty unless status is "failed". |
| `source.content` | string | The note text, for "text" sources only (empty for the other types). |
| `source.pagesDiscovered` | integer | Site crawls only: pages found so far. |
| `source.pagesIngested` | integer | Site crawls only: pages successfully ingested so far. |
| `source.pagesFailed` | integer | Site crawls only: pages that failed. |
| `source.ingestionFinished` | boolean | True once ingestion has reached a final state (status ready, partial or failed): stop polling. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/knowledge-bases/KNOWLEDGEBASEID/sources" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"…","text":"…","url":"…","file":{},"site":{}}'
```
## DELETE /agents/v1/knowledge-sources/{sourceId}
**DeleteKnowledgeSource** · needs `agents:write`
Deletes one source and its indexed content. NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `sourceId` | string (int64) | Id of the source to delete. |
**Response** `DeleteKnowledgeSourceResponse`
```bash
curl -X DELETE "https://api.pingx.ai/agents/v1/knowledge-sources/SOURCEID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /agents/v1/knowledge-sources/{sourceId}
**GetKnowledgeSource** · needs `agents:read` (or write)
Returns one source. This is the call to poll after AddKnowledgeSource,
UpdateKnowledgeSource or RecrawlKnowledgeSource: repeat it every few
seconds until ingestionFinished is true (status ready, partial or
failed). Sites can take minutes; check the pages_* counters for progress.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `sourceId` | string (int64) | Id of the source to read (and poll). |
**Response** `GetKnowledgeSourceResponse`
| Field | Type | Description |
|---|---|---|
| `source` | KnowledgeSource | KnowledgeSource is one piece of knowledge inside a knowledge base. Its content is extracted, chunked and embedded asynchronously after it is added. |
| `source.id` | string (int64) | Source id. |
| `source.knowledgeBaseId` | string (int64) | Id of the knowledge base it belongs to. |
| `source.sourceType` | string | "text" (a note), "url" (one page), "file" (uploaded document) or "site" (whole-site crawl). |
| `source.title` | string | Display title (defaults to the URL or file name). |
| `source.sourceUri` | string | The URL for url/site sources, the original file name for files, empty for text. |
| `source.status` | string | Ingestion status: "pending" (queued), "crawling" (site crawl running), "ready" (fully ingested), "partial" (site crawl finished with some pages failed) or "failed" (see error). |
| `source.error` | string | Why ingestion failed; empty unless status is "failed". |
| `source.content` | string | The note text, for "text" sources only (empty for the other types). |
| `source.pagesDiscovered` | integer | Site crawls only: pages found so far. |
| `source.pagesIngested` | integer | Site crawls only: pages successfully ingested so far. |
| `source.pagesFailed` | integer | Site crawls only: pages that failed. |
| `source.ingestionFinished` | boolean | True once ingestion has reached a final state (status ready, partial or failed): stop polling. |
```bash
curl "https://api.pingx.ai/agents/v1/knowledge-sources/SOURCEID" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## PATCH /agents/v1/knowledge-sources/{sourceId}
**UpdateKnowledgeSource** · needs `agents:write`
Edits the title and content of a "text" source and re-ingests it (status
goes back to "pending"; poll GetKnowledgeSource). INVALID_ARGUMENT if the
source is not a text source; NOT_FOUND if unknown. Idempotent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `sourceId` | string (int64) | Id of the text source to edit. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `title` | string | New title. |
| `content` | string | New note text. |
**Response** `UpdateKnowledgeSourceResponse`
| Field | Type | Description |
|---|---|---|
| `source` | KnowledgeSource | The source, status back to "pending". Poll GetKnowledgeSource. |
| `source.id` | string (int64) | Source id. |
| `source.knowledgeBaseId` | string (int64) | Id of the knowledge base it belongs to. |
| `source.sourceType` | string | "text" (a note), "url" (one page), "file" (uploaded document) or "site" (whole-site crawl). |
| `source.title` | string | Display title (defaults to the URL or file name). |
| `source.sourceUri` | string | The URL for url/site sources, the original file name for files, empty for text. |
| `source.status` | string | Ingestion status: "pending" (queued), "crawling" (site crawl running), "ready" (fully ingested), "partial" (site crawl finished with some pages failed) or "failed" (see error). |
| `source.error` | string | Why ingestion failed; empty unless status is "failed". |
| `source.content` | string | The note text, for "text" sources only (empty for the other types). |
| `source.pagesDiscovered` | integer | Site crawls only: pages found so far. |
| `source.pagesIngested` | integer | Site crawls only: pages successfully ingested so far. |
| `source.pagesFailed` | integer | Site crawls only: pages that failed. |
| `source.ingestionFinished` | boolean | True once ingestion has reached a final state (status ready, partial or failed): stop polling. |
```bash
curl -X PATCH "https://api.pingx.ai/agents/v1/knowledge-sources/SOURCEID" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"…","content":"…"}'
```
## POST /agents/v1/knowledge-sources/{sourceId}:recrawl
**RecrawlKnowledgeSource** · needs `agents:write`
Re-crawls an existing "site" source from scratch (status back to
"pending", counters reset; poll GetKnowledgeSource). INVALID_ARGUMENT if
the source is not a site; FAILED_PRECONDITION if a crawl is already in
progress; NOT_FOUND if unknown.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `sourceId` | string (int64) | Id of the site source to re-crawl. |
**Response** `RecrawlKnowledgeSourceResponse`
| Field | Type | Description |
|---|---|---|
| `source` | KnowledgeSource | The source, status back to "pending". Poll GetKnowledgeSource. |
| `source.id` | string (int64) | Source id. |
| `source.knowledgeBaseId` | string (int64) | Id of the knowledge base it belongs to. |
| `source.sourceType` | string | "text" (a note), "url" (one page), "file" (uploaded document) or "site" (whole-site crawl). |
| `source.title` | string | Display title (defaults to the URL or file name). |
| `source.sourceUri` | string | The URL for url/site sources, the original file name for files, empty for text. |
| `source.status` | string | Ingestion status: "pending" (queued), "crawling" (site crawl running), "ready" (fully ingested), "partial" (site crawl finished with some pages failed) or "failed" (see error). |
| `source.error` | string | Why ingestion failed; empty unless status is "failed". |
| `source.content` | string | The note text, for "text" sources only (empty for the other types). |
| `source.pagesDiscovered` | integer | Site crawls only: pages found so far. |
| `source.pagesIngested` | integer | Site crawls only: pages successfully ingested so far. |
| `source.pagesFailed` | integer | Site crawls only: pages that failed. |
| `source.ingestionFinished` | boolean | True once ingestion has reached a final state (status ready, partial or failed): stop polling. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/knowledge-sources/SOURCEID:recrawl" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /agents/v1/system-prompts:generate
**GenerateSystemPrompt** · needs `agents:write`
Drafts an agent system prompt from a free-form brief, using Claude. Does
not create or modify any agent: copy the returned text into CreateAgent /
UpdateAgent. Can take up to a few minutes and is billed as AI usage; it is
named as a write RPC so read-only keys cannot trigger it. Not idempotent
(the wording differs between calls).
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `brief` | string | Free-form description of the agent to build: domain, audience, purpose, tone, anything relevant. Required. |
**Response** `GenerateSystemPromptResponse`
| Field | Type | Description |
|---|---|---|
| `systemPrompt` | string | The complete generated system prompt text. |
```bash
curl -X POST "https://api.pingx.ai/agents/v1/system-prompts:generate" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"brief":"…"}'
```
---
# Analytics reference
> Every Analytics endpoint with parameters, request and response fields, required scope and a curl example.
Every Analytics endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer `. Read endpoints need `analytics:read` (or `:write`), write endpoints need `analytics:write`; the bare `analytics` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).
**4 endpoints**
| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/analytics/v1/branch-leaderboard` | GetBranchLeaderboard | read |
| `GET` | `/analytics/v1/call-volume` | GetCallVolume | read |
| `GET` | `/analytics/v1/custom-metrics` | GetCustomMetrics | read |
| `GET` | `/analytics/v1/nps-trend` | GetNpsTrend | read |
## GET /analytics/v1/branch-leaderboard
**GetBranchLeaderboard** · needs `analytics:read` (or write)
Returns every branch's NPS over the whole lookback window (not per day),
best NPS first, with its response and detractor counts. Use it to find
the best and worst performing branches/locations. Read-only and
idempotent.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `days` | integer | Lookback window in calendar days ending today (inclusive). <= 0 means 30; maximum 180 (larger values are clamped). |
**Response** `GetBranchLeaderboardResponse`
| Field | Type | Description |
|---|---|---|
| `rows` | BranchLeaderboardRow[] | Branches, best NPS first. |
| `rows[].branch` | string | Branch (location) name as recorded on the survey responses. |
| `rows[].nps` | number | NPS over the whole lookback window (not per day), from -100 to 100. |
| `rows[].responses` | integer | Number of NPS responses in the window. |
| `rows[].detractors` | integer | Number of detractor responses in the window. |
| `days` | integer | The effective lookback window in days after defaulting/clamping. |
```bash
curl "https://api.pingx.ai/analytics/v1/branch-leaderboard" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /analytics/v1/call-volume
**GetCallVolume** · needs `analytics:read` (or write)
Returns how many calls were placed and how many completed in the last
"days" days. Read-only and idempotent. For individual calls use the
voice API.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `days` | integer | Lookback window in calendar days ending today (inclusive). <= 0 means 30; maximum 180 (larger values are clamped). |
**Response** `GetCallVolumeResponse`
| Field | Type | Description |
|---|---|---|
| `callsPlaced` | integer | Calls placed (attempted) in the window, across AI personas, human operators and feedback calls. |
| `callsDone` | integer | Calls that completed in the window. |
| `days` | integer | The effective lookback window in days after defaulting/clamping. |
```bash
curl "https://api.pingx.ai/analytics/v1/call-volume" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /analytics/v1/custom-metrics
**GetCustomMetrics** · needs `analytics:read` (or write)
Returns the organization's custom metrics: numeric fields the AI
extracts from every call according to the organization's custom-field
configuration (for example "customer satisfaction 1-5"), as daily
average series per AI agent (persona) or for human operators, together
with AI-generated "what is working / what is not" insights where enough
calls exist. Filter to one agent with agentId, or to human operators
with humanOperatorsOnly. Read-only and idempotent.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `days` | integer | Lookback window in calendar days ending today (inclusive). <= 0 means 30; maximum 180 (larger values are clamped). |
| `agentId` | string (int64) | Restrict to the series produced by one AI agent (persona). The id comes from the agents API. 0 (default) means every scope ("all personas"). |
| `humanOperatorsOnly` | boolean | When true, restrict to the series produced for human operators (calls handled by people rather than AI agents). |
**Response** `GetCustomMetricsResponse`
| Field | Type | Description |
|---|---|---|
| `series` | CustomMetricSeries[] | One series per (scope, custom field). |
| `series[].scopeType` | string | Which kind of caller produced the values: "agent" or "human_operators". |
| `series[].agentName` | string | AI agent (persona) name; empty for human operators. |
| `series[].fieldKey` | string | Stable machine key of the custom field, e.g. "csat". |
| `series[].fieldLabel` | string | Human-readable label of the custom field, e.g. "Customer satisfaction". |
| `series[].minValue` | integer | Lowest value the field can take (scale lower bound). |
| `series[].maxValue` | integer | Highest value the field can take (scale upper bound). |
| `series[].points` | CustomMetricPoint[] | Daily average values, oldest first. |
| `series[].insightGood` | string[] | AI-written bullets on what is working well. Empty when no insight has been generated yet or the sample is below the threshold. |
| `series[].insightBad` | string[] | AI-written bullets on what is not going well. Same emptiness rule. |
| `series[].insightGeneratedAt` | string | When the insight was generated, RFC 3339; empty when none exists yet. |
| `series[].insightSampleSize` | integer | Number of calls the insight was (or would be) computed from; 0 when no insight exists yet. |
| `days` | integer | The effective lookback window in days after defaulting/clamping. |
```bash
curl "https://api.pingx.ai/analytics/v1/custom-metrics" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /analytics/v1/nps-trend
**GetNpsTrend** · needs `analytics:read` (or write)
Returns the organization's Net Promoter Score (NPS) as a daily time
series for the last "days" days, aggregated across all branches, oldest
day first. NPS ranges from -100 to 100 (percent promoters minus percent
detractors). Days with no survey responses are reported with
responses = 0 and nps = 0; check "responses" before treating an nps of 0
as a real score. Read-only and idempotent.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `days` | integer | Lookback window in calendar days ending today (inclusive). <= 0 means 30; maximum 180 (larger values are clamped). |
**Response** `GetNpsTrendResponse`
| Field | Type | Description |
|---|---|---|
| `points` | NpsTrendPoint[] | Daily points, oldest first. |
| `points[].date` | string | The day, as an RFC 3339 timestamp (day granularity). |
| `points[].nps` | number | Net Promoter Score for that day aggregated across all branches, from -100 to 100. 0 when responses = 0 (no data) — check "responses" first. |
| `points[].responses` | integer | Number of NPS survey responses collected that day across all branches. |
| `days` | integer | The effective lookback window in days after defaulting/clamping. |
```bash
curl "https://api.pingx.ai/analytics/v1/nps-trend" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
---
# Contact memory reference
> Every Contact memory endpoint with parameters, request and response fields, required scope and a curl example.
Every Contact memory endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer `. Read endpoints need `memory:read` (or `:write`), write endpoints need `memory:write`; the bare `memory` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).
**15 endpoints**
| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/memory/v1/contacts` | ListContactActivity | read |
| `POST` | `/memory/v1/contacts/{contactId}:erase` | EraseSubject | write |
| `GET` | `/memory/v1/contacts/{contactId}/memory` | GetContactMemory | read |
| `GET` | `/memory/v1/contacts/{contactId}/messages` | ListRecentMessages | read |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:amend` | AmendFact | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:forget` | ForgetFact | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:renew` | RenewFact | write |
| `GET` | `/memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}/provenance` | GetFactProvenance | read |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/memory:clear` | ClearForPersona | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/memory:forgetAll` | ForgetAllForPersona | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/suppressions:lift` | LiftSuppression | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/todos/{todoId}:close` | CloseTodo | write |
| `POST` | `/memory/v1/contacts/{contactId}/personas/{agentId}/todos/{todoId}:reopen` | ReopenTodo | write |
| `GET` | `/memory/v1/test-contacts` | ListTestContacts | read |
| `POST` | `/memory/v1/test-contacts` | CreateTestContact | write |
## GET /memory/v1/contacts
**ListContactActivity** · needs `memory:read` (or write)
Lists the organization's contacts together with their latest
interaction and memory counts (active facts and open todos across all
personas). Use it to find which contacts the agents hold memory about.
Paginated: pass the returned nextPageToken as pageToken to get the
next page. Read-only.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `search` | string | Case-insensitive substring matched against the contact's name or phone. Empty returns all contacts. |
| `includeTest` | boolean | Include synthetic test contacts (source "test"). They are hidden unless this is true. |
| `pageSize` | integer | Maximum rows per page. <= 0 means 50; maximum 200 (larger values are clamped). |
| `pageToken` | string | Opaque token from a previous response's nextPageToken; empty for the first page. An invalid token is INVALID_ARGUMENT. |
**Response** `ListContactActivityResponse`
| Field | Type | Description |
|---|---|---|
| `contacts` | ContactActivityRow[] | The page of contacts, most recently active first. |
| `contacts[].contactId` | string | The contact's UUID. |
| `contacts[].name` | string | Contact display name. |
| `contacts[].phone` | string | Contact phone number as stored; empty for test contacts. |
| `contacts[].source` | string | How the contact was created: "manual", "import", "inbound" or "test". |
| `contacts[].lastKind` | string | Kind of the latest interaction: "call" or "whatsapp"; empty when the contact never interacted. |
| `contacts[].lastChannel` | string | Channel of the latest interaction: "voice" or "whatsapp"; empty if none. |
| `contacts[].lastAgentId` | string (int64) | Id of the AI agent (persona) involved in the latest interaction; 0 if none. |
| `contacts[].lastAgentName` | string | Name of that AI agent. |
| `contacts[].lastAt` | string | When the latest interaction happened (RFC 3339); empty if none. |
| `contacts[].factCount` | integer | Number of active facts across all personas. |
| `contacts[].openTodoCount` | integer | Number of open todos across all personas. |
| `nextPageToken` | string | Token to pass as pageToken to fetch the next page; empty when this is the last page. |
```bash
curl "https://api.pingx.ai/memory/v1/contacts" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /memory/v1/contacts/{contactId}:erase
**EraseSubject** · needs `memory:write`
DESTRUCTIVE AND IRREVERSIBLE. Right-to-be-forgotten: erases every
fact, todo, suppression and episode held about the contact across ALL
personas of the organization, and records an erasure marker so older
data is not re-learned. Requires confirm = true. Returns the number of
rows erased in "affected". The contact record itself is not deleted.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact to erase from all personas' memory (path parameter). |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `confirm` | boolean | Must be true, acknowledging that this cannot be undone. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID:erase" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"confirm":false}'
```
## GET /memory/v1/contacts/{contactId}/memory
**GetContactMemory** · needs `memory:read` (or write)
Returns everything remembered about one contact for one persona: the
contact header, every persona that has interacted with (or holds memory
about) the contact, and for the selected persona its active facts, todos
(open first, then recently closed), suppressions, counts, and whether a
call is currently in progress. A contact that exists but has no persona
relationship yet returns an empty (but valid) memory; an unknown
contactId is NOT_FOUND. Read-only.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `agentId` | string (int64) | Persona whose memory to return. 0 (default) means the persona of the contact's most recent interaction (else the first persona seen). An agent that does not exist in your organization is NOT_FOUND; an existing agent that never spoke to the contact returns empty memory. |
**Response** `GetContactMemoryResponse`
| Field | Type | Description |
|---|---|---|
| `contactId` | string | The contact's UUID. |
| `name` | string | Contact display name. |
| `phone` | string | Contact phone number; empty for test contacts. |
| `source` | string | How the contact was created: "manual", "import", "inbound" or "test". |
| `personas` | Persona[] | Every persona that has interacted with the contact or holds memory about them. |
| `personas[].id` | string (int64) | Numeric agent id (usable as agentId in other calls). |
| `personas[].name` | string | Agent display name. |
| `agentId` | string (int64) | The persona this response is scoped to (0 when the contact has no persona relationship yet; then the lists below are empty). |
| `facts` | Fact[] | Active facts only. |
| `facts[].id` | string (int64) | Numeric fact id (use it in factId parameters). |
| `facts[].category` | string | Kind of knowledge: "preference" or "fact". |
| `facts[].factKey` | string | Stable key of what the fact is about, e.g. "preferred_language". |
| `facts[].factValue` | string | The remembered value. |
| `facts[].evidenceQuote` | string | Verbatim quote from the conversation that supports the fact; may be empty. |
| `facts[].confidence` | number | Model confidence from 0 to 1. |
| `facts[].verification` | string | How trustworthy the fact is: "stated" (the contact said it), "inferred", "unverified" or "human" (entered or corrected through this API/the app). |
| `facts[].observedAt` | string | When the fact was last observed (RFC 3339). |
| `facts[].expiresAt` | string | When the fact expires (RFC 3339); empty when open-ended. |
| `facts[].status` | string | Lifecycle: "active", "expired", "superseded" or "forgotten". |
| `facts[].pinned` | boolean | True when the fact is pinned (protected from automatic overwrite). |
| `facts[].contradictions` | integer | How many later observations contradicted this fact. |
| `facts[].originEpisodeId` | string (int64) | Id of the episode the fact was learned in (see GetFactProvenance); 0 if unknown. |
| `facts[].dataClassification` | string | Sensitivity: "general" or "sensitive". |
| `todos` | Todo[] | Open todos first, then recently closed ones. |
| `todos[].id` | string (int64) | Numeric todo id (use it in todoId parameters). |
| `todos[].title` | string | What needs to be done, e.g. "Call back on Friday". |
| `todos[].status` | string | "open", "done" or "cancelled". |
| `todos[].createdAt` | string | When the todo was created (RFC 3339). |
| `todos[].dueAt` | string | Due time (RFC 3339); empty when none. |
| `todos[].closedAt` | string | When it was closed (RFC 3339); empty while open. |
| `todos[].closedBy` | string | Who closed it: "human" or "agent"; empty while open. |
| `todos[].closingEvidence` | string | Evidence recorded when it was closed. |
| `todos[].closingEpisodeId` | string (int64) | Episode (call) in which it was closed; 0 if not closed by a call. |
| `todos[].reopenedAt` | string | When it was last reopened (RFC 3339); empty if never. |
| `todos[].reopenedBy` | string | Who reopened it: "human" or "agent"; empty if never. |
| `suppressions` | Suppression[] | Do-not-learn rules for this contact and persona. |
| `suppressions[].factKey` | string | The suppressed fact key. |
| `suppressions[].reason` | string | Why it was suppressed (e.g. the reason given to ForgetFact). |
| `suppressions[].createdBy` | string | Who created it: "human" or "agent". |
| `suppressions[].createdAt` | string | When it was created (RFC 3339). |
| `factCount` | integer | Number of active facts. |
| `openTodoCount` | integer | Number of open todos. |
| `callInProgress` | boolean | True when a call with this contact and persona is in progress right now (memory may change when it ends). |
```bash
curl "https://api.pingx.ai/memory/v1/contacts/CONTACTID/memory" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /memory/v1/contacts/{contactId}/messages
**ListRecentMessages** · needs `memory:read` (or write)
Returns a contact's most recent WhatsApp messages (both directions),
newest first. It is not per persona. A contact with no WhatsApp thread
returns an empty list. Read-only. Not paginated: pageSize bounds the
number of most-recent messages returned.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Maximum number of most-recent messages to return. <= 0 means 50; maximum 200. |
**Response** `ListRecentMessagesResponse`
| Field | Type | Description |
|---|---|---|
| `messages` | WhatsAppMessage[] | Messages, newest first. |
| `messages[].direction` | string | "in" (from the contact) or "out" (to the contact). |
| `messages[].body` | string | Message text. |
| `messages[].sentAt` | string | When it was sent (RFC 3339). |
```bash
curl "https://api.pingx.ai/memory/v1/contacts/CONTACTID/messages" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:amend
**AmendFact** · needs `memory:write`
Overwrites a fact's value in place (a human correction), keeping its id
and history (a human correction takes precedence over what the agent
learned). Idempotent: amending to the same value twice has the same
result. affected = 0 when it is not an active fact of this
contact+persona.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the fact (path parameter); must be > 0. |
| `factId` | string (int64) | Fact id (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `factValue` | string | The corrected value. Required. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/facts/FACTID:amend" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"factValue":"…"}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:forget
**ForgetFact** · needs `memory:write`
Soft-deletes one active fact (status becomes "forgotten", the row is
kept for audit) AND records a suppression for its factKey so the agent
does not learn it again. Reversible only by LiftSuppression (which lets
the key be learned afresh; the forgotten value itself is not restored).
NOT_FOUND / affected = 0 when it is not an active fact of this
contact+persona. Idempotent in effect: forgetting an already-forgotten
fact affects nothing.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the fact (path parameter); must be > 0. |
| `factId` | string (int64) | Fact id (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `reason` | string | Optional reason, stored on the suppression for audit. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/facts/FACTID:forget" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"reason":"…"}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}:renew
**RenewFact** · needs `memory:write`
Pushes a fact's expiry out to a new RFC 3339 time without touching its
value. expiresAt is required (INVALID_ARGUMENT when missing or not
RFC 3339). Idempotent. affected = 0 when the fact is not found.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the fact (path parameter); must be > 0. |
| `factId` | string (int64) | Fact id (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `expiresAt` | string | New expiry as an RFC 3339 timestamp. Required. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/facts/FACTID:renew" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"expiresAt":"…"}'
```
## GET /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}/provenance
**GetFactProvenance** · needs `memory:read` (or write)
Returns the provenance of one fact: the episode (call) it was learned in
and the most recent fact that contradicted it, if any. NOT_FOUND when the
fact does not belong to this contact and persona. Read-only.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the fact (path parameter); must be > 0. |
| `factId` | string (int64) | Fact id from GetContactMemory (path parameter); must be > 0. |
**Response** `GetFactProvenanceResponse`
| Field | Type | Description |
|---|---|---|
| `origin` | Episode | The episode the fact was learned in; unset when it has none. |
| `origin.id` | string (int64) | Numeric episode id. |
| `origin.sourceKind` | string | What the episode came from: "call" or "legacy". |
| `origin.sourceId` | string | Identifier of the source record. |
| `origin.channel` | string | Channel: e.g. "voice". |
| `origin.occurredAt` | string | When the interaction happened (RFC 3339). |
| `origin.summary` | string | Short summary of the interaction. |
| `origin.callId` | string (int64) | The call id when sourceKind is "call"; 0 otherwise. Use the voice API to read the call itself. |
| `mostRecentContradiction` | Fact | The most recent fact that contradicted this one; unset when none did. |
| `mostRecentContradiction.id` | string (int64) | Numeric fact id (use it in factId parameters). |
| `mostRecentContradiction.category` | string | Kind of knowledge: "preference" or "fact". |
| `mostRecentContradiction.factKey` | string | Stable key of what the fact is about, e.g. "preferred_language". |
| `mostRecentContradiction.factValue` | string | The remembered value. |
| `mostRecentContradiction.evidenceQuote` | string | Verbatim quote from the conversation that supports the fact; may be empty. |
| `mostRecentContradiction.confidence` | number | Model confidence from 0 to 1. |
| `mostRecentContradiction.verification` | string | How trustworthy the fact is: "stated" (the contact said it), "inferred", "unverified" or "human" (entered or corrected through this API/the app). |
| `mostRecentContradiction.observedAt` | string | When the fact was last observed (RFC 3339). |
| `mostRecentContradiction.expiresAt` | string | When the fact expires (RFC 3339); empty when open-ended. |
| `mostRecentContradiction.status` | string | Lifecycle: "active", "expired", "superseded" or "forgotten". |
| `mostRecentContradiction.pinned` | boolean | True when the fact is pinned (protected from automatic overwrite). |
| `mostRecentContradiction.contradictions` | integer | How many later observations contradicted this fact. |
| `mostRecentContradiction.originEpisodeId` | string (int64) | Id of the episode the fact was learned in (see GetFactProvenance); 0 if unknown. |
| `mostRecentContradiction.dataClassification` | string | Sensitivity: "general" or "sensitive". |
```bash
curl "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/facts/FACTID/provenance" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/memory:clear
**ClearForPersona** · needs `memory:write`
DESTRUCTIVE AND IRREVERSIBLE. HARD-deletes everything ONE persona holds
about the contact: facts, todos/obligations, do-not-learn rules and call
episodes. Other personas are untouched. Unlike EraseSubject it writes no
erasure marker, so the persona simply starts learning afresh on the next
interaction (a clean-slate reset, e.g. for testing). Requires
confirm = true. Returns the number of rows deleted in "affected".
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | The persona whose memory of the contact is hard-deleted (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `confirm` | boolean | Must be true, acknowledging that this cannot be undone. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/memory:clear" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"confirm":false}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/memory:forgetAll
**ForgetAllForPersona** · needs `memory:write`
DESTRUCTIVE AND IRREVERSIBLE through this API. Soft-deletes EVERY active
fact one persona holds about the contact (status "forgotten", rows kept
for audit); there is no bulk undo. Requires confirm = true. Returns in
"affected" how many facts were forgotten. Other personas' memory of the
contact is untouched.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | The persona whose facts about the contact are forgotten (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `confirm` | boolean | Must be true, acknowledging that this cannot be undone through the API. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/memory:forgetAll" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"confirm":false}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/suppressions:lift
**LiftSuppression** · needs `memory:write`
Lifts a do-not-learn suppression so the given factKey can be learned
again (the opposite of what ForgetFact records). Idempotent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona the suppression applies to (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `factKey` | string | The suppressed fact key to release (see Suppression.factKey). Required. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/suppressions:lift" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"factKey":"…"}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/todos/{todoId}:close
**CloseTodo** · needs `memory:write`
Marks an open todo as done (closed by a human), recording the evidence
(required). Idempotent: closing an already-closed todo affects nothing.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the todo (path parameter); must be > 0. |
| `todoId` | string (int64) | Todo id (path parameter); must be > 0. |
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `evidence` | string | Free-text evidence/reason recorded as the closing evidence. Required (non-empty). |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/todos/TODOID:close" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"evidence":"…"}'
```
## POST /memory/v1/contacts/{contactId}/personas/{agentId}/todos/{todoId}:reopen
**ReopenTodo** · needs `memory:write`
Reopens a closed todo (the inverse of CloseTodo). Idempotent.
**Path parameters**
| Name | Type | Description |
|---|---|---|
| `contactId` | string | UUID of the contact (path parameter). |
| `agentId` | string (int64) | Persona that holds the todo (path parameter); must be > 0. |
| `todoId` | string (int64) | Todo id (path parameter); must be > 0. |
**Response** `WriteResult`
| Field | Type | Description |
|---|---|---|
| `affected` | integer | Number of rows the operation changed. 0 means nothing matched (for example the fact was already forgotten, or does not exist for this contact/persona); for the bulk operations it is the count of facts forgotten or rows deleted. |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/contacts/CONTACTID/personas/AGENTID/todos/TODOID:reopen" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /memory/v1/test-contacts
**ListTestContacts** · needs `memory:read` (or write)
Lists the organization's test contacts: synthetic contacts (source
"test") used to try the agents' memory without touching real customers.
Read-only.
**Response** `ListTestContactsResponse`
| Field | Type | Description |
|---|---|---|
| `contacts` | TestContact[] | |
| `contacts[].contactId` | string | The contact's UUID. |
| `contacts[].name` | string | Display name. |
| `contacts[].createdAt` | string | When it was created (RFC 3339). |
```bash
curl "https://api.pingx.ai/memory/v1/test-contacts" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## POST /memory/v1/test-contacts
**CreateTestContact** · needs `memory:write`
Creates a synthetic test contact (no phone number, hidden from the
regular contact list unless includeTest is set). NOT idempotent: every
call creates a new contact, even with the same name.
**Request body** (JSON)
| Field | Type | Description |
|---|---|---|
| `name` | string | Display name for the test contact. Required, at most 120 characters. |
**Response** `CreateTestContactResponse`
| Field | Type | Description |
|---|---|---|
| `contact` | TestContact | The created test contact. |
| `contact.contactId` | string | The contact's UUID. |
| `contact.name` | string | Display name. |
| `contact.createdAt` | string | When it was created (RFC 3339). |
```bash
curl -X POST "https://api.pingx.ai/memory/v1/test-contacts" \
-H "Authorization: Bearer $PINGX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"…"}'
```
---
# Billing reference
> Every Billing endpoint with parameters, request and response fields, required scope and a curl example.
Every Billing endpoint. Base URL `https://api.pingx.ai`; send `Authorization: Bearer `. Read endpoints need `billing:read` (or `:write`), write endpoints need `billing:write`; the bare `billing` scope grants both. See [Authentication and conventions](https://docs.pingx.ai/authentication.md). Machine-readable: [openapi.json](/openapi.json).
**4 endpoints**
| Method | Path | Operation | Scope |
|---|---|---|---|
| `GET` | `/billing/v1/account` | GetBilling | read |
| `GET` | `/billing/v1/credit-changes` | ListCreditChanges | read |
| `GET` | `/billing/v1/usage/events` | ListUsage | read |
| `GET` | `/billing/v1/usage/summary` | GetUsageSummary | read |
## GET /billing/v1/account
**GetBilling** · needs `billing:read` (or write)
Returns the organization's billing mode and wallet balance. When billing
has not been set up for the organization, configured = false and the
other fields are their zero values. Read-only and idempotent.
**Response** `GetBillingResponse`
| Field | Type | Description |
|---|---|---|
| `configured` | boolean | False when billing is not set up for this organization; the remaining fields are then zero values. |
| `mode` | enum | The billing mode. One of: `MODE_UNSPECIFIED`, `MODE_PREPAID`, `MODE_POSTPAID`, `MODE_LIMITED_POSTPAID`. |
| `balanceMillicredits` | string (int64) | Current wallet balance in millicredits (1 credit = 1000). May be negative for postpaid modes. |
| `negativeCreditLimitMillicredits` | string (int64) | For MODE_LIMITED_POSTPAID: how far below zero the balance may go, as a positive number of millicredits. 0 for other modes. |
```bash
curl "https://api.pingx.ai/billing/v1/account" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /billing/v1/credit-changes
**ListCreditChanges** · needs `billing:read` (or write)
Lists the credit changes recorded on the wallet by PingX (credits added
and credits removed), newest first, each with the balance after the
change. Does not include usage charges (see ListUsage). Read-only.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `pageSize` | integer | Maximum changes per page. <= 0 means 25; maximum 100. |
| `pageToken` | string | Opaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT. |
**Response** `ListCreditChangesResponse`
| Field | Type | Description |
|---|---|---|
| `creditChanges` | CreditChange[] | Credit changes, newest first. |
| `creditChanges[].id` | string (int64) | Monotonic id; newer changes have larger ids. |
| `creditChanges[].kind` | enum | Whether credits were added or removed. One of: `CREDIT_CHANGE_KIND_UNSPECIFIED`, `CREDIT_CHANGE_KIND_CREDIT`, `CREDIT_CHANGE_KIND_DEBIT`. |
| `creditChanges[].amountMillicredits` | string (int64) | Size of the change in millicredits (always positive; see kind for the direction). |
| `creditChanges[].balanceAfterMillicredits` | string (int64) | Wallet balance right after this change, in millicredits. |
| `creditChanges[].description` | string | The note PingX recorded with the change. |
| `creditChanges[].createdAt` | string | When the change was made (RFC 3339). |
| `nextPageToken` | string | Token for the next (older) page; empty when there are no more. |
```bash
curl "https://api.pingx.ai/billing/v1/credit-changes" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /billing/v1/usage/events
**ListUsage** · needs `billing:read` (or write)
Lists individual usage events — charges, refunds and refused (denied)
attempts — newest first, optionally filtered to one operation. Metering
that did not charge anything is not included. Same availability errors as
GetUsageSummary. Read-only.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `operation` | string | Only events of this operation key (see OperationUsage.operation); empty means every operation. |
| `pageSize` | integer | Maximum events per page. <= 0 means 25; maximum 100. |
| `pageToken` | string | Opaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT. |
**Response** `ListUsageResponse`
| Field | Type | Description |
|---|---|---|
| `events` | UsageEvent[] | Usage events, newest first. |
| `events[].id` | string (int64) | Monotonic id; newer events have larger ids. |
| `events[].operation` | string | Operation key, e.g. "whatsapp.message". |
| `events[].name` | string | Display name of the operation. |
| `events[].unit` | string | Unit of quantity. |
| `events[].details` | object | Operation-specific details, e.g. country and message category. |
| `events[].quantity` | string (int64) | Quantity in the operation's unit. |
| `events[].amountMillicredits` | string (int64) | Credits involved in millicredits. |
| `events[].outcome` | enum | Whether it was charged, refunded or denied. One of: `USAGE_OUTCOME_UNSPECIFIED`, `USAGE_OUTCOME_CHARGED`, `USAGE_OUTCOME_REFUNDED`, `USAGE_OUTCOME_DENIED`. |
| `events[].createdAt` | string | When it happened (RFC 3339). |
| `nextPageToken` | string | Token for the next (older) page; empty when there are no more. |
```bash
curl "https://api.pingx.ai/billing/v1/usage/events" \
-H "Authorization: Bearer $PINGX_API_KEY"
```
## GET /billing/v1/usage/summary
**GetUsageSummary** · needs `billing:read` (or write)
Returns credits used over the last N days broken down by operation (for
example "WhatsApp message", voice minutes), with totals and the number of
refused attempts. FAILED_PRECONDITION when usage reporting is not
available for the deployment; UNAVAILABLE when it is temporarily down
(retry). Read-only and idempotent.
**Query parameters**
| Name | Type | Description |
|---|---|---|
| `days` | integer | Lookback window in days ending now. <= 0 means 30; maximum 366. |
**Response** `GetUsageSummaryResponse`
| Field | Type | Description |
|---|---|---|
| `operations` | OperationUsage[] | Usage per operation. |
| `operations[].operation` | string | Stable operation key, e.g. "whatsapp.message". Use it as the filter in ListUsage. |
| `operations[].name` | string | Display name, e.g. "WhatsApp message". |
| `operations[].unit` | string | Unit of quantity, e.g. "message" or "minute". |
| `operations[].operations` | string (int64) | Number of charged operations in the window. |
| `operations[].quantity` | string (int64) | Total quantity in the operation's unit. |
| `operations[].amountMillicredits` | string (int64) | Credits charged in the window, in millicredits. |
| `operations[].denied` | string (int64) | Attempts that were refused (for example for lack of credits); nothing was sent or charged for them. |
| `totalMillicredits` | string (int64) | Total credits charged across all operations, in millicredits. |
| `days` | integer | The effective lookback window in days after defaulting/clamping. |
```bash
curl "https://api.pingx.ai/billing/v1/usage/summary" \
-H "Authorization: Bearer $PINGX_API_KEY"
```