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.
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
- Python
- Go
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
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.
To install the Sendlix Python client library, run the following command in your terminal:
pip install sendlix
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.
To install the Sendlix Go client library, run the following command in your terminal:
go get github.com/sendlix/sendlix-go
Scopes
The Group Service requires the following scopes to be set in your API key:
group:insert: Permission to add emails to groups.group:remove: Permission to remove emails from groups.
Group Functions
Add Email to Group
Add email addresses to an existing group with optional personalization substitutions.
- cURL
- Node.js
- Python
- Go
curl -X POST https://api.sendlix.com/v1/group/{groupId} \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"entries": [
{
"email": "recipient@example.com",
"name": "Recipient Name"
},
"substitutions": {
"{{name}}": "John Doe",
"{{age}}": "30"
},
],
"groupId": "your-group-id",
"onFailure": "SKIP"
}'
Replace {groupId} with the ID of your group. The substitutions will be used for personalization when sending emails to this group member.
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: email,
substitutions: 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);
});
from sendlix import GroupClient
# Initialize client
client = GroupClient("YOUR_API_KEY")
group_id = "your-group-id"
email = "recipient@example.com"
substitutions = {
"{{name}}": "John Doe",
"{{age}}": "30"
}
# Add email to group
client.insert_email_into_group(group_id, {
"email": email,
"substitutions": substitutions
}, "SKIP")
print("Email added to group successfully!")
package main
import (
"context"
"fmt"
"github.com/sendlix/sendlix-go"
)
func main() {
ctx := context.Background()
groupClient, err := sendlix.NewGroupClient("YOUR_API_KEY", nil)
if err != nil {
panic(err)
}
// Add email to group
response, err := groupClient.InsertEmailToGroup(ctx, "your-group-id", sendlix.GroupEntry{
Email: "recipient@example.com",
Substitutions: map[string]string{
"{{name}}": "John Doe",
"{{age}}": "30",
},
})
if err != nil {
fmt.Println("Error adding email to group:", err)
} else {
fmt.Println("Email added to group successfully!", response)
}
}
Remove Email from Group
Remove a specific email address from an existing group.
- cURL
- Node.js
- Python
- Go
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.
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);
});
from sendlix import GroupClient
# Initialize client
client = GroupClient("YOUR_API_KEY")
group_id = "your-group-id"
email = "recipient@example.com"
# Remove email from group
client.delete_email_from_group(group_id, email)
print("Email removed from group successfully!")
package main
import (
"context"
"fmt"
"github.com/sendlix/sendlix-go"
)
func main() {
ctx := context.Background()
groupClient, err := sendlix.NewGroupClient("YOUR_API_KEY", nil)
if err != nil {
panic(err)
}
// Remove email from group
removeResponse, err := groupClient.RemoveEmailFromGroup(ctx, "your-group-id", "recipient@example.com")
if err != nil {
fmt.Println("Error removing email from group:", err)
} else {
fmt.Println("Email removed from group successfully!", removeResponse)
}
}
Check if Email is in Group
Verify if a specific email address is a member of a group.
- cURL
- Node.js
- Python
- Go
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);
});
from sendlix import GroupClient
# Initialize client
client = GroupClient("YOUR_API_KEY")
group_id = "your-group-id"
email = "recipient@example.com"
# Check if email exists in group
exists = client.contains_email_in_group(group_id, email)
if exists:
print("Email is in the group.")
else:
print("Email is not in the group.")
package main
import (
"context"
"fmt"
"github.com/sendlix/sendlix-go"
)
func main() {
ctx := context.Background()
groupClient, err := sendlix.NewGroupClient("YOUR_API_KEY", nil)
if err != nil {
panic(err)
}
// Check if email exists in group
exists, err := groupClient.CheckEmailInGroup(ctx, "your-group-id", "recipient@example.com")
if err != nil {
fmt.Println("Error checking email in group:", err)
} else if exists {
fmt.Println("Email is in the group.")
} else {
fmt.Println("Email is not in the group.")
}
}
Sending Emails to Groups
Please refer to the Email Service documentation for instructions on how to send emails to groups using the Group Service.
Advanced Features
For more advanced usage of the Group Service, please refer to our detailed API reference documentation.
- cURL
- Node.js
- Python
- Go
For more information on advanced features, see the Sendlix API Documentation.
For more information on advanced features, see the Sendlix Node.js Client Documentation.
For more information on advanced features, see the Sendlix Python Client Documentation.
For more information on advanced features, see the Sendlix Go Client Documentation.