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');
console.log(campaign.name, campaign.status);

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.

Returns

Promise<Campaign> — the campaign object.

Errors

CodeWhen
NOT_FOUNDNo campaign exists with this ID.

list

Lists all campaigns. Returns an async iterator.

for await (const campaign of kraiter.campaigns.list()) {
  console.log(campaign.id, campaign.name, campaign.status);
}

Parameters

ParameterTypeRequiredDescription
cursorstringNoPagination cursor.
limitnumberNoMaximum items per page.

Returns

AsyncIterable<Campaign> — an async iterator 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 (e.g. "draft", "active", "paused", "completed").

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.

await kraiter.campaigns.addSequence('cmp_abc123', 'seq_onboarding');

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
sequenceIdstringYesThe sequence ID to add.

Returns

Promise<void>

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.

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

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
sequenceIdstringYesThe sequence ID to remove.

Returns

Promise<void>

Errors

CodeWhen
NOT_FOUNDThe campaign or sequence association does not exist.

addTemplate

Associates a template with the campaign.

await kraiter.campaigns.addTemplate('cmp_abc123', 'tmpl_launch_announcement');

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
templateIdstringYesThe template ID to add.

Returns

Promise<void>

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.

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

Parameters

ParameterTypeRequiredDescription
idstringYesThe campaign ID.
templateIdstringYesThe template ID to remove.

Returns

Promise<void>

Errors

CodeWhen
NOT_FOUNDThe campaign or template association does not exist.