Get Campaigns
The Get Campaigns API lets you fetch campaigns with advanced filtering, search, sorting, and pagination.
Endpoint
GET /api/campaign
Request Example
- cURL
- Node.js
curl --location 'http://localhost:3000/api/campaign?page=1&limit=200&search=TEST&direction=%22%27&column=%27%27%27%27&status=%27%27%27&channel=voice&dateFrom=12%2F11%2F2022&dateTo=11%2F08%2F2024' \\ --header 'x-user-id: 648b80839b30ddb88cdbab11'
import fetch from "node-fetch";
const response = await fetch("http://localhost:3000/api/campaign?page=1&limit=200&search=TEST&direction="'&column=''''&status='''&channel=voice&dateFrom=12/11/2022&dateTo=11/08/2024
", {
headers: {
"x-user-id": "648b80839b30ddb88cdbab11"
}
});
const data = await response.json();
console.log(data);
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | ✅ | Page number (pagination) |
limit | number | ✅ | Number of results per page |
search | string | ❌ | Search term (e.g., campaign name) |
direction | string | ❌ | Sorting direction (asc / desc) |
column | string | ❌ | Column name to sort by |
status | string | ❌ | Campaign status (active, paused, completed) |
channel | string | ✅ | Channel type (sms, email, voice) |
dateFrom | string | ❌ | Start date (MM/DD/YYYY) |
dateTo | string | ❌ | End date (MM/DD/YYYY) |
Example Response
{ "result": "success", "status": 200, "message": "Campaigns retrieved successfully", "data": [ { "id": "6728e4e9f30ba95e72a66c23", "name": "Voice Outreach Campaign", "channel": ["voice"], "status": "active", "createdAt": "2023-12-11T10:15:30.000Z" } ], "pagination": { "page": 1, "limit": 200, "total": 15 } }
Response Fields
| Field | Type | Description |
|---|---|---|
result | string | API call status (success / error) |
status | number | HTTP-like status code |
message | string | Info about the API action |
data | array | List of campaign objects |
id | string | Unique campaign identifier |
name | string | Campaign name |
channel | array | Channels included (email, sms, voice) |
status | string | Current campaign status |
createdAt | datetime | When the campaign was created |
pagination | object | Page, limit, and total records |
Best Practice
For better performance, always use page and limit. Avoid requesting large datasets in a single API call.