Skip to content

Campaign Results API (/v1/campaigns)

The Campaign Results API in DEP provides read-only, server-to-server access using an API Key (Authorization: Bearer <API_KEY>) to reconcile campaign delivery outcomes without relying on webhooks. These endpoints allow external systems to list campaigns, list campaign runs along with the same precomputed summary counters shown in the portal, and inspect per-recipient delivery statuses. All data is automatically scoped to the tenant account that owns the API Key.

Include the standard Bearer API Key header on every request:

Authorization: Bearer $API_KEY

The campaign results endpoints use your standard account API key and do not require any additional scope.

Rate Limit: Up to 60 requests per minute per API key across the campaign results endpoints (/v1/campaigns, /v1/campaigns/{campaign_id}/runs, and /v1/campaign-runs/{run_id}/recipients). When this limit is exceeded, the server responds with HTTP 429 Too Many Requests.

Returns campaigns belonging to your account ordered from newest to oldest (created_at DESC, id DESC) using keyset cursor pagination.

ParameterTypeDefaultDescription
afterstring—Next-page cursor ("<rfc3339>|<uuid>") taken from next_cursor in the previous response
limitinteger50Page size (automatically clamped to 1..=100)
Terminal window
curl -sS "https://messaging.cpaas.id/v1/campaigns?limit=50" \
-H "Authorization: Bearer $API_KEY"
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000001",
"name": "Year-End Promo",
"status": "active",
"created_at": "2026-11-10T08:00:00Z"
}
],
"has_more": true,
"next_cursor": "2026-11-10T08:00:00.000000Z|00000000-0000-4000-8000-000000000001"
}

Important: the next_cursor of the campaign and run lists contains a | character and must be URL-encoded when passed as the after parameter (for example with curl -G --data-urlencode "after=$CURSOR").

2. List Campaign Runs (GET /v1/campaigns/{campaign_id}/runs)

Section titled “2. List Campaign Runs (GET /v1/campaigns/{campaign_id}/runs)”

Returns runs for a specific campaign (created_at DESC, id DESC) together with precomputed delivery and customer reply counters.

Path & Query Parameters (GET /v1/campaigns/{campaign_id}/runs)

Section titled “Path & Query Parameters (GET /v1/campaigns/{campaign_id}/runs)”
ParameterLocationTypeDefaultDescription
campaign_idpathUUIDRequiredCampaign UUID
afterquerystring—Next-page cursor ("<rfc3339>|<uuid>") from next_cursor
limitqueryinteger50Page size (automatically clamped to 1..=100)

Example Request (GET /v1/campaigns/{campaign_id}/runs)

Section titled “Example Request (GET /v1/campaigns/{campaign_id}/runs)”
Terminal window
curl -sS "https://messaging.cpaas.id/v1/campaigns/00000000-0000-4000-8000-000000000001/runs?limit=20" \
-H "Authorization: Bearer $API_KEY"

Example Response (GET /v1/campaigns/{campaign_id}/runs)

Section titled “Example Response (GET /v1/campaigns/{campaign_id}/runs)”
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000002",
"status": "completed",
"scheduled_for": "2026-11-10T08:00:00Z",
"started_at": "2026-11-10T08:00:02Z",
"completed_at": "2026-11-10T08:15:10Z",
"created_at": "2026-11-10T08:00:00Z",
"counts": {
"total": 1000,
"sent": 980,
"delivered": 950,
"read": 610,
"failed": 20,
"replied": 45
},
"stats_computed_at": "2026-11-10T08:16:00Z",
"stats_final": false
}
],
"has_more": false,
"next_cursor": null
}

How counts Relates to Portal Numbers & What null Means

Section titled “How counts Relates to Portal Numbers & What null Means”
  • Portal Alignment: The counts object (total, sent, delivered, read, failed, replied) is read directly from the same precomputed campaign run statistics snapshot used by the DEP portal campaign run list and report views.
  • When counts is null: If a run was just created or scheduled and its statistics snapshot has not been computed yet by the background scheduler, counts, stats_computed_at, and stats_final are returned as null. This endpoint never triggers a synchronous table scan so responses remain fast and predictable.
  • Freshness (stats_computed_at & stats_final): stats_computed_at indicates when the snapshot was last refreshed (UTC). While a run is active or still within the read-receipt reconciliation window, stats_final is false and counters continue refreshing periodically until finalized (stats_final: true).

3. List Campaign Run Recipients (GET /v1/campaign-runs/{run_id}/recipients)

Section titled “3. List Campaign Run Recipients (GET /v1/campaign-runs/{run_id}/recipients)”

Returns per-recipient delivery outcomes for a campaign run ordered by phone number (recipient_e164 ASC), using an opaque cursor token valid for 1 hour.

Path & Query Parameters (GET /v1/campaign-runs/{run_id}/recipients)

Section titled “Path & Query Parameters (GET /v1/campaign-runs/{run_id}/recipients)”
ParameterLocationTypeDefaultDescription
run_idpathUUIDRequiredCampaign run UUID
statusquerystring—Cumulative status filter: pending, sent, delivered, read, failed, or replied
afterquerystring—Opaque cursor token from next_cursor in the previous response (valid for 1 hour)
limitqueryinteger100Page size (automatically clamped to 1..=1000)

Example Request (GET /v1/campaign-runs/{run_id}/recipients)

Section titled “Example Request (GET /v1/campaign-runs/{run_id}/recipients)”
Terminal window
curl -sS "https://messaging.cpaas.id/v1/campaign-runs/00000000-0000-4000-8000-000000000002/recipients?status=failed&limit=100" \
-H "Authorization: Bearer $API_KEY"

Example Response (GET /v1/campaign-runs/{run_id}/recipients)

Section titled “Example Response (GET /v1/campaign-runs/{run_id}/recipients)”
{
"data": [
{
"phone": "+6281234567890",
"message_id": "wamid.HBgNNjI4MTIzNDU2Nzg5MBUCABIYFDNB",
"status": "failed",
"error_code": "131026",
"error_title": "Message undeliverable",
"sent_at": "2026-11-10T08:01:12Z",
"delivered_at": null,
"read_at": null,
"failed_at": "2026-11-10T08:01:15Z"
}
],
"has_more": false,
"next_cursor": null
}

On each recipient item in data, the status field is mutually exclusive and reports the highest delivery progress reached by that recipient according to the following precedence:

Row status ValueResolution Rule (Highest Progress Wins)
readread_at is not null
deliveredread_at is null and delivered_at is not null
failedread_at and delivered_at are null, and failed_at is not null
sentOnly sent_at is not null (not yet delivered, read, or failed)
pendingsent_at, delivered_at, read_at, and failed_at are all null

By contrast, the status= query parameter is cumulative so that the total number of rows matching each filter equals the corresponding counter in the run’s counts object:

status= Filter ValueMatching Row PredicateMatches counts Field
pendingsent_at IS NULL and failed_at IS NULLno equivalent counter
sentsent_at IS NOT NULL (includes rows later delivered or read)counts.sent
delivereddelivered_at IS NOT NULL (includes rows later read)counts.delivered
readread_at IS NOT NULLcounts.read
failedfailed_at IS NOT NULLcounts.failed
repliedRecipient replied to the campaign (first_reply_at IS NOT NULL)counts.replied

Pagination Rules & Windowed Filtered Scans (Important)

Section titled “Pagination Rules & Windowed Filtered Scans (Important)”

All three endpoints return the same pagination envelope:

  • data: Array of items for the current page.
  • has_more: Boolean indicating whether additional pages remain.
  • next_cursor: Cursor string to pass as after on the next request, or null when has_more is false.

Short or Empty Pages When Filtering with status=:

To keep database queries fast on multi-million-recipient runs without performing unbounded scans, filtered /recipients requests inspect at most 10,000 primary-key rows per call:

  • If fewer than limit matching rows (or 0 matching rows) appear within the 10,000-row scan window, the API returns the matching rows found in that window (which may be shorter than limit or an empty [] array) together with has_more: true and a next_cursor advancing past the 10,000-row window.
  • Clients must keep following next_cursor until next_cursor is null (has_more: false), and must not stop early merely because data is empty or shorter than limit.
Terminal window
CURSOR=""
while :; do
URL="https://messaging.cpaas.id/v1/campaign-runs/$RUN_ID/recipients?status=failed&limit=500"
if [ -n "$CURSOR" ]; then
URL="${URL}&after=${CURSOR}"
fi
RESP=$(curl -sS "$URL" -H "Authorization: Bearer $API_KEY")
echo "$RESP" | jq -c '.data[]'
NEXT=$(echo "$RESP" | jq -r '.next_cursor // empty')
if [ -z "$NEXT" ]; then
break
fi
CURSOR="$NEXT"
done

message_id Visibility Policy & Customer PII Masking

Section titled “message_id Visibility Policy & Customer PII Masking”
  • message_id Visibility: The message_id field contains the channel provider’s message identifier (such as the WhatsApp wamid). It respects your account’s provider message ID visibility policy (the same account setting that governs the other messaging APIs and portal exports). For accounts where provider message IDs are hidden, or for rows not yet sent (pending) or failed prior to provider submission, message_id is null. When customer PII masking is enabled, message_id is always null because a WhatsApp message id embeds the recipient number.
  • Phone Number Masking (PII Masking): When customer PII masking is enabled for your account, the phone field in /recipients responses is automatically masked (for example, +62812•••••890). Recipient pagination cursors (next_cursor) are opaque random tokens stored server-side, so raw phone numbers are never exposed in cursor strings.
HTTP StatusCause & Resolution
400 Bad RequestMalformed after cursor, expired (> 1 hour) or mismatched recipient cursor token, or an unsupported status filter value (allowed: pending, sent, delivered, read, failed, replied).
401 UnauthorizedMissing Authorization: Bearer <API_KEY> header, invalid token format, or inactive/expired API key.
403 ForbiddenThe requested campaign_id or run_id exists but belongs to another account.
404 Not FoundThe requested campaign_id or run_id does not exist.
429 Too Many RequestsExceeded the 60 requests/minute limit for this API key. Wait before retrying.