MIRQAM / DEVELOPER PLATFORM / v1

Connect any application.
Build on Mirqam messaging.

Server-to-server text, media, verification and event delivery. A store is optional.

First request

  1. Open Dashboard → Integrations. Create a test key with messages:send and messages:read. No WhatsApp channel is needed for sandbox.
  2. Keep the key on your server. Test keys never contact WhatsApp. Live keys require an active subscription and a connected channel.
  3. Persist an operation ID before sending. Reuse it after timeouts and credential rotation; changing the payload with the same key returns 409.
curl https://bot.mirqam.sa/api/v1/messages \
 -H "Authorization: Bearer $MIRQAM_API_KEY" \
 -H 'Content-Type: application/json' \
 -H 'Idempotency-Key: order-123-confirmation-v1' \
 -d '{"type":"text","to":"+966500000001","text":"Your order is confirmed"}'

HTTP 202 means durably accepted, not delivered. Read GET /api/v1/messages/{id} or subscribe to delivery events. Statuses: accepted, sending, sent, delivered, read, failed, expired, unknown. Unknown means a provider outcome could not be established; never blindly resend with a new ID.

Messages accept text, image, document, audio, video and template types. For media supply an HTTPS url and optional caption/fileName. Gateway downloads are capped at 10 MB; provider limits may be stricter. Templates require Cloud API. Cloud OTP requires an approved authentication template. Provider rules and account permissions still apply.

GROUPS & RICH MESSAGES

Discover groups. Send with the right permissions.

Use the existing QR / gateway channel to discover groups that the connected number participates in. This Mirqam adapter does not expose group discovery or group sending for Cloud API channels. Check capabilities first; there is no automatic provider switch.

GET /api/v1/capabilities
Authorization: Bearer YOUR_API_KEY

GET /api/v1/groups?limit=50
GET /api/v1/groups?limit=50&cursor=NEXT_CURSOR
GET /api/v1/groups/120363000000000000%40g.us

Permissions: create a key with groups:read to discover groups and member roles. Sending to a group requires both messages:send and groups:send. Existing keys are not silently upgraded. Keys are bound to a tenant and channel; a group outside that channel returns group_not_found. List results omit member details; the detail endpoint includes members, description and administrator roles. Participant IDs can be privacy LIDs: never interpret them as phone numbers.

curl https://bot.mirqam.sa/api/v1/messages \
  -H "Authorization: Bearer $MIRQAM_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: group-notice-20260930-001" \
  -d '{"to":"120363000000000000@g.us","type":"text","text":"Your team update"}'

Use the real ID returned by discovery. Group text, image, video, audio, document, location and contact messages use the existing encrypted queue, expiry, quotas and idempotency. WhatsApp enforces membership and administrator-only posting rules. Group templates and OTP are not supported. A 202 response means accepted into the queue, not delivered; inspect the message status.

Safe sandbox

Test keys return one synthetic group 120363000000000000@g.us and simulated:true, without connecting to WhatsApp or reading real groups. Test sends never deliver. Live discovery requires a connected gateway channel and an active subscription. Missing scopes return 403; incompatible or disconnected channels return 409.

Locations and contact cards

{"to":"+966500000000","type":"location","location":{"latitude":24.7136,"longitude":46.6753,"name":"Our office","address":"Riyadh"}}

{"to":"+966500000000","type":"contact","contact":{"name":"Customer support","phone":"+966500000001"}}

These types also work with supported Cloud channels. Gateway location messages carry the location name and coordinates; the optional address is a Cloud field. Contact phone numbers remain E.164. Each POST requires a unique Idempotency-Key.

Incoming group messages

Existing message.received webhooks now identify group messages with isGroup, groupId and senderId. The existing account setting that hides group chats remains authoritative: hidden groups do not produce inbox or developer inbound events. This update does not change that preference. A sender ID can be a privacy LID. Never send OTP or personal verification data to a group.

Creation, invite links and adding/removing members are not part of this release.

Managed verification

Request a challenge, retain its verificationId on your backend, then verify it in a separate request. Bind clientId and purpose to the real business operation, not to arbitrary browser input.

POST /api/v1/verifications
{"phone":"+966500000001","clientId":"store-1","purpose":"refund:order-123"}

POST /api/v1/verifications/{verificationId}/verify
{"code":"CUSTOMER_INPUT","clientId":"store-1","purpose":"refund:order-123"}

Six digits, five-minute expiry, three wrong guesses, single use and a 30-second per-phone cooldown. Phone numbers must use full E.164. Live responses never return the code; sandbox returns testCode. Responses are generic on mismatch, expiry or replay. Serialize the business action using its own unique operation ID.

Migration: when the integration feature is enabled, legacy store-secret OTP calls return a verificationId. Send that ID and the same action on verify; the store ID is derived from authentication. Split request and verification into separate UI steps.

Signed events, retry and replay

Create a subscription with an HTTPS public URL and selected events. Save the one-time signing secret. Never use the API key as a webhook secret.

{"url":"https://your-app.com/hooks/mirqam",
 "events":["message.received","message.delivered","message.read"]}

Verify X-Mirqam-Signature as hex HMAC-SHA256 of timestamp + "." + rawBody. Check X-Mirqam-Timestamp within five minutes, then deduplicate by X-Mirqam-Event-Id in persistent storage. Acknowledge 2xx only after durable acceptance. Do not reconstruct JSON before signature verification.

Delivery is at least once. Up to 12 attempts or 24 hours, whichever is reached first, with exponential backoff, jitter and bounded Retry-After handling. Redirects are not followed. Private destinations are rejected and DNS is pinned. Dead deliveries can be replayed by the owner; the event ID stays the same. Pause prevents new worker claims, but an already in-flight request can finish.

Secret rotation is immediate: update the receiver before resuming a paused subscription. Test subscriptions receive sandbox lifecycle events only. Live inbound callbacks are not copied to sandbox.

Limits and support

Default: 120 API requests/minute per tenant and mode, 60 sends/minute and 30 verification requests/minute. 429 includes Retry-After. Existing subscription quotas apply to live sends.

Every error body is {"error":{"code":"…","requestId":"…"}}; branch on error.code, not on the message. 409 codes: channel_not_connected (the WhatsApp number is not linked; relink it in the dashboard), cloud_channel_not_ready (the official number is not ready to send), idempotency_conflict (same Idempotency-Key with a different payload; do not retry), conversation_requires_live_key. Channel 409s carry Retry-After and error.retryAfter in seconds. A key that keeps sending to a disconnected channel is answered 429 channel_not_connected without being processed, for 1 minute and then longer (up to 10 minutes) while it keeps failing; the first accepted send clears it. Request IDs are returned in X-Request-Id and error bodies. List messages using cursor pagination; each page contains up to 50 records.

Message/idempotency and event records: 30 days from creation, once terminal. Verification records: expiry plus one day. Receipts: seven days. Audit records: 90 days. Unknown outcomes are retained for manual investigation. Do not reuse operation IDs after retention. OTP dispatch payloads are encrypted while queued and removed when processed; their codes are excluded from gateway retry persistence.

Version policy: additive changes under v1; breaking changes require a new version and migration notice. Published availability targets require measured production evidence. SDK samples and troubleshooting are included in the developer ZIP.

Endpoint reference

Authorization: Bearer API key. Required scope appears on each operation. The downloadable OpenAPI file is the machine-readable contract.