Skip to main content

šŸ‘„ 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:

ParameterTypeRequiredDescription
devicestringāœ…Your registered WhatsApp device number
typestringāœ…Message type: "text", "image", "file", "location", "template", "list"
paramsobjectāœ…Message parameters (varies by message type)
simulate_typingintegerāŒShow typing indicator: 1 (yes) or 0 (no)
Group ID

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
}
}