Contact Methods Overview
Contact methods define how users receive notifications. Each user can have multiple email and SMS contact methods. When a relay rule notifies an on-call user, it uses their configured contact methods.
Transport Types
Section titled “Transport Types”Send notifications via email:
const emailContact = await client.contactMethod.create({ userId: "usr_alice", transport: "email", value: "alice@example.com",});Send notifications via text message:
const smsContact = await client.contactMethod.create({ userId: "usr_alice", transport: "sms", value: "+14155551234", // E.164 format recommended});Verification Status
Section titled “Verification Status”Contact methods have a verified status:
- Verified: Confirmed to be working and deliverable
- Unverified: Not yet confirmed
Unverified contact methods receive notifications, but delivery is not guaranteed. Verify methods for reliable delivery.
Common Use Cases
Section titled “Common Use Cases”Adding Multiple Contact Methods
Section titled “Adding Multiple Contact Methods”Users can have multiple ways to be reached:
await client.contactMethod.create({ userId: "usr_alice", transport: "email", value: "alice.work@example.com",});
await client.contactMethod.create({ userId: "usr_alice", transport: "email", value: "alice.personal@example.com",});
await client.contactMethod.create({ userId: "usr_alice", transport: "sms", value: "+14155551234",});Managing User Contact Preferences
Section titled “Managing User Contact Preferences”List and manage contact methods:
const methods = await client.contactMethod.list({ userId: "usr_alice",});
console.log(`Alice has ${methods.length} contact methods`);
const emailMethods = methods.filter((m) => m.transport === "email");const smsMethods = methods.filter((m) => m.transport === "sms");
console.log(`Emails: ${emailMethods.length}, SMS: ${smsMethods.length}`);Cleaning Up Old Contact Methods
Section titled “Cleaning Up Old Contact Methods”Remove outdated contact information:
const methods = await client.contactMethod.list({ userId: "usr_alice",});
const oldEmail = methods.find( (m) => m.value === "old-email@example.com");
if (oldEmail) { await client.contactMethod.delete(oldEmail.id, { userId: "usr_alice", });}Best Practices
Section titled “Best Practices”See Best Practices - Contact Methods for configuration guidelines.