Skip to content

Campaign

client.campaign manages marketing campaigns and their associated touchpoints — the individual interaction points (messages, actions) that make up a campaign sequence.


Schema

Campaign

FieldTypeDescription
_idstringUnique campaign ID
namestringCampaign display name
statusstring?Campaign status (e.g. draft, active, completed)
channel_typestring?Channel type this campaign runs on
created_atstring?ISO 8601 creation timestamp
updated_atstring?ISO 8601 last-updated timestamp

Touchpoint

FieldTypeDescription
_idstringUnique touchpoint ID
namestring?Touchpoint display name
typestring?Touchpoint type
campaign_idstring?Parent campaign ID
created_atstring?ISO 8601 creation timestamp

CreateCampaignInput

FieldTypeRequiredDescription
namestringCampaign name
channel_typestringChannel type (e.g. whatsapp, email)

CreateTouchpointInput

FieldTypeRequiredDescription
namestringTouchpoint name
typestringTouchpoint type
campaign_idstringParent campaign ID
messagestring | objectMessage payload

Methods

Campaign

MethodTypeScriptPythonDescription
List campaignslistlistList all campaigns
Get campaigngetgetGet a campaign by ID
Create campaigncreatecreateCreate a new campaign
Delete campaigndeletedeleteDelete a campaign

Touchpoint

MethodTypeScriptPythonDescription
List touchpointslistTouchpointslist_touchpointsList all touchpoints
Get touchpointgetTouchpointget_touchpointGet a touchpoint by ID
Create touchpointcreateTouchpointcreate_touchpointAdd a touchpoint to a campaign
Update touchpointupdateTouchpointupdate_touchpointUpdate a touchpoint
Delete touchpointdeleteTouchpointdelete_touchpointRemove a touchpoint
Validate touchpointvalidateTouchpointvalidate_touchpointValidate touchpoint configuration

list / list

const { data: campaigns } = await client.campaign.list();
for (const c of campaigns) {
console.log(c._id, c.name, c.status);
}

create / create

const campaign = await client.campaign.create({
name: "Q3 Re-engagement",
channel_type: "whatsapp",
});
console.log(campaign._id);

get / get

const campaign = await client.campaign.get("campaign_id");
console.log(campaign._id, campaign.name, campaign.status);

delete / delete

await client.campaign.delete("campaign_id");

createTouchpoint / create_touchpoint

const touchpoint = await client.campaign.createTouchpoint({
name: "Welcome Message",
type: "message",
campaign_id: "campaign_id",
message: { text: "Hi! Welcome to our service." },
});

updateTouchpoint / update_touchpoint

const updated = await client.campaign.updateTouchpoint("touchpoint_id", {
name: "Updated Welcome Message",
message: { text: "Hi! Great to have you here." },
});

getTouchpoint / get_touchpoint

const touchpoint = await client.campaign.getTouchpoint("touchpoint_id");
console.log(touchpoint._id, touchpoint.name);

deleteTouchpoint / delete_touchpoint

await client.campaign.deleteTouchpoint("touchpoint_id");

validateTouchpoint / validate_touchpoint

Check whether a touchpoint is correctly configured before activating the campaign.

const result = await client.campaign.validateTouchpoint({
touchpoint_id: "touchpoint_id",
});
if (!result.valid) {
console.error("Validation errors:", result.errors);
}