Skip to content

Campaigns

Campaigns automate bulk actions over an audience of passes — push notifications, template switches, custom-field updates, reward grants, and tier assignments. An audience is defined either by a saved segment (segment_id) or a manual list of client IDs (manual_client_ids); the two are mutually exclusive.

Marketing consent (GDPR): every campaign send is treated as marketing-purpose, so audience resolution — manual and segment alike — excludes clients whose marketing_consent is not true. The same gate applies to audience preview/count, so what you see is what will be targeted. Transactional flows (pass delivery emails, pairing codes) do not run through campaigns and are unaffected.

Auth: All campaign endpoints require a Bearer token. Workspace-scoped routes (/workspace/:workspaceId/...) and entity routes (/campaigns/:id/..., /campaign-actions/:id/...) are guarded so the caller must be a member of the owning workspace. The calendar route resolves the workspace from the workspace_id query parameter.

bash
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

Campaign Lifecycle

StatusDescription
draftCampaign is being configured
scheduledCampaign is scheduled to run at a future time
activeCampaign is currently executing
completedCampaign finished executing all actions
cancelledCampaign was cancelled before completion

Action Types

TypeDescription
push_notificationSend a push notification to passes
template_switchSwitch passes to a different template (optionally temporary via duration_days)
custom_field_updateUpdate custom field values on passes
give_rewardIssue one or more rewards
assign_tierAssign a loyalty tier (optionally temporary via duration_days)

Campaign Structure

typescript
interface Campaign {
  id: string;
  workspace_id: string;
  name: string;
  description?: string;
  status: 'draft' | 'scheduled' | 'active' | 'completed' | 'cancelled';
  scheduled_at?: string;
  started_at?: string;
  completed_at?: string;
  segment_id?: string;          // mutually exclusive with manual_client_ids
  manual_client_ids?: string[]; // mutually exclusive with segment_id
}

Reference Pages

  • CRUD & listing — list, create, get, update, delete, calendar, summary, duplicate
  • Lifecycle — schedule, start-now, complete, cancel
  • Actions — manage and execute campaign actions
  • Statistics & audience — preview, count, events, errors, audience, statistics, reachability

Endpoint Index

MethodEndpointPage
GET/wallethero-api/workspace/:workspaceId/campaignscrud
POST/wallethero-api/workspace/:workspaceId/campaignscrud
GET/wallethero-api/campaigns/calendarcrud
GET/wallethero-api/campaigns/:idcrud
PATCH/wallethero-api/campaigns/:idcrud
DELETE/wallethero-api/campaigns/:idcrud
POST/wallethero-api/campaigns/:id/duplicatecrud
GET/wallethero-api/workspace/:workspaceId/campaigns/summarycrud
POST/wallethero-api/campaigns/:id/schedulelifecycle
POST/wallethero-api/campaigns/:id/start-nowlifecycle
POST/wallethero-api/campaigns/:id/completelifecycle
POST/wallethero-api/campaigns/:id/cancellifecycle
GET/wallethero-api/campaigns/:id/actionsactions
POST/wallethero-api/campaigns/:id/actionsactions
POST/wallethero-api/campaigns/:id/actions/reorderactions
PATCH/wallethero-api/campaign-actions/:idactions
DELETE/wallethero-api/campaign-actions/:idactions
POST/wallethero-api/campaign-actions/:id/executeactions
POST/wallethero-api/campaigns/:id/execute-allactions
GET/wallethero-api/campaigns/:id/previewstatistics
GET/wallethero-api/campaigns/:id/countstatistics
GET/wallethero-api/campaigns/:id/eventsstatistics
GET/wallethero-api/campaigns/:id/errorsstatistics
GET/wallethero-api/campaigns/:id/audiencestatistics
GET/wallethero-api/campaigns/:id/statisticsstatistics
GET/wallethero-api/campaigns/:id/unreachable-audiencestatistics
GET/wallethero-api/campaigns/:id/action-statsstatistics
POST/wallethero-api/workspace/:workspaceId/audience-reachabilitystatistics

SDK Example

typescript
import { WalletHero } from "@wallethero/sdk";
const wh = new WalletHero({ apiToken: "YOUR_TOKEN" });

// Create a campaign
const { data: campaign } = await wh.campaigns.create({
  workspace_id: "WORKSPACE_ID",
  name: "Winter Promo Push",
  segment_id: "SEGMENT_ID",
});

// Add a push notification action
await wh.campaigns.addAction(campaign.id, {
  action_type: "push_notification",
  action_config: { notification_message: "Earn double points this weekend!" },
});

// Preview the audience, then start
const preview = await wh.campaigns.previewAudience(campaign.id);
console.log(`Targeting ${preview.total} passes`);
await wh.campaigns.startNow(campaign.id);

WalletHero Documentation