# CLEANPANELS API > Reference for AI coding assistants. Two APIs: (1) the Panel API, the standard SMM API v2 on every panel; (2) the Platform API for WhatsApp numbers, email mailboxes and the account wallet. Rules for generated code: - Never hard-code API keys. Read them from environment variables: PANEL_API_KEY (panel API) and CLEANPANELS_API_KEY (platform API). - Always check for an "error" field in responses and show it to the user. - Use HTTPS only. ## 1. Panel API (SMM API v2) URL: POST https://YOUR-PANEL-DOMAIN/api/v2 (each panel has its own domain, e.g. https://yourbrand.cleanpanels.co.ke/api/v2) Format: application/x-www-form-urlencoded form fields. Always send `key` (from the panel: Account → API) and `action`. Responses: JSON. Errors: {"success":false,"error":"message"} — always check for an "error" field. ### List services — action=services Every service you can order, with price per 1,000, limits and options. Call it once and cache it. Example response: [{"service":1042,"name":"Instagram Followers [Real]","type":"Default","category":"Instagram","rate":"1.20","min":"10","max":"100000","refill":true,"cancel":false}] ### Place an order — action=add Creates an order and charges your balance. Keep the returned order ID to check its status. Fields: service (Service ID from "services", e.g. 1042), link (Profile or post link, e.g. https://instagram.com/yourbrand), quantity (Between the service min and max, e.g. 1000) Example response: {"order":20481} ### Order with drip-feed — action=add Spreads delivery over time so growth looks natural. Total = quantity × runs. Fields: service (Service ID, e.g. 1042), link (Link, e.g. https://instagram.com/yourbrand), quantity (Quantity per run, e.g. 500), runs (How many runs, e.g. 10), interval (Minutes between runs, e.g. 60) Example response: {"order":20482} ### Order custom comments — action=add For services of type "Custom Comments". The quantity is the number of lines. Fields: service (A "Custom Comments" service, e.g. 2210), link (Post link, e.g. https://instagram.com/p/POST_ID), comments (One comment per line (\n), e.g. Love this!\nSo good 🔥\nWow) Example response: {"order":20483} ### Order status — action=status Status values: Pending, Processing, In progress, Completed, Partial, Canceled. "remains" is how much is left to deliver. Fields: order (Order ID, e.g. 20481) Example response: {"charge":"1.20","start_count":"1290","status":"In progress","remains":"380","currency":"USD"} ### Status of many orders — action=status One request for up to 100 orders — use this for dashboards and scheduled checks. Fields: orders (Up to 100 IDs, comma separated, e.g. 20481,20482,20483) Example response: {"20481":{"charge":"1.20","start_count":"1290","status":"Completed","remains":"0","currency":"USD"},"20482":{"error":"Incorrect order ID"}} ### Request a refill — action=refill Only for services with "refill": true, when the count dropped. Fields: order (Order ID (or "orders" for several), e.g. 20481) Example response: {"refill":"7731"} ### Refill status — action=refill_status Status of a refill request. Fields: refill (Refill ID (or "refills" for several), e.g. 7731) Example response: {"status":"Completed"} ### Cancel orders — action=cancel Only for services with "cancel": true that have not started. Fields: orders (Comma separated order IDs, e.g. 20481,20482) Example response: [{"order":20481,"cancel":1},{"order":20482,"cancel":{"error":"Incorrect order ID"}}] ### Ask to speed up — action=speedup Sends a speed-up request for a running order to the panel's support team. Fields: order (Order ID (or "orders" for several), e.g. 20481) Example response: {"speedup":1} ### Plain-language request — action=request Understands a support message like a human would — perfect for chat bots. Returns one result per order plus a ready-made reply text. Fields: text (Order IDs plus what you want: status, refill, cancel or speed, e.g. 20481 20482 refill) Example response: {"results":[{"order":20481,"action":"refill","ok":true,"task":7731}],"reply":"Refill requested for #20481"} ### Your balance — action=balance Your account balance on this panel. Example response: {"balance":"184.32","currency":"USD"} ## 2. Platform API (REST, JSON) Base URL: https://cleanpanels.co.ke/api/v1 Auth header: Authorization: Bearer sk_live_… (create keys in the console: API keys) Body: JSON (Content-Type: application/json). Errors: {"error":{"code":"…","message":"…"}} with HTTP 401 (bad key), 402 (wallet needs topping up), 404, 409, 422 (invalid input), 429 (rate limited), 500. Rate limit: 120 requests per minute per key. ### Account - GET /me — Who am I. Your account, pricing tier and wallet balance. Good first call to test your key. Response: {"id":42,"name":"Jane","email":"jane@example.com","tier":"external","wallet":{"balance":25.5,"currency":"USD"}} - GET /wallet — Wallet and transactions. Balance and your last 50 wallet transactions. Services are paid monthly from this wallet. Response: {"balance":25.5,"currency":"USD","transactions":[{"id":901,"amount":-5,"balance_after":25.5,"type":"charge","description":"WhatsApp API number — first month","created_at":"2026-10-25T09:12:00+03:00"}],"top_up_url":"https://cleanpanels.co.ke/wallet"} - GET /prices — Your prices. What you pay per month, including any custom reseller pricing. Response: {"tier":"reseller","currency":"USD","custom_pricing":false,"monthly":{"whatsapp_number":4,"mailbox":1.5}} ### WhatsApp - POST /whatsapp/instances — Create a WhatsApp number. Starts a new number (first month charged from your wallet) and returns a QR code. Scan it in WhatsApp → Linked devices. Body: {"name":"Support","webhook_url":"https://yourapp.com/whatsapp-webhook"}. Response: {"id":12,"name":"Support","status":"pending","webhook_secret":"whsec_…","connection":{"status":"qr","qr":"data:image/png;base64,…"}} - GET /whatsapp/instances — List numbers. All your WhatsApp numbers with status and message counts. Response: {"data":[{"id":12,"name":"Support","status":"connected","phone":"254712345678","messages_in":120,"messages_out":96}]} - GET /whatsapp/instances/12/qr — Connection status / QR. Poll every few seconds while linking: returns a fresh QR until status becomes "connected". Response: {"status":"connected","phone":"254712345678"} - POST /whatsapp/instances/12/send — Send a message. "to" is a phone number in international format (digits only) OR a group ID (JID) ending in @g.us from GET …/groups. In groups you can @mention people: add "mentions": ["254711111111"] and write "@254711111111" in the text. The number must be a member of the group (and an admin if only admins can send). Body: {"to":"254712345678","text":"Your order #20481 is complete ✅"}. Response: {"sent":true,"to":"254712345678","group":false,"message_id":"3EB0C4A1F2"} - POST /whatsapp/instances/12/send — Send to a group. Same endpoint, with a group JID as "to". Get group IDs from GET …/groups. Incoming group messages arrive at your webhook with group=true, group_id, group_name and chat_id (send your reply to chat_id). Body: {"to":"120363025246125486@g.us","text":"New services added today 🚀 @254711111111","mentions":["254711111111"]}. Response: {"sent":true,"to":"120363025246125486@g.us","group":true,"message_id":"3EB0C4A1F3"} - POST /whatsapp/instances/12/send — Send an image, video, document or audio. Same endpoint with "type" = image, video, document or audio and ONE source: "media_url" (a public https link we download; up to the full WhatsApp limit), "media_base64" (inline; whole request up to 25 MB) or "media_id" (from POST …/media; send it to many chats). Optional "caption" (up to 1024 characters; not for audio), "filename" and "mimetype" (documents), "ptt": true (audio as a voice note). Limits: image 5 MB (JPEG, PNG), video 16 MB (MP4, 3GP), audio 16 MB (OGG Opus, MP3, M4A/AAC, AMR), document 100 MB (any file). The real file type is checked. Errors: {"sent":false,"error":{"code":"media_too_large","message":"…"}}, codes: invalid_type, missing_media, ambiguous_media, invalid_media_url, media_url_blocked, media_download_failed, invalid_base64, media_not_found, media_too_large, unsupported_media_type, caption_too_long, caption_not_allowed, invalid_recipient, not_connected, rate_limited, daily_limit_reached, send_failed. Requests without media fields work exactly as before. Body: {"to":"254712345678","type":"document","media_url":"https://yourshop.com/invoices/20481.pdf","filename":"Invoice 20481.pdf","mimetype":"application/pdf","caption":"Your invoice"}. Response: {"sent":true,"id":"3EB0C4A1F4","message_id":"3EB0C4A1F4","to":"254712345678","group":false,"type":"document","size":48213} - POST /whatsapp/instances/12/media — Upload a file to send. Upload once, send many times with "media_id" (kept 3 days). Send a multipart form with a "file" field (up to 25 MB) or JSON with media_url / media_base64; "type" is optional (we detect it). GET …/media/{media_id} shows a file, DELETE removes it. Body: {"media_url":"https://yourshop.com/promo.jpg","type":"image"}. Response: {"media_id":"9f2c…","type":"image","mimetype":"image/jpeg","filename":"promo.jpg","size":182311,"url":"https://cleanpanels.co.ke/wa-media/9f2c…","expires_at":"2026-12-01T10:00:00+00:00"} - GET /whatsapp/instances/12/groups — List groups. Groups this number is a member of. "id" is the group JID to send to. can_send=false means only admins may post there. Cached for 2 minutes; add ?refresh=1 after joining a new group. Response: {"data":[{"id":"120363025246125486@g.us","name":"VIP Customers","participants":148,"is_admin":true,"admins_only":false,"can_send":true}]} - PATCH /whatsapp/instances/12 — Change settings. Change name, webhook_url or respond_groups. Body: {"webhook_url":"https://yourapp.com/new-webhook","respond_groups":false}. Response: {"id":12,"name":"Support","webhook_url":"https://yourapp.com/new-webhook","respond_groups":false} - GET /whatsapp/instances/12/messages — Recent messages. The last 100 messages in and out. Response: {"data":[{"direction":"in","peer":"254712345678","text":"20481 status","status":"received","created_at":"2026-10-25T10:01:00+03:00"}]} - DELETE /whatsapp/instances/12 — Unlink / delete. Deletes the number and stops billing. Use POST …/12/logout to only unlink the phone. Response: {"deleted":true} ### Email - POST /email/domains — Add an email domain. Creates the domain and its DKIM key (ready in about a minute). Returns the DNS records to publish. Body: {"domain":"brandx.com"}. Response: {"id":42,"domain":"brandx.com","status":"provisioning","dns_records":[{"type":"TXT","name":"brandx.com","value":"v=spf1 a mx ip4:… ~all"}]} - POST /email/domains/42/cloudflare — One-click DNS with Cloudflare. Your customer's Cloudflare token (template "Edit zone DNS") — used once, never stored. Merges SPF, adds DKIM and DMARC, and MX only if receive_mail is true. Body: {"api_token":"CLOUDFLARE_TOKEN","receive_mail":true,"replace_mx":false}. Response: {"cloudflare":{"zone":"brandx.com","changes":["Updated your SPF record to include our server","Added DKIM record","Added DMARC record","Added MX record — email to brandx.com now arrives here"]},"can_send":true,"can_receive":true} - GET /email/domains/42/dns — Live DNS check. Checks every record against public DNS. Each has status ok | missing | wrong | warn | info, what was found, and a fix. Response: {"summary":{"can_send":false,"can_receive":false,"inbox_ready":false,"records":{"spf":"wrong","dkim":"ok","dmarc":"warn","mx":"info"}},"dns_check":[{"key":"spf","status":"wrong","message":"Your SPF record does not include our server yet. Replace it with:","suggest":"v=spf1 ip4:… include:_spf.google.com ~all"}]} - POST /email/mailboxes — Create a mailbox. On your verified domain (domain_id) or the shared domain ("domain":"shared"). The password is shown only once. Body: {"domain_id":42,"name":"support"}. Response: {"id":7,"address":"support@brandx.com","status":"provisioning","smtp":{"host":"mail.cleanpanels.co.ke","port_ssl":465,"port_tls":587,"username":"support@brandx.com","password":"…","imap_host":"mail.cleanpanels.co.ke","imap_port":993}} - PATCH /email/mailboxes/7 — Forwarding, auto-reply, aliases, size. Send only what you want to change. forward_to: up to 10 addresses ([] = off); keep_copy: false forwards without storing; aliases: extra addresses delivering to this mailbox; quota_mb: 512, 1024 or 2048; password: set your own (10+ letters and numbers). Live within a minute. Body: {"forward_to":["owner@gmail.com"],"keep_copy":true,"autoreply":{"enabled":true,"message":"Thanks! We reply within 24 hours."},"aliases":["sales","hello"],"quota_mb":2048}. Response: {"id":7,"address":"support@brandx.com","status":"active","settings":{"forward_to":["owner@gmail.com"],"keep_copy":true,"autoreply":{"enabled":true,"message":"Thanks! We reply within 24 hours."},"aliases":["sales@brandx.com","hello@brandx.com"],"quota_mb":2048,"state":"syncing"},"changed":["forwarding","auto-reply","aliases","storage"]} - PATCH /email/domains/42 — Catch-all for a domain. Mail to any address @domain that does not exist is delivered here instead of bouncing. Send null to turn it off. Body: {"catchall":"support@brandx.com"}. Response: {"id":42,"domain":"brandx.com","status":"active","catchall":"support@brandx.com","can_send":true,"can_receive":true} - POST /email/mailboxes/7/reset-password — New mailbox password. Generates a new password (takes effect within a minute). Response: {"password":"…","note":"Takes effect within a minute."} ### WhatsApp webhook We POST each incoming message as JSON to your webhook_url: {"event":"message","instance_id":12,"from":"254712345678","name":"Jane","text":"…","group":false,"group_id":"","group_name":"","chat_id":"254712345678","timestamp":1761300000}. In groups: group=true, group_id/chat_id = the group JID (…@g.us), from = the member who wrote. Send to a group: POST /whatsapp/instances/{id}/send with "to" set to the group JID; list groups with GET /whatsapp/instances/{id}/groups. Header X-Signature: sha256=HMAC_SHA256(raw_body, webhook_secret) — verify it with a constant-time compare. Respond within 10 seconds with {"reply":"text"} to answer, or {} to stay silent. Every event has "type": text, image, video, audio, document or sticker. Files a customer sends (e.g. an M-PESA screenshot) come with "media": {"media_id","type","mimetype","filename","size","sha256","url","expires_at","caption"}; "text" is the caption. The url is a private download link (keep it secret), valid for 7 days; save the file if you need it longer. If we could not fetch the file, media.error is set (e.g. too_large, download_failed).