Overview
Marketing audiences let you group recipient phone numbers and send the same SMS message to the whole group in one request.
Audience list responses include:
subscriber_countfor total phone numbers in the audiencemessage_countfor total SMS messages sent through the audience
All marketing endpoints support Authorization: Bearer <api key> or X-API-Key: <api key>.
Create an audience
curl https://api.bar9.me/v1/marketing/channels \
-H "Authorization: Bearer $BAR9_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Ramadan audience" }'Add numbers to an audience
curl https://api.bar9.me/v1/marketing/channels/mkt_123/numbers \
-H "Authorization: Bearer $BAR9_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "phone_number": "+213555123456" }'phone_number must be in E.164 format.
Update an audience name
curl https://api.bar9.me/v1/marketing/channels/mkt_123 \
-H "Authorization: Bearer $BAR9_API_KEY" \
-H "Content-Type: application/json" \
-X PATCH \
-d '{ "name": "VIP customers" }'Delete an audience
curl https://api.bar9.me/v1/marketing/channels/mkt_123 \
-H "Authorization: Bearer $BAR9_API_KEY" \
-X DELETEBroadcast a message to an audience
curl https://api.bar9.me/v1/marketing/channels/mkt_123/messages \
-H "Authorization: Bearer $BAR9_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "Big discount this weekend!"
}'This creates one queued SMS per phone number in the audience.
API key scopes
| Scope | Purpose |
|---|---|
marketing:channels:read | List audiences and list numbers in an audience. |
marketing:channels:write | Create audiences and add numbers. |
marketing:channels:send | Broadcast audience messages. |