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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A human-readable name for the campaign. |
description | string | No | A longer description of the campaign's purpose. |
Returns
Promise<Campaign> — the newly created campaign object.
Errors
| Code | When |
|---|---|
VALIDATION_ERROR | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID. |
Returns
Promise<Campaign> — the campaign object.
Errors
| Code | When |
|---|---|
NOT_FOUND | No 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
| Parameter | Type | Required | Description |
|---|---|---|---|
cursor | string | No | Pagination cursor. |
limit | number | No | Maximum 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID to update. |
name | string | No | Updated campaign name. |
description | string | No | Updated description. |
status | string | No | Updated status (e.g. "draft", "active", "paused", "completed"). |
Returns
Promise<Campaign> — the updated campaign object.
Errors
| Code | When |
|---|---|
NOT_FOUND | No campaign exists with this ID. |
VALIDATION_ERROR | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID to delete. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | No campaign exists with this ID. |
addSequence
Associates a sequence with the campaign.
await kraiter.campaigns.addSequence('cmp_abc123', 'seq_onboarding');Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID. |
sequenceId | string | Yes | The sequence ID to add. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | The campaign or sequence does not exist. |
CONFLICT | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID. |
sequenceId | string | Yes | The sequence ID to remove. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | The campaign or sequence association does not exist. |
addTemplate
Associates a template with the campaign.
await kraiter.campaigns.addTemplate('cmp_abc123', 'tmpl_launch_announcement');Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID. |
templateId | string | Yes | The template ID to add. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | The campaign or template does not exist. |
CONFLICT | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The campaign ID. |
templateId | string | Yes | The template ID to remove. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | The campaign or template association does not exist. |