API key

Marketing Audiences

Create marketing audiences, add phone numbers, and broadcast one message to all audience members.

POST
/v1/marketing/channels
API key scope marketing:channels:write - Create a marketing audience.
GET
/v1/marketing/channels
API key scope marketing:channels:read - List marketing audiences.
PATCH
/v1/marketing/channels/:channel_id
API key scope marketing:channels:write - Update a marketing audience.
DELETE
/v1/marketing/channels/:channel_id
API key scope marketing:channels:write - Delete a marketing audience.
POST
/v1/marketing/channels/:channel_id/numbers
API key scope marketing:channels:write - Add a phone number to an audience.
GET
/v1/marketing/channels/:channel_id/numbers
API key scope marketing:channels:read - List phone numbers in an audience.
POST
/v1/marketing/channels/:channel_id/messages
API key scope marketing:channels:send - Broadcast one SMS to all phone numbers in the audience.

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_count for total phone numbers in the audience
  • message_count for 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 DELETE

Broadcast 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

ScopePurpose
marketing:channels:readList audiences and list numbers in an audience.
marketing:channels:writeCreate audiences and add numbers.
marketing:channels:sendBroadcast audience messages.