Mobiz Help Centre

Advice and answers from the Mobiz team

Sending SMS from your own system (Trigger API)

The Trigger API lets your own system (a website, CRM, order system or app) send a Mobiz SMS or SmartSMS to a customer the moment something happens, for example an order confirmation, an appointment reminder or a follow-up after a call. Each call adds the customer to the campaign's customer list and sends the trigger engagement's message to them.


Before you start

  • A trigger engagement. In the Mobiz client panel, create a campaign with a trigger engagement and the message you want to send. The engagement must be active. See Automations and Creating standard SMS campaigns.
  • Two keys. From the trigger engagement's menu, choose Share Integration Detail and pick your developer. They receive an email with the trigger key (which identifies the engagement) and their API key (which identifies the developer). If you don't see the option, contact Mobiz support.
  • Credit. Each message uses credit from the engagement's budget. Long messages and some characters cost more than one SMS; see About Mobiz South Africa.

Keep both keys secret. Anyone with them can send messages from your account and spend your credit. Call the API from your server, never from a web page or mobile app.


Step 1: find the field order

The campaign's customer list has columns labelled A, B, C and so on. To see which letter is which field, open this address with your keys:


https://api.mobiz.co.za/api/2.0/triggerMessage.php?show_api=1&trigger_key=YOUR_TRIGGER_KEY&api_key=YOUR_API_KEY

It returns one line per column, for example:


A => Mobile
B => FirstName
C => OrderNumber

This is plain text with HTML line breaks, not JSON.


Step 2: send a message

Send a POST request with the customer as JSON in the body, keyed by column letter. Pass the keys in headers:


POST https://api.mobiz.co.za/api/2.0/triggerMessage.php
X-API-Key: YOUR_API_KEY
X-Trigger-Key: YOUR_TRIGGER_KEY
Content-Type: application/json

{"A": "27821234567", "B": "Thandi", "C": "INV-10023"}

Example with curl:


curl -X POST "https://api.mobiz.co.za/api/2.0/triggerMessage.php" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "X-Trigger-Key: YOUR_TRIGGER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"A": "27821234567", "B": "Thandi", "C": "INV-10023"}'

To send to several customers in one call, send a JSON array: [{"A": "27821234567", "B": "Thandi"}, {"A": "27831234567", "B": "Sipho"}].


  • Write mobile numbers in international format without the plus sign, for example 27821234567.
  • Letters that aren't columns in the list are ignored. Columns you leave out are stored empty.
  • The keys can also be sent as query parameters (?trigger_key=…&api_key=…), which older integrations use. Headers are preferred because query strings end up in server logs.

Scheduling a send

Add send_time to the address as a Unix timestamp (seconds) to send later: …/triggerMessage.php?send_time=1767254400. If the engagement has a fixed delay set, that delay is added to send_time, or to the current time if you don't pass one.


The response

{
  "reference": 12345,
  "result_code": 3,
  "result_description": "Accepted",
  "message_status": [ ... one entry per customer ... ],
  "new_budget": 950
}

reference identifies the call in Mobiz's log; quote it when you contact support. new_budget is the engagement's remaining budget.


Result codes

  • 3: Accepted. Check message_status for each customer.
  • 0: Authentication failed: the API key is wrong, suspended or not allowed to send triggers.
  • 1: No active trigger engagement for this trigger key.
  • 2: The body isn't valid JSON.
  • 4: Something is missing; result_description lists what (keys or body).

Message status (per customer)

  • SUBMITTED: Sent to the network for delivery.
  • SCHEDULED: Will be sent at the scheduled time.
  • OPTED OUT: The customer has opted out, so no message was sent.
  • ERROR_INVALID_NUMBER: The mobile number isn't valid.
  • ERROR_TOO_LONG: The message is too long.
  • ERROR_LOW_CREDIT: Not enough credit in the engagement's budget.
  • DUPLICATE INDEX: This record was already sent.

"Accepted" means Mobiz took the request, not that the phone received it. Delivery results appear in the campaign's reports; see Reports and analytics.


Good practice

  • Don't retry blindly. If a call times out, check the campaign's reports before sending again, or the customer may get the message twice.
  • Only message customers who agreed to hear from you, and include an opt-out in marketing messages. See Compliance-related features and functions.
  • If a key may have leaked, contact Mobiz support to suspend it and issue a new one.