Implement Customer.io's key platform features: transactional emails/push (password resets, receipts), API-triggered broadcasts (one-to-many on demand), segment-driving attributes, anonymous-to-known user merging, and person suppression/deletion.
Prerequisites
customerio-node installed
Track API credentials (CUSTOMERIO_SITE_ID + CUSTOMERIO_TRACK_API_KEY)
App API credential (CUSTOMERIO_APP_API_KEY) — required for transactional + broadcasts
Instructions
Feature 1: Transactional Email
Transactional messages are opt-in-implied messages (receipts, password resets). Create the template in Customer.io dashboard first, then call the API with data.
// Merge a secondary (duplicate) person into a primary person.// The secondary is deleted permanently after merge.asyncfunctionmergeUsers(primaryId: string,
secondaryId: string,
identifierType: "id" | "email" | "cio_id" = "id") {
await cio.mergeCustomers(
identifierType,
primaryId,
identifierType,
secondaryId
);
// Secondary person is permanently deleted.// Their attributes and activity merge into the primary.
}
Feature 6: Suppress and Delete People
// Suppress: user stays in system but receives no messagesasyncfunctionsuppressUser(userId: string): Promise<void> {
await cio.suppress(userId);
}
// Delete: remove user entirely from Customer.ioasyncfunctiondeleteUser(userId: string): Promise<void> {
await cio.destroy(userId);
}
Error Handling
Error
Cause
Solution
422 on transactional
Wrong transactional_message_id
Verify template ID in Customer.io dashboard
Missing Liquid variable
message_data incomplete
Ensure all {{ data.x }} variables are in message_data
Broadcast 404
Invalid broadcast ID
Check broadcast ID in dashboard Broadcasts section
Segment not updating
Attribute type mismatch
Dashboard segments compare types strictly — number vs string matters