Group Service
The Group Service allows you to send emails to predefined recipient groups, simplifying the management of large recipient lists. This service is particularly useful for organizations that need to send bulk emails to specific groups of users. Also it is the best way to implement newsletters.
Key Features
- Group Management: Create, update, and delete groups of recipients.
- Email Sending: Send emails to all members of a group with a single API call.
- Personalization: Customize emails for each group member using placeholders.
Getting Started
- Register for an account on Sendlix.
- Add a domain to your account.
- Verify your domain ownership.
- Get your API key from the dashboard.
- Create a group at the Dashboard.
- Install the required client library for your programming language.
- cURL
- Node.js
Install cURL on your system. You can find installation instructions for your operating system here.
This guide can be outdated, we try to keep it up to date, but the API is constantly evolving and improving. We recommend checking the API Reference for the most accurate and detailed information on using the Group Service.
To install the Sendlix Node.js client library, run the following command in your terminal:
npm install sendlix
Group Functions
Add Email to Group
Add email addresses to an existing group with optional personalization substitutions.
- cURL
- Node.js
curl -X POST https://api.sendlix.com/v1/group/{groupId} \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"emails": [
{
"email": "recipient@example.com",
"name": "Recipient Name"
}
],
"substitutions": {
"{{name}}": "John Doe",
"{{age}}": "30"
}
}'
Replace {groupId}
with the ID of your group. The substitutions will be used for personalization when sending emails to this group member.
You can add an email address multiple times to the same group. When sending a group email, the user will receive multiple copies of the same email.
import { GroupClient } from "sendlix";
// Initialize client
const client = new GroupClient("YOUR_API_KEY");
const groupId = "your-group-id";
const email = "recipient@example.com";
const substitutions = {
"{{name}}": "John Doe",
"{{age}}": "30"
};
// Add email to group
client.insertEmailIntoGroup(groupId, email, substitutions)
.then(response => {
if (response) {
console.log("Email added to group successfully!");
} else {
console.log("Failed to add email to group.");
}
})
.catch(error => {
console.error("Error adding email to group:", error);
});
You can add an email address multiple times to the same group. When sending a group email, the user will receive multiple copies of the same email.
Remove Email from Group
Remove a specific email address from an existing group.
- cURL
- Node.js
curl -X DELETE https://api.sendlix.com/v1/group/{groupId} \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"email": "recipient@example.com"
}'
Replace {groupId}
with the ID of your group.
Only emails that were added within the last 30 minutes can be removed from the group.
import { GroupClient } from "sendlix";
// Initialize client
const client = new GroupClient("YOUR_API_KEY");
const groupId = "your-group-id";
const email = "recipient@example.com";
// Remove email from group
client.deleteEmailFromGroup(groupId, email)
.then(response => {
if (response) {
console.log("Email removed from group successfully!");
} else {
console.log("Failed to remove email from group.");
}
})
.catch(error => {
console.error("Error removing email from group:", error);
});
Only emails that were added within the last 30 minutes can be removed from the group.
Check if Email is in Group
Verify if a specific email address is a member of a group.
- cURL
- Node.js
curl -X GET https://api.sendlix.com/v1/group/{groupId}/check/{email} \
-H "X-API-KEY: YOUR_API_KEY"
Replace {groupId}
with the ID of your group and {email}
with the email address you want to check.
import { GroupClient } from "sendlix";
// Initialize client
const client = new GroupClient("YOUR_API_KEY");
const groupId = "your-group-id";
const email = "recipient@example.com";
// Check if email exists in group
client.containsEmailInGroup(groupId, email)
.then(response => {
if (response) {
console.log("Email is in the group.");
} else {
console.log("Email is not in the group.");
}
})
.catch(error => {
console.error("Error checking email in group:", error);
});
Sending Emails to Groups
Send an email to all members of a specific group.
- cURL
- Node.js
curl -X POST https://api.sendlix.com/v1/send/group/{groupId} \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"subject": "Important Announcement for the Group",
"content": {
"type": "HTML",
"value": "<h1>Hello {{name}}!</h1><p>This is an important announcement for all group members.</p>",
"tracking": true
},
"from": {
"email": "sender@example.com",
"name": "Group Administrator"
},
"category": "newsletter"
}'
Replace {groupId}
with the ID of your group. Any substitution values defined for group members (like {{name}}
) will be replaced with the actual values for each recipient.
import { EmailClient } from "sendlix";
// Initialize client
const client = new EmailClient("YOUR_API_KEY");
const groupId = "your-group-id";
const subject = "Important Announcement for the Group";
const content = {
value: "<h1>Hello {{name}}!</h1><p>This is an important announcement for all group members.</p>",
type: "html",
tracking: true
};
const from = {
email: "sender@example.com",
name: "Group Administrator"
};
// Send email to group
client.sendGroupEmail(content, from, groupId, subject, "newsletter")
.then(response => {
console.log("Group email sent:", response);
})
.catch(error => {
console.error("Error sending group email:", error);
});
Any substitution values defined for group members (like {{name}}
) will be replaced with the actual values for each recipient.
Advanced Features
For more advanced usage of the Group Service, please refer to our detailed API reference documentation.
- cURL
- Node.js
For more information on advanced features, see the Sendlix API Documentation.
For more information on advanced features, see the Sendlix Node.js Client Documentation.