š„ Send Messages to Groups
Send text, images, files, and other message types to WhatsApp groups using the Whatspie API with all the same features available for individual messaging.
šÆ Group Messaging
Send messages to WhatsApp groups using the same message format as individual messages. Perfect for broadcasting announcements, sharing files, and engaging with group members.
š Endpointā
POST https://api.whatspie.com/groups/{group_id}/send
Where {group_id}
is the numeric ID of the WhatsApp group.
š Authenticationā
Bearer token required with proper JSON content headers.
š Request Parametersā
The request parameters are identical to individual messaging, with the key difference being the endpoint URL:
Parameter | Type | Required | Description |
---|---|---|---|
device | string | ā | Your registered WhatsApp device number |
type | string | ā | Message type: "text" , "image" , "file" , "location" , "template" , "list" |
params | object | ā | Message parameters (varies by message type) |
simulate_typing | integer | ā | Show typing indicator: 1 (yes) or 0 (no) |
The group ID can be obtained from the group creation response or by listing your groups. It's the numeric identifier for the WhatsApp group.
š Message Typesā
All message types supported for individual messaging are available for groups:
š Text Messages
- Plain text
- Formatted text (bold, italic)
- Emojis and symbols
- Line breaks
š¼ļø Media Messages
- Images with captions
- Documents and files
- Audio files
- Video files
šÆ Interactive
- Location sharing
- Template messages
- List messages
- Contact cards
š Request Examplesā
Text Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "text",
"params": {
"text": "š *Team Update* š\n\nGreat news everyone! Our project milestone has been completed successfully.\n\nā
All features tested\nā
Documentation updated\nā
Ready for deployment\n\nThanks for your hard work! š"
},
"simulate_typing": 1
}'
Image Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "image",
"params": {
"image": {
"url": "https://example.com/team-photo.jpg"
},
"caption": "šø Team lunch today! Great job everyone on completing the sprint goals. š½ļøāØ"
},
"simulate_typing": 1
}'
File Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "file",
"params": {
"document": {
"url": "https://example.com/project-report.pdf"
},
"fileName": "Project_Report_Q4_2024.pdf",
"mimetype": "application/pdf"
},
"simulate_typing": 1
}'
Location Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "location",
"params": {
"location": {
"degreesLatitude": -6.2088,
"degreesLongitude": 106.8456
}
},
"simulate_typing": 1
}'
Template Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "template",
"params": {
"templateName": "team_meeting_reminder",
"templateParams": [
"Project Review",
"Tomorrow",
"2:00 PM",
"Conference Room A"
]
},
"simulate_typing": 1
}'
List Message to Groupā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"device": "6281234567890",
"type": "list",
"params": {
"body": "š *Project Tasks* š\n\nPlease select a task to view details:",
"buttonText": "View Tasks",
"sections": [
{
"title": "High Priority",
"rows": [
{
"id": "task_1",
"title": "API Documentation",
"description": "Complete API documentation review"
},
{
"id": "task_2",
"title": "Testing Phase",
"description": "Execute comprehensive testing"
}
]
},
{
"title": "Medium Priority",
"rows": [
{
"id": "task_3",
"title": "UI Polish",
"description": "Final UI improvements"
}
]
}
]
},
"simulate_typing": 1
}'
š Response Formatā
Success Responseā
{
"code": 200,
"message": "Message sent successfully",
"data": {
"id": "msg_group_12345",
"status": "pending",
"type": "text",
"device": "6281234567890",
"receiver": "120363022368688477@g.us",
"message": "Team Update: Project milestone completed!",
"simulate_typing": 1,
"timestamp": "2024-12-20T10:30:00Z"
}
}
Error Response - Group Not Foundā
{
"code": 404,
"message": "Group not found",
"error": "The specified group ID does not exist or you don't have access to it"
}
Error Response - Not a Group Memberā
{
"code": 403,
"message": "Access denied",
"error": "Your device is not a member of this group"
}
šÆ Group-Specific Featuresā
Mention Group Membersā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"device": "6281234567890",
"type": "text",
"params": {
"text": "Hey @6289876543210 and @6281122334455, can you review the latest changes? š",
"mentions": ["6289876543210", "6281122334455"]
}
}'
Reply to Group Messageā
curl -X POST "https://api.whatspie.com/groups/495/send" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"device": "6281234567890",
"type": "text",
"params": {
"text": "Great point! Let me add some details to that.",
"quotedMessageId": "msg_group_12344"
}
}'
š” Best Practicesā
1. Group Message Etiquetteā
// Good: Clear, structured group messages
const groupMessage = {
device: "6281234567890",
type: "text",
params: {
text: "š¢ *ANNOUNCEMENT* š¢\n\n" +
"Subject: Weekly Standup\n" +
"š
When: Monday 10:00 AM\n" +
"š Where: Conference Room B\n" +
"ā±ļø Duration: 30 minutes\n\n" +
"Please bring your progress updates! š"
},
simulate_typing: 1
};
2. Batch Group Messagingā
async function sendToMultipleGroups(message, groupIds) {
const results = [];
for (const groupId of groupIds) {
try {
const response = await fetch(`https://api.whatspie.com/groups/${groupId}/send`, {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify(message)
});
const result = await response.json();
results.push({ groupId, success: true, messageId: result.data.id });
// Delay between messages to avoid rate limiting
await new Promise(resolve => setTimeout(resolve, 2000));
} catch (error) {
results.push({ groupId, success: false, error: error.message });
}
}
return results;
}
// Usage
const announcement = {
device: "6281234567890",
type: "text",
params: {
text: "š Company Update: We've reached 10,000 users! Thank you all for your hard work! š"
}
};
const groupIds = [495, 496, 497];
const results = await sendToMultipleGroups(announcement, groupIds);
3. Group Message Schedulingā
function scheduleGroupMessage(groupId, message, scheduleTime) {
const delay = scheduleTime.getTime() - Date.now();
if (delay <= 0) {
throw new Error('Schedule time must be in the future');
}
setTimeout(async () => {
try {
const response = await fetch(`https://api.whatspie.com/groups/${groupId}/send`, {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify(message)
});
console.log('Scheduled message sent:', await response.json());
} catch (error) {
console.error('Failed to send scheduled message:', error);
}
}, delay);
}
// Schedule a reminder for tomorrow at 9 AM
const tomorrow9AM = new Date();
tomorrow9AM.setDate(tomorrow9AM.getDate() + 1);
tomorrow9AM.setHours(9, 0, 0, 0);
const reminder = {
device: "6281234567890",
type: "text",
params: {
text: "ā° Reminder: Daily standup in 1 hour! š„"
}
};
scheduleGroupMessage(495, reminder, tomorrow9AM);
ā ļø Limitationsā
- Group membership: Your device must be a member of the group to send messages
- Message size: Same limits apply as individual messaging (16MB for images, 100MB for files)
- Rate limiting: Groups may have stricter rate limits to prevent spam
- Admin restrictions: Some groups may restrict messaging to admins only
- Delivery tracking: Group message delivery status may be limited compared to individual messages
š Getting Group Informationā
Before sending messages, you may want to get group details:
curl -X GET "https://api.whatspie.com/groups/495" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
Response:
{
"code": 200,
"data": {
"id": 495,
"name": "Project Team",
"description": "Development team coordination",
"participant_count": 8,
"created_at": "2024-11-15T09:00:00Z",
"is_admin": false,
"can_send_messages": true
}
}
š Related Endpointsā
- Create WhatsApp Groups - Create new groups
- Send Text Messages - Text message format details
- Send Image Messages - Image message parameters
- Send File Messages - File message specifications
- Send Location Messages - Location sharing
- Send Template Messages - Template message format
- Send List Messages - Interactive list messages