Contacts and campaigns

A campaign is one message to many people, sent at a pace that does not get the number banned.

Contacts

curl -X POST https://njiwa.upeo.ai/v1/contacts/import \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"contacts": [
        {"msisdn": "0712345678", "name": "Asha"},
        {"msisdn": "254733111222", "name": "Brian"}
      ]}'

Rows that cannot be read are reported back with a reason; the rest still import. A 5,000 row list with three bad numbers imports 4,997 contacts and tells you about the three.

GET /v1/contactsList, with ?q= to search.
POST /v1/contactsAdd or update one.
POST /v1/contacts/importBulk import.
PATCH /v1/contacts/{id}Update.
DELETE /v1/contacts/{id}Remove.

Campaigns

curl -X POST https://njiwa.upeo.ai/v1/campaigns \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"name": "September price list",
       "all_contacts": true,
       "content": {"text": "Our September price list is out."},
       "pacing_ms": 3000}'

The response tells you how long it will take before you commit to it. Then start it:

POST /v1/campaigns/{id}/start
POST /v1/campaigns/{id}/pause
GET  /v1/campaigns/{id}/recipients

Every recipient carries its own message id and its own status, so a campaign that half worked tells you exactly which half.

Pacing is the point. A campaign goes onto the same queue a single send uses, and drains at the number's own interval. Sending as fast as the socket allows is how a number stops working.

Auto-replies

Rules are checked in priority order and the first match wins, so one inbound message never produces two replies.

curl -X POST https://njiwa.upeo.ai/v1/autoresponders \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"match_type": "contains", "pattern": "price",
       "reply": {"text": "Our price list is at example.com/prices"},
       "priority": 10}'

match_type is exact, contains, starts_with, regex or any. Put any last, at a high priority number.

Usage

GET /v1/usage

Messages sent and received, media stored, by day and in total. Quantities only: what they cost is decided elsewhere.