The customer list API lets your own system keep Mobiz customer lists up to date: create a new list, then add customers to it as they sign up or buy. Campaigns that use the list, including bulk triggers subscribed to it, pick up the new customers. To manage lists by hand instead, see Uploading and managing your customer database.
Before you start
You need a Mobiz API key with customer-list access, linked to a Mobiz user. Contact Mobiz support to have one issued. You'll use:
- username: the Mobiz username the key belongs to.
- api_key: the API key.
Keep the key secret and call the API only from your server. Anyone with it can read your list structure and add customers.
Create a customer list
Send a POST with HTTP Basic authentication (username and API key) and a JSON body naming the list and its columns:
curl -X POST "https://api.mobiz.co.za/api/2.0/CustomerList-create.php" \
-u "YOUR_USERNAME:YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"Customer List Name": "Online orders",
"Customer List Definition": {"Mobile": "msisdn", "FirstName": "text", "Email": "email", "Spend": "numeric"}
}'
Columns are created in the order you list them and labelled A, B, C… (here Mobile = A, FirstName = B, Email = C, Spend = D). The column types are:
msisdn: Mobile numbers. Checked and converted to international format.text: Any text.email: Email addresses.numeric: Numbers.
The response includes the new list's ID, which you need to add customers:
{"status": 1, "message": "...", "list_id": 4821}
Add customers to a list
Send a POST with the API key and list ID in the address, and a JSON array of customers in the body:
curl -X POST "https://api.mobiz.co.za/api/2.0/CustomerList-append.php?api_key=YOUR_API_KEY&list_id=4821" \
-H "Content-Type: application/json" \
-d '[
{"Mobile": "27821234567", "FirstName": "Thandi", "Email": "thandi@example.com", "Spend": "1250"},
{"Mobile": "27831234567", "FirstName": "Sipho", "Email": "sipho@example.com", "Spend": "640"}
]'
- Values are matched by position, not by name. The first value in each customer goes into column A, the second into B, and so on. The names are only for your own readability, so always send fields in the same order as the list definition.
- Each value is checked against its column type.
- Up to 10,000 customers per call. Split larger uploads into several calls.
- For this call, pass the key in the address as shown. HTTP Basic authentication does not work for adding customers.
A successful call returns:
{"status": 1, "message": "Data Appended"}
Status codes
- 1: Success.
- 2: Authentication failed or missing (HTTP 401).
- 3: Invalid list name (create).
- 4: Missing list ID (add).
- 5: Invalid list definition, such as an unknown column type (create).
- 6: Missing or invalid JSON body.
- 7: Invalid list ID, or the list isn't yours (add).
- 8: Too many customers in one call (over 10,000).
Good practice
- Only add customers who agreed to hear from you. Customers on your opt-out list are excluded from sends. See Compliance-related features and functions.
- Don't resend a batch after a timeout without checking the list first, or you may add duplicates.
- If a key may have leaked, contact Mobiz support to suspend it and issue a new one.