Contact methods represent communication channels for clients, such as email addresses and phone numbers.
| Type | Description |
|---|
email | Email address |
phone | Phone number |
fax | Fax number |
other | Other contact type |
// Create an email contact
const email = await sdk.contactMethods.create({
clientId: "client_abc123",
type: "email",
value: "juan@example.com",
label: "Personal",
isPrimary: true,
});
// Create a phone contact
const phone = await sdk.contactMethods.create({
clientId: "client_abc123",
type: "phone",
value: "+52 55 1234 5678",
label: "Mobile",
isPrimary: false,
});
// Get a specific contact method
const contact = await sdk.contactMethods.retrieve("contact_xyz789");
console.log(contact.type); // "email"
console.log(contact.value); // "juan@example.com"
console.log(contact.isPrimary); // true
Also available: retrieveByExternalId and retrieveByMetadata for custom identifiers or metadata lookups (see SDK reference).
List by Client
// Get all contact methods for a client
const { data: contacts } =
await sdk.contactMethods.listByClient("client_abc123");
for (const contact of contacts) {
console.log(`${contact.type}: ${contact.value}`);
}
Filter by Type
// Get only email contacts for a client
const { data: emails } = await sdk.contactMethods.list({
filter: {
clientId: "client_abc123",
type: "email",
},
});
// Update a contact method
const updated = await sdk.contactMethods.update("contact_xyz789", {
value: "new.email@example.com",
isPrimary: true,
});
await sdk.contactMethods.delete("contact_xyz789");
Each client can have one primary contact method per type:
// Get the primary email for a client
const primaryEmail = await sdk.contactMethods.getPrimary(
"client_abc123",
"email",
);
if (primaryEmail) {
console.log(`Primary email: ${primaryEmail.value}`);
}
// Set a contact as primary
await sdk.contactMethods.update("contact_xyz789", {
isPrimary: true,
});
Setting a contact method as primary automatically removes the primary flag
from other contact methods of the same type for that client.
| Property | Type | Description |
|---|
id | string | Unique identifier |
clientId | string | Parent client ID |
type | ContactMethodType | Contact type |
value | string | The contact value |
label | string | undefined | Optional label |
isPrimary | boolean | Whether this is primary |
isVerified | boolean | Whether verified |
createdAt | Date | Creation timestamp |
updatedAt | Date | Last update timestamp |
Batch Operations
// Create multiple contact methods
const result = await sdk.contactMethods.createMany([
{
clientId: "client_abc123",
type: "email",
value: "work@company.com",
label: "Work",
},
{
clientId: "client_abc123",
type: "phone",
value: "+52 55 9876 5432",
label: "Work",
},
]);