Developers

TumaMaoni API Documentation

Everything you need to collect customer feedback from your web app, mobile app or website — with one simple token-based API. Every paid request costs exactly 1 token.

# Introduction

TumaMaoni is a customer feedback platform for Tanzanian and global businesses. Our developer API lets you collect, read and analyse feedback programmatically — using prepaid tokens instead of a subscription.

What the API gives you

  • Collect feedback — submit ratings and comments from your app or widget in a single request.
  • Read feedback — list and search everything customers have shared, with pagination and filters.
  • Analytics — overviews, trends, department and product breakdowns, satisfaction scores.
  • Simple billing — 1 token = 1 request = TZS 1. No monthly fees, no credit checks.
  • Ready widget — a drop-in JavaScript feedback bubble for websites, powered by publishable keys.

Base URL

EnvironmentBase URL
Productionhttps://tumamaoni.com/api/v2
There is no separate sandbox domain. Test and live requests use the same base URL — they are distinguished only by your API key.

Pricing

ItemCostNotes
Paid request1 tokenDebited per request, refunded if the request fails (4xx/5xx)
Token priceTZS 1Buy tokens via mobile money (M-Pesa, Airtel, Tigo)
Free grant100 tokensCredited automatically when you create your first API key
Wallet & key managementFreeBalance, usage, keys and topup endpoints never cost tokens

Next steps

  1. Create your account and open the Developer API portal.
  2. Generate an API key — you get 100 free tokens.
  3. Make your first request (see Quickstart).

# Quickstart

Get your first feedback submitted through the API in about two minutes.

1. Create an API key

  1. Log in to TumaMaoni and open the Developer API portal.
  2. Open the API keys tab and click Create an API key.
  3. Choose Secret for server-side access (full access) or Publishable for the client-side widget.
  4. Copy the key immediately — it is only shown once.

Creating your first key also grants you 100 free tokens.

2. Check your balance

bash
curl https://tumamaoni.com/api/v2/balance \
  -H "Authorization: Bearer TM-secret-your_key_here"
response
{
  "success": true,
  "message": "Success",
  "data": {
    "user_id": 42,
    "balance": 100,
    "total_purchased": 0,
    "total_spent": 0,
    "free_granted": 1,
    "used_today": 0,
    "rejected_insufficient": 0,
    "min_topup": 1000,
    "max_topup": 200000,
    "tokens_per_request": 1,
    "topup_url": "https://tumamaoni.com/api"
  }
}

3. Submit your first feedback

This paid request costs 1 token and submits feedback to your own business.

bash
curl -X POST https://tumamaoni.com/api/v2/feedbacks/submit \
  -H "Authorization: Bearer TM-secret-your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_name": "John Doe",
    "email_phone": "john@example.com",
    "comments": "Great service, very fast!",
    "satisfaction_score": 5,
    "recommend": "yes",
    "department": "Support",
    "product_service": "Mobile App"
  }'
response
{
  "success": true,
  "message": "Feedback submitted successfully",
  "data": { "feedback_id": 1024 }
}
Done. That's a live feedback entry — check it in your dashboard and your analytics endpoint. See Token billing when you need more tokens.

# Authentication

Authenticate every request with your API key. Send it as a Bearer token or in the X-API-Key header.

Bearer token

header
Authorization: Bearer TM-secret-your_key_here

X-API-Key header

header
X-API-Key: TM-secret-your_key_here

Key formats

PrefixTypeUse
TM-secret-…SecretServer-side. Full access: submit, read, analytics.
TM-pub-…PublishableClient-side widget only. Can submit feedback, cannot read data.
Never expose a secret key in browser code or mobile app binaries. Use a publishable key for anything client-side. If a key leaks, revoke it in the portal and create a new one.

Authenticating requests

Most endpoints require authentication and return 401 with an invalid or missing key. The POST /feedbacks/submit endpoint also accepts publishable keys so your widget can submit feedback directly.

# API keys

Create and manage keys from the Developer API portal or through the API itself. Keys are hashed in our database — the raw key is shown only once at creation.

Secret vs publishable

CapabilitySecretPublishable
Submit feedbackYesYes
Read feedback / analyticsYesNo
Manage keys & walletYesNo
Allowed domainsNot enforcedEnforced (Referer)
Daily request cap1,000100
Where it livesYour backendYour frontend

Allowed domains (publishable keys)

You can restrict a publishable key to specific domains. Requests are checked against the Referer header, so the widget will only run on your sites. One domain per line, e.g. myapp.com and localhost. Leave empty to allow any domain.

Create a key via the API

Zero-token endpoint. Requires an existing secret key.

bash
curl -X POST https://tumamaoni.com/api/v2/keys \
  -H "Authorization: Bearer TM-secret-your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Mobile App",
    "key_type": "publishable",
    "allowed_referrers": ["myapp.com", "localhost"]
  }'

The response returns your new key once:

response
{
  "success": true,
  "message": "API key created. Store it now — you will not see it again.",
  "data": {
    "id": 7,
    "key": "TM-pub-a1b2c3d4e5...",
    "key_type": "publishable",
    "name": "My Mobile App"
  }
}

# Token billing

TumaMaoni API uses simple prepaid billing. There are no subscriptions — you buy tokens and each paid request spends exactly one.

How it works

  1. 1 token = 1 request — every paid endpoint costs exactly 1 token (TZS 1).
  2. Free grant — creating your first API key credits 100 free tokens.
  3. Top up via mobile money — buy tokens with M-Pesa, Airtel or Tigo through CamelPay.
  4. Instant credit — once payment is confirmed, your balance updates automatically.
  5. Refunds — if a paid request fails (4xx/5xx), the token is refunded automatically.

Prices

ItemValue
Minimum topupTZS 1,000 (1,000 tokens)
Maximum topupTZS 200,000 (200,000 tokens)
Low balance alertEmail when balance drops below 500 tokens

Top up from your server

Zero-token endpoint. Initiates a CamelPay mobile money charge — the customer gets a USSD prompt on their phone.

bash
curl -X POST https://tumamaoni.com/api/v2/topup \
  -H "Authorization: Bearer TM-secret-your_key_here" \
  -H "Content-Type: application/json" \
  -d '{ "amount_tsh": 5000, "phone": "0712345678" }'
response
{
  "success": true,
  "message": "Payment initiated. Please check your phone for the USSD prompt.",
  "data": {
    "order_ref": "TT-42-1722...",
    "reference": "cp_a1b2c3d4...",
    "tokens": 5000,
    "tsh_amount": 5000
  }
}

After the customer completes payment, CamelPay calls your account's topup webhook and the tokens are credited to your wallet instantly.

You can also top up directly from the Developer API portal — the Top up tab offers quick amounts from TZS 1,000 to TZS 200,000.

# Feedback widget

Add a non-intrusive feedback bubble to your website in minutes. The widget is powered by a publishable key and submits feedback directly to your TumaMaoni account — no backend needed.

Install

Add this to your page, replacing apiKey with your publishable key:

html
<script src="https://tumamaoni.com/widget.js" async></script>
<script>
  TumaMaoni.init({
    apiKey: 'TM-pub-your_publishable_key',
    appName: 'Tumamaoni',
    auto: { enabled: true, frequency: 'twice_week' }
  });
</script>

Event-triggered prompts

Ask for feedback after a specific action (for example after checkout):

js
// call after a user does something
TumaMaoni.askFeedback('Checkout');

Auto-prompt frequency

ValueFrequency
offNever show automatically (event-triggered only)
dailyOnce per day per visitor
twice_weekTwice per week per visitor
weeklyOnce per week per visitor
The widget costs TZS 1 per submitted feedback — exactly like the API. Make sure your token balance is topped up or submissions will be rejected.

# Webhooks

TumaMaoni doesn't need you to poll for payment status — when your mobile money topup is confirmed, your token wallet is credited automatically.

Topup webhook

When a topup payment succeeds through CamelPay, TumaMaoni receives a webhook at https://tumamaoni.com/api/token_topup_webhook.php and credits the customer's wallet. You never have to write code for this — it happens automatically on our side.

Developer tip: after initiating a topup with POST /api/v2/topup, poll GET /api/v2/balance until the balance increases, or simply watch the Token history table in your developer portal.

# API reference

Complete list of endpoints. Base URL: https://tumamaoni.com/api/v2. Every paid endpoint costs 1 token.

Wallet & key management free

MethodEndpointDescription
POST/keysCreate an API key
GET/keysList your API keys
PUT/keys/{id}Rename, suspend or update domains
DELETE/keys/{id}Revoke (suspend) a key
GET/balanceWallet balance, usage today, limits
GET/usageRequest log (pagination supported)
POST/topupInitiate a CamelPay mobile money topup

Feedback 1 token each

MethodEndpointDescription
POST/feedbacks/submitSubmit feedback (secret or publishable key)
GET/feedbacksList feedback with filters & pagination
GET/feedbacks/{id}Get one feedback with custom answers
GET/feedbacks/statsTotals, average rating, daily trends, departments

Analytics 1 token each

MethodEndpointDescription
GET/analytics/overviewHeadline metrics
GET/analytics/trendsFeedback volume over time
GET/analytics/departmentsPerformance by department
GET/analytics/productsPerformance by product / service
GET/analytics/satisfactionSatisfaction & recommendation scores

Data 1 token each

MethodEndpointDescription
GET/departmentsList departments
GET/productsList products / services
GET/settingsBusiness settings
GET/notificationsRecent notifications

Submit feedback — fields

FieldTypeRequiredDescription
commentsstringYesThe customer's feedback text
satisfaction_scoreintegerYesRating from 1 to 5
customer_namestringNoDefaults to "Anonymous"
email_phonestringNoContact of the customer
recommendenumNoyes or no — inferred from the score
departmentstringNoDepartment or channel
product_servicestringNoProduct or service being rated
featurestringNoWidget context label
location_channelstringNoWhere the feedback was collected
custom_answersarrayNoAnswers to custom questions: [{question_id, answer}]

List feedback — query filters

ParameterExampleDescription
page2Page number (default 1)
per_page50Results per page (default 20, max 50)
date_from / date_to2026-07-01Date range filter
departmentSupportFilter by department
locationMobile AppFilter by location / channel
rating5Filter by satisfaction score
searchfastSearch name or comments

Example — list feedback

bash
curl "https://tumamaoni.com/api/v2/feedbacks?page=1&per_page=20&rating=5" \
  -H "Authorization: Bearer TM-secret-your_key_here"

# Error handling

Errors are always returned as JSON with a success: false flag and a human-readable error message. Failed paid requests are automatically refunded.

error format
{
  "success": false,
  "error": "Insufficient token balance. Top up to continue.",
  "code": "insufficient_tokens",
  "balance": 0,
  "topup_url": "https://tumamaoni.com/api",
  "tokens_per_request": 1
}

Status codes

CodeMeaningNotes
400Bad requestInvalid JSON or missing/incorrect fields
401UnauthorizedMissing, invalid or expired key
402Insufficient tokensTop up at the topup_url returned in the body
403ForbiddenKey suspended, wrong key type, or domain not allowed
404Not foundUnknown endpoint or resource
429Rate limitedDaily request cap reached — resets at midnight
500Server errorSomething broke on our side
502Gateway errorCamelPay could not be reached during topup

Refunds

Tokens are charged when a paid request begins and refunded automatically if the request ends with a 4xx or 5xx status. Refunds appear in your Token history as refund transactions.

Tip: handle 402 by pointing the user to the returned topup_url — your app never has to hard-code the topup page.

# Rate limits

Each API key has a daily request budget that resets at midnight (Tanzania time). Limits apply per key, not per account. If you have paid for tokens, there are no rate limits.

Key typeDaily limit (Free tier)
Secret1,000 requests / day
Publishable100 requests / day

When a free key hits its cap, the API returns 429 with the limit in the error payload. Zero-token endpoints (keys, balance, usage, topup) count toward your daily cap too, but never cost tokens.

Rate limits only apply to free tokens. Once you top up, all limits are removed automatically.

# Support

We're here to help you integrate.

Enjoying the API? Give us a star on the feedback you collect — and tell your developer friends about TumaMaoni.