Skip to main content
GET
/
analytics
/
campaigns
/
{campaignId}
/
orders
List Campaign Orders
curl --request GET \
  --url https://api-ai.textyess.com/analytics/campaigns/{campaignId}/orders \
  --header 'x-auth-token: <api-key>'
{
  "data": [
    {
      "_id": "507f1f77bcf86cd799439020",
      "cms_id": "ord_12345",
      "order_number": "1001",
      "total": 89.99,
      "items_number": 2,
      "paid": true,
      "createdAt": "2024-01-15T14:30:00.000Z",
      "conversation": {
        "_id": "507f1f77bcf86cd799439021",
        "phone": "+393331234567"
      }
    }
  ],
  "pagination": {
    "total": 120,
    "perPage": 10,
    "page": 0
  }
}

Overview

The list campaign orders endpoint returns a paginated list of orders attributed to a specific campaign. Use this to see which orders were driven by a given campaign, with optional date range and sorting.

Authentication

This endpoint requires a valid JWT token in the x-auth-token header. You can find your token in the Developers section:
x-auth-token: your_jwt_token

Path Parameters

campaignId
string
required
The unique identifier of the campaign (MongoDB ObjectId). Only orders attributed to this campaign are returned.

Query Parameters

from
string
Start date for filtering orders (ISO 8601).
to
string
End date for filtering orders (ISO 8601).
sortDirection
string
Sort direction: 1 for ascending, -1 for descending. Defaults to -1.
sortKey
string
Field to sort by: createdAt, name, title, total_messages, cost, revenue, orders_number, campaign_conversion_rate, average_cart, roas.
page
string
required
Page number (0-based). Use 0 for the first page.
perPage
string
required
Number of items per page. Must be at least 1.

Response

The response has two top-level keys: data (array of order objects) and pagination. Each order in data includes order fields (e.g. cms_id, order_number, total, items_number, paid, createdAt) and a populated conversation when available.
data
array
Array of order documents (TextYess-attributed orders for this campaign).
pagination
object
Pagination metadata: total (total count), perPage, page.
{
  "data": [
    {
      "_id": "507f1f77bcf86cd799439020",
      "cms_id": "ord_12345",
      "order_number": "1001",
      "total": 89.99,
      "items_number": 2,
      "paid": true,
      "createdAt": "2024-01-15T14:30:00.000Z",
      "conversation": {
        "_id": "507f1f77bcf86cd799439021",
        "phone": "+393331234567"
      }
    }
  ],
  "pagination": {
    "total": 120,
    "perPage": 10,
    "page": 0
  }
}