Contacts
SDK reference for creating, reading, updating, and deleting contacts in Kraiter.
The kraiter.contacts namespace provides methods for managing your contact records — the people you send email to. Each contact has a unique ID, an email address, and an optional set of custom properties.
create
Creates a new contact.
const contact = await kraiter.contacts.create({
email: 'alice@example.com',
properties: {
firstName: 'Alice',
plan: 'pro',
},
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | The contact's email address. Must be unique within your tenant. |
properties | Record<string, unknown> | No | Arbitrary key-value pairs to store against the contact. |
Returns
Promise<Contact> — the newly created contact object.
Errors
| Code | When |
|---|---|
CONFLICT | A contact with this email address already exists. |
VALIDATION_ERROR | The email address is invalid. |
get
Retrieves a contact by ID.
const contact = await kraiter.contacts.get('con_abc123');
console.log(contact.email);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
Returns
Promise<Contact> — the contact object.
Errors
| Code | When |
|---|---|
NOT_FOUND | No contact exists with this ID. |
getByEmail
Looks up a contact by email address. Returns null if no contact is found rather than throwing an error.
const contact = await kraiter.contacts.getByEmail('alice@example.com');
if (contact) {
console.log(contact.id);
} else {
console.log('Contact not found');
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | The email address to look up. |
Returns
Promise<Contact | null> — the contact object, or null if not found.
list
Lists contacts with optional filtering and pagination. Returns an async iterator.
for await (const contact of kraiter.contacts.list()) {
console.log(contact.email);
}Filter by search term:
for await (const contact of kraiter.contacts.list({ search: 'alice' })) {
console.log(contact.email);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cursor | string | No | Pagination cursor from a previous response. |
limit | number | No | Maximum number of contacts to return per page. |
search | string | No | Filter contacts by email or property values. |
Returns
AsyncIterable<Contact> — an async iterator that yields contact objects.
update
Updates an existing contact. Only the fields you include are changed; omitted fields are left untouched.
const updated = await kraiter.contacts.update('con_abc123', {
properties: {
plan: 'enterprise',
},
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID to update. |
email | string | No | A new email address for the contact. |
properties | Record<string, unknown> | No | Properties to set or overwrite. |
Returns
Promise<Contact> — the updated contact object.
Errors
| Code | When |
|---|---|
NOT_FOUND | No contact exists with this ID. |
CONFLICT | The new email address is already in use by another contact. |
delete
Permanently deletes a contact.
await kraiter.contacts.delete('con_abc123');Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID to delete. |
Returns
Promise<void>
Errors
| Code | When |
|---|---|
NOT_FOUND | No contact exists with this ID. |
getSends
Retrieves the send history for a contact. Returns an async iterator of send records.
for await (const send of kraiter.contacts.getSends('con_abc123')) {
console.log(send.templateId, send.sentAt, send.status);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
cursor | string | No | Pagination cursor. |
limit | number | No | Maximum items per page. |
Returns
AsyncIterable<Send> — an async iterator of send records.
getScheduled
Retrieves scheduled sends for a contact. Returns an async iterator.
for await (const scheduled of kraiter.contacts.getScheduled('con_abc123')) {
console.log(scheduled.templateId, scheduled.scheduledFor);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
cursor | string | No | Pagination cursor. |
limit | number | No | Maximum items per page. |
Returns
AsyncIterable<ScheduledSend> — an async iterator of scheduled send records.
getSequences
Returns the sequences a contact is currently enrolled in.
const enrolments = await kraiter.contacts.getSequences('con_abc123');
for (const enrolment of enrolments) {
console.log(enrolment.sequenceId, enrolment.status, enrolment.currentStep);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
Returns
Promise<SequenceEnrolment[]> — an array of sequence enrolment records.
getSegments
Returns the segments a contact belongs to.
const memberships = await kraiter.contacts.getSegments('con_abc123');
for (const membership of memberships) {
console.log(membership.segmentId, membership.segmentName);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
Returns
Promise<SegmentMembership[]> — an array of segment membership records.
getTimeline
Returns a chronological feed of all events and interactions for a contact. Returns an async iterator.
for await (const entry of kraiter.contacts.getTimeline('con_abc123')) {
console.log(entry.type, entry.timestamp, entry.data);
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact ID. |
cursor | string | No | Pagination cursor. |
limit | number | No | Maximum items per page. |
Returns
AsyncIterable<TimelineEntry> — an async iterator of timeline entries.