Contacts API
Manage contacts and subscribers with the Metigan Contacts API. Create, update, delete, and list contacts with built-in validation and deduplication.
Overview
The Contacts API allows you to manage your contact database. Contacts can be organized into audiences, tagged, and used for targeted email campaigns.
Create Contact
create-contact.tsTypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Metigan from 'metigan';
const metigan = new Metigan({
apiKey: 'your_api_key'
});
// Create a new contact
const contact = await metigan.contacts.create({
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
phone: '+1234567890',
tags: ['customer', 'premium'],
customFields: {
company: 'Acme Corp',
jobTitle: 'Software Engineer'
}
});
console.log('Contact created:', contact.id);List Contacts
list-contacts.tsTypeScript
1
2
3
4
5
6
7
8
9
10
// List all contacts with pagination
const contacts = await metigan.contacts.list({
page: 1,
limit: 50,
tags: ['customer'], // Optional: filter by tags
audienceId: 'audience_123' // Optional: filter by audience
});
console.log('Total contacts:', contacts.total);
console.log('Contacts:', contacts.items);Update Contact
update-contact.tsTypeScript
1
2
3
4
5
6
7
8
// Update an existing contact
const updatedContact = await metigan.contacts.update('contact_123', {
firstName: 'Jane',
lastName: 'Smith',
tags: ['customer', 'vip']
});
console.log('Contact updated:', updatedContact);Learn More
Check out the Contact Management guidefor best practices and advanced techniques.