Kraiter
SDK Reference

Campaigns

SDK reference for creating and managing campaigns in Kraiter.

The kraiter.campaigns namespace provides methods for organising your email marketing efforts. A campaign groups related sequences and templates together, making it easier to manage and report on multi-step marketing initiatives.

create

Creates a new campaign.

const campaign = await kraiter.campaigns.create({
  name: 'Q1 Product Launch',
  description: 'Announcement sequence and follow-up emails for the January product launch.',
});

Parameters

ParameterTypeRequiredDescription
namestringYesA human-readable name for the campaign.
descriptionstringNoA longer description of the campaign's purpose.

Returns

Promise<Campaign> — the newly created campaign object.

Errors

CodeWhen
VALIDATION_ERRORThe campaign name is missing or invalid.

get

Retrieves a campaign by ID.

const campaign = await kraiter.campaigns.get('cmp_abc123');

if (campaign) {
  console.log(campaign.name, campaign.status);
}

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.

Returns

Promise<Campaign | null> — the campaign object, or null if not found.


list

Lists campaigns with cursor-based pagination. Optionally filter by status.

const page = await kraiter.campaigns.list({ status: 'active' });

for (const campaign of page.items) {
  console.log(campaign.campaignId, campaign.name, campaign.status);
}

Parameters

ParameterTypeRequiredDescription
statusstringNoFilter by status ("draft", "active", "paused", "completed", "archived").
limitnumberNoMaximum items per page.
cursorstringNoPagination cursor from a previous response's nextCursor.

Returns

Promise<{ items: Campaign[]; nextCursor?: string }> — a page of campaign objects.


update

Updates an existing campaign. Only the fields you include are changed.

const updated = await kraiter.campaigns.update('cmp_abc123', {
  name: 'Q1 Product Launch (Updated)',
  status: 'active',
});

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID to update.
namestringNoUpdated campaign name.
descriptionstringNoUpdated description.
statusstringNoUpdated status ("draft", "active", "paused", "completed", "archived").

Returns

Promise<Campaign> — the updated campaign object.

Errors

CodeWhen
NOT_FOUNDNo campaign exists with this ID.
VALIDATION_ERRORThe updated fields are invalid.

delete

Permanently deletes a campaign. This does not delete the sequences or templates associated with it — it only removes the campaign grouping.

await kraiter.campaigns.delete('cmp_abc123');

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID to delete.

Returns

Promise<void>

Errors

CodeWhen
NOT_FOUNDNo campaign exists with this ID.

addSequence

Associates a sequence with the campaign.

const campaign = await kraiter.campaigns.addSequence('cmp_abc123', 'seq_onboarding');
console.log(campaign.sequenceIds);

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
sequenceIdstringYesThe sequence ID to add.

Returns

Promise<Campaign> — the updated campaign object.

Errors

CodeWhen
NOT_FOUNDThe campaign or sequence does not exist.
CONFLICTThe sequence is already associated with this campaign.

removeSequence

Removes a sequence from the campaign. This does not delete the sequence itself.

const campaign = await kraiter.campaigns.removeSequence('cmp_abc123', 'seq_onboarding');

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
sequenceIdstringYesThe sequence ID to remove.

Returns

Promise<Campaign> — the updated campaign object.

Errors

CodeWhen
NOT_FOUNDThe campaign or sequence association does not exist.

addTemplate

Associates a template with the campaign.

const campaign = await kraiter.campaigns.addTemplate('cmp_abc123', 'tmpl_launch_announcement');
console.log(campaign.templateIds);

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
templateIdstringYesThe template ID to add.

Returns

Promise<Campaign> — the updated campaign object.

Errors

CodeWhen
NOT_FOUNDThe campaign or template does not exist.
CONFLICTThe template is already associated with this campaign.

removeTemplate

Removes a template from the campaign. This does not delete the template itself.

const campaign = await kraiter.campaigns.removeTemplate('cmp_abc123', 'tmpl_launch_announcement');

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
templateIdstringYesThe template ID to remove.

Returns

Promise<Campaign> — the updated campaign object.

Errors

CodeWhen
NOT_FOUNDThe campaign or template association does not exist.