Audiences API

Organize contacts into targeted audiences for better segmentation and campaign management. Use audiences to send targeted emails to specific groups of contacts.

Create Audience

create-audience.tsTypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Metigan from 'metigan';

const metigan = new Metigan({
  apiKey: 'your_api_key'
});

// Create a new audience
const audience = await metigan.audiences.create({
  name: 'Premium Customers',
  description: 'Customers with premium subscription',
  tags: ['premium', 'active'] // Optional: filter by tags
});

console.log('Audience created:', audience.id);

Add Contacts to Audience

add-contacts.tsTypeScript
1
2
3
4
5
6
7
8
9
// Add contacts to an audience
await metigan.audiences.addContacts('audience_123', {
  contactIds: ['contact_1', 'contact_2', 'contact_3']
});

// Or add by email
await metigan.audiences.addContactsByEmail('audience_123', {
  emails: ['user1@example.com', 'user2@example.com']
});
Audience Segmentation

Use audiences to segment your contacts for targeted campaigns. Audiences can be created based on tags, custom fields, or specific contact criteria.