# Kirem (kirem.co) > WhatsApp Business API Developer Infrastructure berstandar enterprise. Kirem adalah platform gerbang API (API Gateway) dan perute webhook (Webhook Router) multi-tenant yang diletakkan di atas Meta WhatsApp Cloud API. Dirancang khusus untuk developer, agensi, penyedia CRM, dan startup SaaS untuk mengintegrasikan WhatsApp Business API tanpa hambatan teknis. --- ## 🔑 Konsep Utama Kirem ### 1. WABA Coexistence (Nomor Bersamaan HP & API) Secara default, Meta WhatsApp Business API tidak memperbolehkan nomor terhubung digunakan di aplikasi HP WhatsApp Messenger/Business biasa. Kirem memecahkan masalah ini dengan sistem **Coexistence**: - Pemilik bisnis tetap dapat menggunakan aplikasi handphone WhatsApp biasa untuk CS/manual chat. - API Kirem tetap aktif di latar belakang menerima pesan masuk dan merutekannya tanpa konflik. ### 2. Rule-Based Webhook Routing Meneruskan satu event WhatsApp masuk ke beberapa endpoint konsumen (multi-consumer webhook) secara bersamaan. - Aturan (rules) dapat dibuat berdasarkan: jenis pesan (text, image, interactive), nomor pengirim, kata kunci konten, atau regex. - Mendukung retry otomatis (exponential backoff) dan replay manual jika backend tujuan down. ### 3. Strict Tenant & Token Isolation - Token akses WABA dienkripsi menggunakan AES-256-GCM tingkat perbankan di database. - Setiap project berada dalam isolasi data multi-tenant yang ketat. --- ## 💳 Informasi Paket Harga (IDR) - **Developer**: Gratis selamanya. 1 channel, 20 pesan keluar/hari, retensi log 7 hari, 1 webhook target. - **Growth**: Rp 25.000 /bulan + usage. Proyek tak terbatas, 5 webhook routing rules, retensi log 30 hari, analytics API, IP whitelisting. - **Scale**: Rp 100.000 /bulan + usage. Customer Setup Link (CSL) API untuk onboarding otomatis klien Anda, dedicated outbound IPs, retensi log 90 hari, webhook target tak terbatas. - **Enterprise**: Rp 1.000.000 /bulan. Penempatan VPC privat / On-Premise, dedicated MCP endpoints, custom SLA thresholds. --- ## ⚡ Panduan API Developer (Quick Reference) ### Base URL - Public API: `https://api.kirem.co` ### Autentikasi Gunakan header Authorization Bearer Token: ```http Authorization: Bearer ``` --- ## 🛠️ REST API Specification ### 1. Kirim Pesan Teks (Meta-Compatible) `POST /v1/messages` - **Request Body**: ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "6282360419136", "type": "text", "text": { "body": "Halo dari Kirem!" } } ``` - **Success Response (200 OK)**: ```json { "status": 200, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{ "input": "6282360419136", "wa_id": "6282360419136" }], "messages": [{ "id": "wamid.HBgNNjI4MTIzNDU2Nzg5MBcGAgQRFRMyFAA=" }] } } ``` ### 2. Kirim Pesan Templat (Meta-Compatible) `POST /v1/messages` - **Request Body**: ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "6282360419136", "type": "template", "template": { "name": "otp_verification", "language": { "code": "id" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "123456" } ] } ] } } ``` ### 3. Mengirim Status Centang Biru (Read Receipt) `POST /v1/messages/read` - **Request Body**: ```json { "messaging_product": "whatsapp", "message_id": "wamid.HBgNNjI4MTIzNDU2Nzg5MBcGAgQRFRMyFAA=" } ``` ### 4. Upload Media ke WhatsApp `POST /v1/media` - **Request (Multipart Form-Data)**: - `file`: (binary file) - `messaging_product`: `whatsapp` - **Response**: ```json { "status": 200, "message": "Media uploaded successfully", "data": { "id": "1049284050215893" } } ``` ### 5. Webhook Security Verification Setiap event webhook yang dikirimkan Kirem menyertakan header tanda tangan HMAC-SHA256 untuk memvalidasi integritas pesan: ```http X-Kirem-Signature: sha256= ``` Dihitung menggunakan request payload mentah (raw body string) dan Webhook Secret Key milik proyek Anda. --- ## 🤖 AI & Agentic Integration (MCP Server) Kirem menyediakan endpoint kompatibel **Model Context Protocol (MCP)** untuk integrasi mandiri AI Agent (misalnya Claude Desktop/Cursor): - **MCP Endpoint**: `POST /v1/mcp` - Protokol menggunakan standard **JSON-RPC 2.0**. - Agent dapat memanggil fungsi `send_message`, `list_templates`, dan `view_analytics` secara langsung dari konteks chat. --- ### Fetch Filtered Message Logs (Go) Source: https://kirem.co/docs/pull-message-logs Use Go's standard `net/http` package to perform a GET request. Set the Authorization header and include query parameters directly in the URL for filtering and limiting results. The example prints the HTTP status of the response. ```go package main import ( "fmt" "net/http" ) func main() { url := "https://api.kirem.co/v1/analytics/messages?status=failed&limit=20" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() fmt.Println("Status:", resp.Status) } ``` -------------------------------- ### List Available Kirem MCP Tools Source: https://kirem.co/docs/mcp Use this method to get a schema and a complete list of tools supported by Kirem. This is the first step to understand available functionalities. ```json { "jsonrpc": "2.0", "method": "tools/list", "id": 1 } ``` ```json { "jsonrpc": "2.0", "result": { "tools": [ { "name": "send_message", "description": "Kirim pesan WhatsApp ke session chat/percakapan tertentu.", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "ID dari chat session/percakapan." }, "text": { "type": "string", "description": "Isi pesan teks yang ingin dikirim." } }, "required": ["session_id", "text"] } }, { "name": "list_conversations", "description": "Dapatkan daftar percakapan (chat sessions) aktif dalam proyek.", "inputSchema": { "type": "object", "properties": { "status": { "type": "string", "description": "Saring berdasarkan status percakapan (open, pending, resolved, on_hold). Opsional." } } } }, { "name": "get_conversation", "description": "Dapatkan detail percakapan (chat session) beserta riwayat timeline pesannya.", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "ID dari chat session/percakapan." } }, "required": ["session_id"] } } ] }, "id": 1 } ``` -------------------------------- ### Mengambil Daftar Templat Pesan Source: https://kirem.co/docs/list-templates Gunakan cURL untuk melakukan permintaan GET ke endpoint /v1/templates guna mengambil daftar semua templat pesan WhatsApp. Pastikan untuk menyertakan header Authorization. ```bash curl -X GET "https://api.kirem.co/v1/templates" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Mengambil Daftar Templat Pesan dengan Go Source: https://kirem.co/docs/list-templates Contoh Go untuk melakukan permintaan GET ke endpoint /v1/templates. Kode ini mencetak status respons HTTP. Pastikan untuk menyertakan header Authorization. ```go package main import ( "fmt" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.kirem.co/v1/templates", nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() fmt.Println("Status:", resp.Status) } ``` -------------------------------- ### Meta Cloud API Error Handling Example (400 Bad Request) Source: https://kirem.co/docs/response-wrapper This example shows how Kirem wraps specific errors from the Meta WhatsApp Cloud API within the standard error response. This is useful for diagnosing issues like unapproved message templates. ```json { "status": 400, "message": "( #132000) Template status is not APPROVED.", "errors": { "message": "( #132000) Template status is not APPROVED.", "type": "OAuthException", "code": 132000, "error_subcode": 2490001 } } ``` -------------------------------- ### Send Interactive Message - Quick Reply Buttons Source: https://kirem.co/docs/send-interactive This example demonstrates how to send a message with Quick Reply Buttons. Up to three buttons can be displayed below the chat message bubble, allowing users to interact easily without manual typing. ```APIDOC ## POST /v1/messages ### Description Sends an interactive message with Quick Reply Buttons. These buttons provide quick response options for users. ### Method POST ### Endpoint `/v1/messages` or `/v1/:phone_number_id/messages` ### Headers: - `Authorization`: `Bearer ` - `Content-Type`: `application/json` ### Request Body ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "interactive", "interactive": { "type": "button", "header": { "type": "text", "text": "Konfirmasi Pendaftaran" }, "body": { "text": "Apakah Anda bersedia melanjutkan pendaftaran?" }, "footer": { "text": "Layanan Pendaftaran Otomatis" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "btn_yes", "title": "Ya, bersedia" } }, { "type": "reply", "reply": { "id": "btn_no", "title": "Tidak, batalkan" } } ] } } } ``` ### Response (Success response details not provided in source) ``` -------------------------------- ### Fetch Failed Webhook Logs (Go) Source: https://kirem.co/docs/pull-webhook-logs Fetch failed webhook logs in Go using the net/http package. This example demonstrates setting the Authorization header and query parameters for filtering and limiting results. ```go package main import ( "fmt" "net/http" ) func main() { url := "https://api.kirem.co/v1/analytics/webhooks?is_success=false&limit=10" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() fmt.Println("Status:", resp.Status) } ``` -------------------------------- ### GET /v1/profile Source: https://kirem.co/docs/get-profile Endpoint ini mengambil informasi detail profil bisnis WhatsApp yang saat ini terdaftar di Meta. Gunakan endpoint ini untuk memverifikasi data profil sebelum melakukan pembaruan, atau untuk menampilkan informasi bisnis di aplikasi Anda. ```APIDOC ## GET /v1/profile ### Description Mengambil informasi detail profil bisnis WhatsApp yang terdaftar di Meta. ### Method GET ### Endpoint /v1/profile ### Parameters Endpoint ini tidak memerlukan parameter tambahan. Cukup sertakan header `Authorization`. ### Request Example ```curl curl -X GET "https://api.kirem.co/v1/profile" \ -H "Authorization: Bearer kirem_live_xxx" ``` ### Response #### Success Response (200 OK) - **about** (string) - Informasi singkat tentang bisnis Anda (ditampilkan di bawah nama bisnis) - **address** (string) - Alamat fisik bisnis yang tercantum di profil - **description** (string) - Deskripsi panjang bisnis Anda - **email** (string) - Alamat email kontak resmi bisnis - **vertical** (string) - Kategori industri bisnis Anda (contoh: `RETAIL`, `FINANCE`, `HEALTH`) - **websites** (array of strings) - Daftar situs web resmi (maksimal 2 tautan) - **profile_picture_url** (string) - URL gambar profil WhatsApp Business Anda #### Response Example ```json { "status": 200, "message": "Business profile retrieved successfully", "data": { "about": "Solusi Komunikasi Bisnis Terbaik", "address": "Gedung Cyber 2, Lt. 15, Jakarta Selatan", "description": "Kirem adalah platform WhatsApp Business API Developer Terpercaya.", "email": "support@kirem.co.id", "vertical": "RETAIL", "websites": [ "https://kirem.co.id", "https://docs.kirem.co.id" ], "profile_picture_url": "https://pps.whatsapp.net/v/t61.24694-24/..." } } ``` ``` -------------------------------- ### Send First Message Source: https://kirem.co/docs/quickstart This example demonstrates how to send your first message using the Kirem API via cURL. It includes the necessary endpoint, headers, and request body structure. ```APIDOC ## POST /v1/messages ### Description Send your first message using the Kirem API. ### Method POST ### Endpoint /v1/messages ### Request Body - **messaging_product** (string) - Required - Specifies the messaging product, e.g., "whatsapp". - **recipient_type** (string) - Required - Specifies the recipient type, e.g., "individual". - **to** (string) - Required - The recipient's phone number. - **type** (string) - Required - The type of message, e.g., "text". - **text** (object) - Required - Contains the text message content. - **body** (string) - Required - The body of the text message. ### Request Example ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "text", "text": { "body": "Halo! Ini adalah pesan uji coba pertama saya menggunakan Kirem API." } } ``` ### Response #### Success Response (201 Created) Indicates that the message was successfully sent. ``` -------------------------------- ### Send Interactive Message - List Messages Source: https://kirem.co/docs/send-interactive This example shows how to send a message with a List Menu. This feature allows for organized menu options, with up to 10 selectable rows within a dropdown button. ```APIDOC ## POST /v1/messages ### Description Sends an interactive message with a List Menu. This allows users to select from a list of predefined options presented in a dropdown. ### Method POST ### Endpoint `/v1/messages` or `/v1/:phone_number_id/messages` ### Headers: - `Authorization`: `Bearer ` - `Content-Type`: `application/json` ### Request Body ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "interactive", "interactive": { "type": "list", "header": { "type": "text", "text": "Pusat Layanan Kirem" }, "body": { "text": "Silakan pilih menu bantuan di bawah ini untuk memulai interaksi." }, "footer": { "text": "Kirem Bot Service" }, "action": { "button": "Pilih Bantuan", "sections": [ { "title": "Layanan Umum", "rows": [ { "id": "menu_billing", "title": "Cek Tagihan", "description": "Melihat rincian tagihan bulanan Anda" }, { "id": "menu_support", "title": "Hubungi Support", "description": "Hubungkan dengan tim developer support" } ] }, { "title": "Layanan Teknis", "rows": [ { "id": "menu_webhook_test", "title": "Uji Webhook", "description": "Kirim payload testing ke server Anda" } ] } ] } } } ``` ### Response (Success response details not provided in source) ``` -------------------------------- ### Mengambil Daftar Templat Pesan dengan Node.js Source: https://kirem.co/docs/list-templates Menggunakan pustaka axios di Node.js untuk melakukan permintaan GET ke endpoint /v1/templates. Respons data akan dicetak ke konsol. Pastikan untuk menyertakan header Authorization. ```javascript const axios = require('axios'); axios.get('https://api.kirem.co/v1/templates', { headers: { 'Authorization': 'Bearer kirem_live_xxx' } }).then(res => console.log(res.data)); ``` -------------------------------- ### Mengambil Daftar Templat Pesan dengan PHP Source: https://kirem.co/docs/list-templates Contoh PHP menggunakan cURL untuk melakukan permintaan GET ke endpoint /v1/templates. Respons akan dicetak ke output. Pastikan untuk menyertakan header Authorization. ```php console.log(res.data)); ``` -------------------------------- ### Successful Response (200 OK) for Business Profile Source: https://kirem.co/docs/get-profile This is an example of a successful response when retrieving a WhatsApp Business profile. It includes status, message, and detailed business data. ```json { "status": 200, "message": "Business profile retrieved successfully", "data": { "about": "Solusi Komunikasi Bisnis Terbaik", "address": "Gedung Cyber 2, Lt. 15, Jakarta Selatan", "description": "Kirem adalah platform WhatsApp Business API Developer Terpercaya.", "email": "support@kirem.co.id", "vertical": "RETAIL", "websites": [ "https://kirem.co.id", "https://docs.kirem.co.id" ], "profile_picture_url": "https://pps.whatsapp.net/v/t61.24694-24/..." } } ``` -------------------------------- ### Paginate Webhook Logs Source: https://kirem.co/docs/pull-webhook-logs Use 'limit' and 'offset' query parameters to navigate through webhook log results. 'limit' specifies the number of records per page, and 'offset' specifies the starting point. ```http # Halaman 1: 50 catatan pertama GET /v1/analytics/webhooks?limit=50&offset=0 # Halaman 2 GET /v1/analytics/webhooks?limit=50&offset=50 ``` -------------------------------- ### Fetch Failed Webhook Logs (Node.js) Source: https://kirem.co/docs/pull-webhook-logs Fetch failed webhook logs using Axios. This example shows how to set the Authorization header and filter by 'is_success' and 'limit'. It then logs the total count and details of each failed webhook. ```javascript const axios = require('axios'); axios.get('https://api.kirem.co/v1/analytics/webhooks', { headers: { 'Authorization': 'Bearer kirem_live_xxx' }, params: { is_success: false, limit: 10 } }).then(res => { const { total, logs } = res.data.data; console.log(`Total webhook gagal: ${total}`); logs.forEach(log => { console.log(`${log.url} — HTTP ${log.status_code} (${log.duration_ms}ms)`); }); }); ``` -------------------------------- ### Go Request to Get WhatsApp Business Profile Source: https://kirem.co/docs/get-profile A Go program to fetch WhatsApp Business profile details using the standard net/http package. It sets the Authorization header before making the request. ```go package main import ( "fmt" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.kirem.co/v1/profile", nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() fmt.Println("Status:", resp.Status) } ``` -------------------------------- ### Paginate Message Logs Source: https://kirem.co/docs/pull-message-logs Use `limit` and `offset` parameters to navigate through large result sets. `data.total` shows the total matching records, `data.limit` is the records per page, and `data.offset` is the current page's starting position. ```http # Halaman 1: 50 catatan pertama GET /v1/analytics/messages?limit=50&offset=0 # Halaman 2: 50 catatan berikutnya GET /v1/analytics/messages?limit=50&offset=50 # Halaman 3 GET /v1/analytics/messages?limit=50&offset=100 ``` -------------------------------- ### GET /v1/analytics/messages Source: https://kirem.co/docs/pull-message-logs Retrieves message logs. Supports pagination using `limit` and `offset` query parameters. Can also filter by `status` and `direction`. ```APIDOC ## GET /v1/analytics/messages ### Description Retrieves message logs. Supports pagination using `limit` and `offset` query parameters. Can also filter by `status` and `direction`. ### Method GET ### Endpoint /v1/analytics/messages ### Parameters #### Query Parameters - **limit** (integer) - Optional - The number of records to return per page. - **offset** (integer) - Optional - The starting position for the current page of results. - **status** (string) - Optional - Filters logs by their status (e.g., 'failed'). - **direction** (string) - Optional - Filters logs by their direction (e.g., 'outbound'). ### Response #### Success Response (200) - **data.total** (integer) - The total number of records matching the filter. - **data.limit** (integer) - The number of records per page. - **data.offset** (integer) - The starting position of the current page. - **data.logs** (array) - An array of log objects. ``` -------------------------------- ### cURL Request to Get WhatsApp Business Profile Source: https://kirem.co/docs/get-profile Use this cURL command to fetch the details of a WhatsApp Business profile. Ensure you include the Authorization header with your bearer token. ```bash curl -X GET "https://api.kirem.co/v1/profile" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Get Specific Conversation Details Source: https://kirem.co/docs/mcp Fetch the complete message history for a given conversation session to provide context. The `session_id` must be a valid UUID. ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_conversation", "arguments": { "session_id": "8a3d12d4-1a9b-4bfa-a7b3-c123456789ab" // Wajib berupa UUID session yang valid } }, "id": 3 } ``` ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "{"session":{"id":"8a3d12d4-1a9b-4bfa-a7b3-c123456789ab","status":"open"},"messages":[{"id":"msg_1","sender":"customer","text":"Halo, apakah produk X ready?","created_at":"..."}]}" } ] }, "id": 3 } ``` -------------------------------- ### PHP Request to Get WhatsApp Business Profile Source: https://kirem.co/docs/get-profile This PHP script uses cURL to request WhatsApp Business profile information. It sets the Authorization header and retrieves the response. ```php { console.log(`Total: ${res.data.data.total}`); console.log(`Logs: ${res.data.data.logs.length}`); console.log(res.data.data.logs); }); ``` -------------------------------- ### Contoh Kode (Go — io.Copy ke file) Source: https://kirem.co/docs/download-media Mengunduh file media di Go dan menyimpannya ke file lokal menggunakan io.Copy. Pastikan untuk menangani error dengan benar dalam implementasi produksi. ```go package main import ( "fmt" "io" "net/http" "os" ) func main() { url := "https://api.kirem.co/v1/media/18471948194819/download" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() file, _ := os.Create("downloaded_image.png") defer file.Close() io.Copy(file, resp.Body) fmt.Println("File berhasil disimpan!") } ``` -------------------------------- ### Menghapus Templat Pesan dengan Go Source: https://kirem.co/docs/delete-template Implementasi penghapusan templat pesan WhatsApp menggunakan Go. Nama templat di-URL encode menggunakan url.PathEscape sebelum dimasukkan ke dalam URL permintaan. ```go package main import ( "fmt" "net/http" "net/url" ) func main() { templateName := "promo_diskon_baru" encodedName := url.PathEscape(templateName) req, _ := http.NewRequest("DELETE", fmt.Sprintf("https://api.kirem.co/v1/templates/%s", encodedName), nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() fmt.Println("Status:", resp.Status) } ``` -------------------------------- ### Memfilter Templat Pesan Berdasarkan Status (Menunggu) Source: https://kirem.co/docs/list-templates Gunakan parameter query 'status=PENDING' untuk memfilter dan hanya menampilkan templat pesan WhatsApp yang sedang dalam proses peninjauan oleh Meta. Sertakan header Authorization. ```bash # Hanya tampilkan templat yang masih menunggu curl -X GET "https://api.kirem.co/v1/templates?status=PENDING" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Memfilter Templat Pesan Berdasarkan Status (Disetujui) Source: https://kirem.co/docs/list-templates Gunakan parameter query 'status=APPROVED' untuk memfilter dan hanya menampilkan templat pesan WhatsApp yang telah disetujui oleh Meta. Sertakan header Authorization. ```bash # Hanya tampilkan templat yang sudah disetujui curl -X GET "https://api.kirem.co/v1/templates?status=APPROVED" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Menghapus Templat Pesan dengan Node.js (Axios) Source: https://kirem.co/docs/delete-template Contoh penghapusan templat pesan WhatsApp menggunakan library Axios di Node.js. Nama templat perlu di-URL encoding sebelum dikirimkan dalam permintaan DELETE. ```javascript const axios = require('axios'); const templateName = 'promo_diskon_baru'; const encodedName = encodeURIComponent(templateName); axios.delete(`https://api.kirem.co/v1/templates/${encodedName}`, { headers: { 'Authorization': 'Bearer kirem_live_xxx' } }).then(res => console.log(res.data)); ``` -------------------------------- ### Mengirim Pesan Templat (Template) Source: https://kirem.co/docs/send-template Endpoint ini digunakan untuk mengirimkan pesan menggunakan templat pesan yang telah didaftarkan dan disetujui oleh Meta. Templat pesan wajib digunakan untuk membuka sesi obrolan baru dengan pelanggan jika di luar jendela interaksi 24 jam. ```APIDOC ## POST /v1/messages ### Description Endpoint ini digunakan untuk mengirimkan pesan menggunakan templat pesan (_Message Template_) yang telah didaftarkan dan disetujui (_APPROVED_) oleh Meta. Templat pesan wajib digunakan untuk membuka sesi obrolan baru dengan pelanggan jika di luar jendela interaksi 24 jam. ### Method POST ### Endpoint - `POST /v1/messages` (Routing otomatis menggunakan saluran aktif pertama) - `POST /v1/:phone_number_id/messages` (Routing melalui nomor tertentu) ### Headers - `Authorization: Bearer ` - `Content-Type: application/json ### Request Body ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "template", "template": { "name": "promo_diskon_baru", "language": { "code": "id" }, "components": [ { "type": "header", "parameters": [ { "type": "text", "text": "Budi" } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "50" }, { "type": "text", "text": "HEMAT50" } ] } ] } } ``` ### Parameters #### Request Body Fields - `messaging_product` (String - Wajib): Produk pengiriman pesan, contoh: `"whatsapp"`. - `recipient_type` (String - Wajib): Tipe penerima, contoh: `"individual"`. - `to` (String - Wajib): Nomor telepon penerima. - `type` (String - Wajib): Tipe pesan, harus `"template"`. - `template` (Object - Wajib): Objek yang berisi detail templat pesan. - `name` (String - Wajib): Nama unik templat pesan yang sudah disetujui Meta. - `language` (Object - Wajib): Objek yang berisi kode bahasa templat. - `code` (String - Wajib): Kode bahasa templat (misal: `"id"` untuk Bahasa Indonesia, `"en"` untuk Bahasa Inggris). - `components` (Array - Opsional): Kumpulan komponen yang mendefinisikan nilai variabel dinamis pada templat. - `type` (String - Wajib): Jenis komponen (`header`, `body`, `button`). - `parameters` (Array - Wajib): Array nilai parameter yang disubstitusikan ke dalam variabel secara berurutan. - `type` (String - Wajib): Tipe parameter (`text`, `currency`, `date_time`, `image`, `document`, `video`). - `text` (String - Wajib): Isi nilai teks pengganti jika tipe parameter adalah `"text"`. ### Response #### Success Response (201 Created) ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [ { "input": "62812345678", "wa_id": "62812345678" } ], "messages": [ { "id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG" } ] } } ``` #### Response Fields - `status` (Integer): Kode status respons HTTP. - `message` (String): Pesan status pengiriman. - `data` (Object): Objek berisi detail pengiriman pesan. - `messaging_product` (String): Produk pengiriman pesan. - `contacts` (Array): Array informasi kontak penerima. - `input` (String): Input nomor telepon penerima. - `wa_id` (String): WhatsApp ID penerima. - `messages` (Array): Array informasi pesan yang dikirim. - `id` (String): ID pesan untuk memantau status pengantaran via webhook callback. ``` -------------------------------- ### Contoh cURL Request (simpan ke file) Source: https://kirem.co/docs/download-media Gunakan perintah cURL untuk mengunduh file media dan menyimpannya ke file lokal. Pastikan untuk mengganti placeholder media_id dan token otorisasi. ```bash curl -X GET "https://api.kirem.co/v1/media/18471948194819/download" \ -H "Authorization: Bearer kirem_live_xxx" \ --output downloaded_image.png ``` -------------------------------- ### ngrok command for local development Source: https://kirem.co/docs/n8n-whatsapp-bot Use ngrok to expose your local development server to the internet, making your n8n webhook accessible. ```bash ngrok http 5678 ``` -------------------------------- ### Contoh Kode (Node.js — stream ke file) Source: https://kirem.co/docs/download-media Mengunduh file media menggunakan Axios di Node.js dan menyimpannya ke file lokal menggunakan stream. Pastikan untuk menginstal pustaka 'axios' dan 'fs' sudah tersedia. ```javascript const axios = require('axios'); const fs = require('fs'); axios.get('https://api.kirem.co/v1/media/18471948194819/download', { headers: { 'Authorization': 'Bearer kirem_live_xxx' }, responseType: 'stream' }).then(res => { res.data.pipe(fs.createWriteStream('downloaded_image.png')); console.log('File berhasil disimpan!'); }); ``` -------------------------------- ### Kirem Node - Send Welcome Reply Source: https://kirem.co/docs/n8n-whatsapp-bot Configure the Kirem node to send a welcome message. Set the Resource to 'Message', Operation to 'Send', and provide the Phone Number ID. The 'To' field should dynamically capture the sender's number, and the 'Body' contains the welcome text. ```text Resource : Message Operation : Send Phone Number ID : (ID nomor WhatsApp Anda dari Dasbor Kirem) To : {{ $json.body.entry[0].changes[0].value.messages[0].from }} Message Type : Text Body : Halo! 👋 Selamat datang di layanan kami. Berikut yang bisa saya bantu: - Ketik *Harga* untuk info produk & harga - Ketik *Bantuan* untuk bantuan pelanggan - Ketik *Jam* untuk jam operasional ``` -------------------------------- ### Mengirim Pesan Video via Endpoint Source: https://kirem.co/docs/send-video Endpoint ini digunakan untuk mengirimkan berkas video (MP4/3GP) ke pelanggan. Mendukung pengiriman menggunakan Media ID Meta atau Tautan URL video eksternal. ```APIDOC ## POST /v1/messages ### Description Endpoint ini digunakan untuk mengirimkan berkas video (MP4/3GP) ke pelanggan. Layaknya gambar, pengiriman video mendukung dua metode: menggunakan **Media ID** Meta atau menggunakan **Tautan URL** video eksternal secara langsung. ### Method POST ### Endpoint - `POST /v1/messages` (Routing otomatis menggunakan saluran aktif pertama) - `POST /v1/:phone_number_id/messages` (Routing melalui nomor tertentu) ### Headers - `Authorization: Bearer ` - `Content-Type: application/json` ### Request Body #### Metode A: Menggunakan Media ID (Direkomendasikan) ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "video", "video": { "id": "18471948194820", "caption": "Silakan tonton video demo produk kami" } } ``` #### Metode B: Menggunakan Tautan URL Langsung ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "video", "video": { "link": "https://kirem.id/assets/demo-video.mp4", "caption": "Video Tutorial Penggunaan Kirem API" } } ``` ### Parameters #### Request Body Parameters - `type` (String - Wajib): Set nilai ke `"video"`. - `video.id` (String - Wajib jika tidak memakai link): ID media video hasil unggahan. - `video.link` (String - Wajib jika tidak memakai ID): Tautan HTTPS langsung ke file video (harus berakhiran format video, misal `.mp4`/`.3gp`). - `video.caption` (String - Opsional): Teks keterangan yang disematkan tepat di bawah pratinjau video di aplikasi pelanggan. ### Response #### Success Response (201 Created) ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` - `messages[0].id`: ID pesan unik untuk melacak status pengantaran via webhook. ``` -------------------------------- ### Switch Node Configuration for Keyword Matching Source: https://kirem.co/docs/n8n-whatsapp-bot Set up a Switch node to route messages based on keywords. Use the message body as input and define rules for matching specific terms like 'Harga', 'Bantuan', or 'Jam' to different outputs. ```text Mode : Rules Input : {{ $json.body.entry[0].changes[0].value.messages[0].text.body }} Aturan | Operator | Nilai | Output ---|---|---|--- `contains` | Halo | 1 (Sambutan) | `contains` | Hai | 1 (Sambutan) | `contains` or `matches` | Harga | 2 (Harga) | `contains` or `matches` | Bantuan | 3 (Bantuan) | `contains` or `matches` | Jam | 4 (Jam Operasional) | ``` -------------------------------- ### Membuat Templat Pesan Notifikasi Pesanan Source: https://kirem.co/docs/woocommerce-order-notif Gunakan endpoint POST /v1/templates untuk membuat templat pesan WhatsApp yang akan digunakan untuk notifikasi pesanan baru. Pastikan templat disetujui sebelum melanjutkan. ```json { "name": "notif_pesanan_baru", "category": "UTILITY", "language": "id", "components": [ { "type": "BODY", "text": "Halo {{1}}, terima kasih telah berbelanja di {{2}}!\n\nPesanan #{{3}} telah kami terima.\nTotal: Rp {{4}}\n\nKami akan segera memproses pesanan Anda." } ] } ``` -------------------------------- ### Menghapus Templat Pesan dengan cURL Source: https://kirem.co/docs/delete-template Contoh penggunaan cURL untuk menghapus templat pesan WhatsApp. Pastikan untuk menyertakan nama templat yang sudah di-URL encoding pada path dan header Authorization. ```bash curl -X DELETE "https://api.kirem.co/v1/templates/promo_diskon_baru" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Mengambil Informasi Profil Bisnis Source: https://kirem.co/docs/manage-profile Gunakan contoh cURL ini untuk mengambil detail profil bisnis WhatsApp yang terdaftar di Meta. Pastikan Anda menyertakan channel_id yang valid. ```bash curl -X GET "https://api.kirem.id/v1/profile?channel_id=chan-123" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Build Product List for WhatsApp Notification Source: https://kirem.co/docs/woocommerce-order-notif In the `kirem_send_order_notification` function, iterate through order items to build a formatted string of products and their quantities. This string is then passed as the fifth parameter to the notification. ```php // Di dalam fungsi kirem_send_order_notification, tambahkan: $items = $order->get_items(); $product_list = ''; foreach ($items as $item) { $product_name = $item->get_name(); $quantity = $item->get_quantity(); $product_list .= "- {$product_name} x{$quantity}\n"; } // Tambahkan parameter ke-5: ['type' => 'text', 'text' => $product_list], ``` -------------------------------- ### Mengirim Pesan Gambar via Endpoint Source: https://kirem.co/docs/send-image Endpoint ini digunakan untuk mengirimkan berkas gambar (JPEG/PNG) ke pelanggan. WhatsApp mendukung dua metode pengiriman gambar: menggunakan Media ID (berkas yang telah diunggah sebelumnya di server Meta) atau menggunakan Tautan URL gambar eksternal secara langsung. ```APIDOC ## POST /v1/messages atau POST /v1/:phone_number_id/messages ### Description Endpoint ini digunakan untuk mengirimkan berkas gambar (JPEG/PNG) ke pelanggan. WhatsApp mendukung dua metode pengiriman gambar: menggunakan **Media ID** (berkas yang telah diunggah sebelumnya di server Meta) atau menggunakan **Tautan URL** gambar eksternal secara langsung. ### Method POST ### Endpoint - `POST /v1/messages` (Routing otomatis menggunakan saluran aktif pertama) - `POST /v1/:phone_number_id/messages` (Routing melalui nomor tertentu) ### Headers - `Authorization: Bearer ` - `Content-Type: application/json` ### Request Body #### Metode A: Menggunakan Media ID (Direkomendasikan) ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "image", "image": { "id": "18471948194819", "caption": "Silakan lihat gambar brosur promo kami" } } ``` #### Metode B: Menggunakan Tautan URL Langsung ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "image", "image": { "link": "https://kirem.id/assets/promo-poster.png", "caption": "Brosur Promo Akhir Tahun Kirem" } } ``` ### Parameters - `type` (String - Wajib): Set nilai ke "image". - `image.id` (String - Wajib jika tidak memakai link): ID media gambar hasil unggahan. - `image.link` (String - Wajib jika tidak memakai ID): Tautan HTTPS langsung ke file gambar yang dihosting di server Anda (harus berakhiran format gambar, misal `.jpg`/`.png`). - `image.caption` (String - Opsional): Teks keterangan yang disematkan tepat di bawah pratinjau gambar di aplikasi pelanggan. ### Response #### Success Response (201 Created) ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` **Note**: Meta membatasi ukuran file gambar maksimal sebesar 5 MB dengan format file yang didukung adalah `image/jpeg` dan `image/png`. ``` -------------------------------- ### Menghapus Templat Pesan Source: https://kirem.co/docs/delete-template Endpoint ini menghapus templat pesan WhatsApp yang sudah terdaftar dari sistem Meta. Penghapusan bersifat permanen dan tidak dapat dikembalikan. ```APIDOC ## DELETE /v1/templates/:name ### Description Endpoint ini menghapus templat pesan WhatsApp yang sudah terdaftar dari sistem Meta. Penghapusan bersifat permanen — templat yang telah dihapus **tidak dapat dikembalikan**. ### Method DELETE ### Endpoint `/v1/templates/:name` Parameter `:name` adalah nama templat yang akan dihapus. Jika nama mengandung karakter khusus, lakukan **URL encoding** (misalnya spasi menjadi `%20`). ### Parameters Endpoint ini **tidak memerlukan query parameter tambahan**. Cukup sertakan nama templat pada path URL dan header `Authorization`. ### Request Example ```curl curl -X DELETE "https://api.kirem.co/v1/templates/promo_diskon_baru" \ -H "Authorization: Bearer kirem_live_xxx" ``` ### Response #### Success Response (200 OK) - **status** (integer) - 200 - **message** (string) - Template deleted successfully - **data** (object) - **success** (boolean) - true #### Response Example ```json { "status": 200, "message": "Template deleted successfully", "data": { "success": true } } ``` #### Error Response - **404 Not Found**: Jika nama templat tidak ditemukan. ``` -------------------------------- ### Melihat Daftar Templat Pesan Source: https://kirem.co/docs/list-templates Endpoint ini mengembalikan daftar seluruh templat pesan WhatsApp yang terdaftar pada akun bisnis Anda di Meta, beserta informasi status persetujuan, kategori, bahasa, dan komponen penyusunnya. ```APIDOC ## GET /v1/templates ### Description Mengambil daftar lengkap templat pesan WhatsApp yang terdaftar beserta status persetujuannya. ### Method GET ### Endpoint /v1/templates ### Parameters #### Query Parameters - **status** (string) - Optional - Memfilter templat berdasarkan status persetujuan (misalnya, "APPROVED", "PENDING"). ### Request Example ``` curl -X GET "https://api.kirem.co/v1/templates?status=APPROVED" \ -H "Authorization: Bearer kirem_live_xxx" ``` ### Response #### Success Response (200 OK) - **status** (integer) - Kode status respons. - **message** (string) - Pesan yang menjelaskan hasil operasi. - **data** (array) - Daftar objek templat pesan. - **name** (string) - Nama templat. - **status** (string) - Status persetujuan templat (misalnya, "APPROVED", "PENDING", "REJECTED"). - **category** (string) - Kategori templat (misalnya, "AUTHENTICATION", "MARKETING"). - **language** (string) - Kode bahasa templat. - **components** (array) - Daftar komponen penyusun templat. - **type** (string) - Tipe komponen (misalnya, "BODY", "HEADER", "BUTTONS"). - **text** (string) - Teks konten komponen (jika berlaku). - **format** (string) - Format komponen (jika berlaku, misalnya "TEXT"). - **buttons** (array) - Daftar tombol (jika tipe komponen adalah "BUTTONS"). - **type** (string) - Tipe tombol (misalnya, "QUICK_REPLY"). - **text** (string) - Teks tombol. - **id** (string) - ID unik templat. #### Response Example ```json { "status": 200, "message": "Templates retrieved successfully", "data": [ { "name": "otp_verification", "status": "APPROVED", "category": "AUTHENTICATION", "language": "id", "components": [ { "type": "BODY", "text": "Kode keamanan OTP Kirem Anda adalah: {{1}}." } ], "id": "18491849184919" } ] } ``` ``` -------------------------------- ### Create a New Template Source: https://kirem.co/docs/create-template Use this cURL command to send a POST request to create a new message template. Ensure you include your authorization token and a JSON payload defining the template's name, category, language, and components. ```bash curl -X POST https://api.kirem.co/v1/templates \ -H "Authorization: Bearer kirem_live_xxx" \ -H "Content-Type: application/json" \ -d '{ \ "name": "konfirmasi_pesanan", \ "category": "UTILITY", \ "language": "id", \ "components": [ \ { \ "type": "BODY", \ "text": "Halo {{1}}, pesanan Anda #{{2}} telah dikonfirmasi. Estimasi pengiriman: {{3}} hari kerja." \ }, \ { \ "type": "BUTTONS", \ "buttons": [ \ { \ "type": "QUICK_REPLY", \ "text": "Lacak Pesanan" \ }, \ { \ "type": "URL", \ "text": "Lihat Status", \ "url": "https://kirem.co.id/pesanan/{{2}}" \ } \ ] \ } \ ] \ }' ``` -------------------------------- ### Mendapatkan Informasi Profil Bisnis Source: https://kirem.co/docs/manage-profile Mengambil detail informasi profil bisnis WhatsApp yang saat ini terdaftar di Meta. ```APIDOC ## GET /v1/profile ### Description Mengambil detail informasi profil bisnis WhatsApp yang saat ini terdaftar di Meta. ### Method GET ### Endpoint /v1/profile #### Query Parameters - **channel_id** (String - Wajib): ID saluran WhatsApp terdaftar. ### Request Example ```curl curl -X GET "https://api.kirem.id/v1/profile?channel_id=chan-123" \ -H "Authorization: Bearer kirem_live_xxx" ``` ### Response #### Success Response (200 OK) - **status** (Integer) - Kode status respons. - **message** (String) - Pesan yang menjelaskan hasil operasi. - **data** (Object) - Objek yang berisi detail profil bisnis. - **about** (String) - Informasi singkat tentang bisnis. - **address** (String) - Alamat fisik bisnis. - **description** (String) - Deskripsi bisnis. - **email** (String) - Email kontak resmi bisnis. - **vertical** (String) - Kategori industri bisnis. - **websites** (Array of Strings) - Daftar situs web resmi. - **profile_picture_url** (String) - URL gambar profil. #### Response Example ```json { "status": 200, "message": "Business profile retrieved successfully", "data": { "about": "Solusi Komunikasi Bisnis Terbaik", "address": "Gedung Cyber 2, Lt. 15, Jakarta Selatan", "description": "Kirem adalah platform WhatsApp Business API Developer Terpercaya.", "email": "support@kirem.id", "vertical": "RETAIL", "websites": [ "https://kirem.id", "https://docs.kirem.id" ], "profile_picture_url": "https://pps.whatsapp.net/v/t61.24694-24/..." } } ``` ``` -------------------------------- ### Memperbarui Informasi Profil Bisnis Source: https://kirem.co/docs/manage-profile Memperbarui detail profil WhatsApp Business resmi Anda secara instan ke Meta. ```APIDOC ## POST /v1/profile ### Description Memperbarui detail profil WhatsApp Business resmi Anda secara instan ke Meta. ### Method POST ### Endpoint /v1/profile #### Query Parameters - **channel_id** (String - Wajib): ID saluran WhatsApp terdaftar. #### Request Body - **about** (String - Opsional): Informasi singkat tentang bisnis Anda (maksimal 139 karakter). - **address** (String - Opsional): Alamat fisik bisnis Anda (maksimal 256 karakter). - **description** (String - Opsional): Deskripsi bisnis Anda (maksimal 256 karakter). - **email** (String - Opsional): Email kontak resmi bisnis Anda. - **vertical** (String - Opsional): Kategori industri bisnis Anda. Nilai yang didukung meliputi: `AUTO`, `BEAUTY`, `APPAREL`, `EDU`, `ENTERTAIN`, `FINANCE`, `GROCERY`, `GOVT`, `HOTEL`, `HEALTH`, `NONPROFIT`, `PROF_SERVICES`, `RETAIL`, `TRAVEL`, `RESTAURANT`, atau `OTHER`. - **websites** (Array of Strings - Opsional): Daftar situs web resmi (maksimal 2 tautan). ### Request Example ```json { "about": "Solusi Komunikasi Bisnis Terpadu", "address": "Gedung Cyber 2, Lt. 17, Jakarta Selatan", "description": "Kirem menyediakan API WhatsApp handal untuk integrasi enterprise.", "email": "help@kirem.id", "vertical": "RETAIL", "websites": [ "https://kirem.id", "https://kirem.id/blog" ] } ``` ### Response #### Success Response (200 OK) - **status** (Integer) - Kode status respons. - **message** (String) - Pesan yang menjelaskan hasil operasi. - **data** (Object) - Objek yang berisi status pembaruan. - **success** (Boolean) - Menunjukkan apakah pembaruan berhasil. #### Response Example ```json { "status": 200, "message": "Business profile updated successfully", "data": { "success": true } } ``` ``` -------------------------------- ### Create Template Source: https://kirem.co/docs/create-template Creates a new template by sending a POST request to the /v1/templates endpoint. The request body includes the template's name, category, language, and components. ```APIDOC ## POST /v1/templates ### Description Creates a new template with specified components. ### Method POST ### Endpoint https://api.kirem.co/v1/templates ### Parameters #### Request Body - **name** (string) - Required - The name of the template. - **category** (string) - Required - The category of the template (e.g., UTILITY). - **language** (string) - Required - The language of the template (e.g., id). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., BODY, BUTTONS). - **text** (string) - Optional - The text content for BODY components or button text. - **buttons** (array) - Optional - An array of buttons for BUTTONS components. - **type** (string) - Required - The type of button (e.g., QUICK_REPLY, URL). - **text** (string) - Required - The text displayed on the button. - **url** (string) - Optional - The URL for URL type buttons. ### Request Example ```json { "name": "konfirmasi_pesanan", "category": "UTILITY", "language": "id", "components": [ { "type": "BODY", "text": "Halo {{1}}, pesanan Anda #{{2}} telah dikonfirmasi. Estimasi pengiriman: {{3}} hari kerja." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Lacak Pesanan" }, { "type": "URL", "text": "Lihat Status", "url": "https://kirem.co.id/pesanan/{{2}}" } ] } ] } ``` ### Response #### Success Response (200 OK) - **status** (integer) - The HTTP status code. - **message** (string) - A message indicating the success of the operation. - **data** (object) - Contains details about the created template. - **id** (string) - The unique ID of the newly created template. - **status** (string) - The initial status of the template (always PENDING). - **category** (string) - The registered category of the template. #### Response Example ```json { "status": 200, "message": "Template created successfully", "data": { "id": "194819481948194", "status": "PENDING", "category": "UTILITY" } } ``` ``` -------------------------------- ### Callback Webhook Klik Tombol (Quick Reply) Source: https://kirem.co/docs/send-interactive Contoh payload webhook yang diterima server ketika pelanggan mengklik tombol Quick Reply. Gunakan 'id' untuk mengeksekusi logika alur bot selanjutnya. ```json { "event": "messages.received", "data": { "from": "62812345678", "message_id": "wamid.HBgLN...", "type": "interactive", "interactive": { "type": "button_reply", "button_reply": { "id": "btn_yes", "title": "Ya, bersedia" } } } } ``` -------------------------------- ### tools/list Source: https://kirem.co/docs/mcp Retrieves the schema and a complete list of tools supported by Kirem. This is useful for an AI Agent to understand its capabilities. ```APIDOC ## tools/list ### Description Used to get the schema and a complete list of tools supported by Kirem. ### Method POST ### Endpoint /tools/list ### Request Body - **jsonrpc** (string) - Required - JSON RPC version. - **method** (string) - Required - The method to call, which is 'tools/list'. - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/list", "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON RPC version. - **result** (object) - The result of the RPC call. - **tools** (array) - A list of available tools. - **name** (string) - The name of the tool. - **description** (string) - A description of what the tool does. - **inputSchema** (object) - The schema for the tool's input arguments. - **id** (integer) - The request ID. #### Response Example ```json { "jsonrpc": "2.0", "result": { "tools": [ { "name": "send_message", "description": "Kirim pesan WhatsApp ke session chat/percakapan tertentu.", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "ID dari chat session/percakapan." }, "text": { "type": "string", "description": "Isi pesan teks yang ingin dikirim." } }, "required": ["session_id", "text"] } }, { "name": "list_conversations", "description": "Dapatkan daftar percakapan (chat sessions) aktif dalam proyek.", "inputSchema": { "type": "object", "properties": { "status": { "type": "string", "description": "Saring berdasarkan status percakapan (open, pending, resolved, on_hold). Opsional." } } } }, { "name": "get_conversation", "description": "Dapatkan detail percakapan (chat session) beserta riwayat timeline pesannya.", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "ID dari chat session/percakapan." } }, "required": ["session_id"] } } ] }, "id": 1 } ``` ``` -------------------------------- ### Mengirim Tombol Cepat (Quick Reply Buttons) Source: https://kirem.co/docs/send-interactive Menampilkan hingga 3 tombol klik cepat di bawah balon pesan obrolan. Gunakan ini untuk interaksi sederhana yang memerlukan respons cepat dari pelanggan. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "interactive", "interactive": { "type": "button", "header": { "type": "text", "text": "Konfirmasi Pendaftaran" }, "body": { "text": "Apakah Anda bersedia melanjutkan pendaftaran?" }, "footer": { "text": "Layanan Pendaftaran Otomatis" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "btn_yes", "title": "Ya, bersedia" } }, { "type": "reply", "reply": { "id": "btn_no", "title": "Tidak, batalkan" } } ] } } } ``` -------------------------------- ### Respons Pertama Sukses (201 Created) Source: https://kirem.co/docs/idempotency Ini adalah respons yang diterima ketika permintaan pertama berhasil diproses dan dikirim ke Meta API. ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU..."}] } } ``` -------------------------------- ### Respons Sukses Pengambilan Profil Source: https://kirem.co/docs/manage-profile Contoh respons JSON yang menunjukkan detail profil bisnis yang berhasil diambil. Ini mencakup informasi seperti 'about', 'address', 'description', 'email', 'vertical', 'websites', dan 'profile_picture_url'. ```json { "status": 200, "message": "Business profile retrieved successfully", "data": { "about": "Solusi Komunikasi Bisnis Terbaik", "address": "Gedung Cyber 2, Lt. 15, Jakarta Selatan", "description": "Kirem adalah platform WhatsApp Business API Developer Terpercaya.", "email": "support@kirem.id", "vertical": "RETAIL", "websites": [ "https://kirem.id", "https://docs.kirem.id" ], "profile_picture_url": "https://pps.whatsapp.net/v/t61.24694-24/..." } } ``` -------------------------------- ### Download Media Source: https://kirem.co/docs/download-media This endpoint returns the raw binary content of a media file stored on the Meta server. Use this endpoint to save customer-sent media to your local storage directly as a file. The response is a binary stream, not JSON. ```APIDOC ## GET /v1/media/:media_id/download ### Description Retrieves the raw binary content of a media file from the Meta server. This is useful for saving media files directly to your local storage. ### Method GET ### Endpoint `/v1/media/:media_id/download` ### Parameters This endpoint does not require additional query parameters. Include the `media_id` in the URL path and the `Authorization` header. #### Path Parameters - **media_id** (string) - Required - The unique identifier for the media file. #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer kirem_live_xxx`). ### Response #### Success Response (200 OK) Returns the raw binary data of the file with a `Content-Type` header corresponding to the original file type (e.g., `image/png`, `video/mp4`, `application/pdf`). The response body is a binary stream, not JSON. **Content-Type Header Examples:** - Image PNG: `image/png` - Image JPEG: `image/jpeg` - Video MP4: `video/mp4` - Document PDF: `application/pdf` - Audio OGG: `audio/ogg` ### Error Handling - **404 Not Found**: If the `media_id` is not found or has been deleted. ### Request Example (cURL) ```bash curl -X GET "https://api.kirem.co/v1/media/18471948194819/download" \ -H "Authorization: Bearer kirem_live_xxx" \ --output downloaded_image.png ``` ### Code Examples #### Node.js (stream to file) ```javascript const axios = require('axios'); const fs = require('fs'); axios.get('https://api.kirem.co/v1/media/18471948194819/download', { headers: { 'Authorization': 'Bearer kirem_live_xxx' }, responseType: 'stream' }).then(res => { res.data.pipe(fs.createWriteStream('downloaded_image.png')); console.log('File berhasil disimpan!'); }); ``` #### Go (io.Copy to file) ```go package main import ( "fmt" "io" "net/http" "os" ) func main() { url := "https://api.kirem.co/v1/media/18471948194819/download" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer kirem_live_xxx") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() file, _ := os.Create("downloaded_image.png") defer file.Close() io.Copy(file, resp.Body) fmt.Println("File berhasil disimpan!") } ``` #### PHP (file_put_contents) ```php ``` ``` -------------------------------- ### Request Body untuk Membuat Templat Pesan Baru Source: https://kirem.co/docs/create-template Contoh JSON request body untuk membuat templat pesan WhatsApp baru. Ini mencakup nama, kategori, bahasa, dan berbagai komponen templat seperti header, body, footer, dan tombol. ```json { "name": "promo_diskon_baru", "category": "MARKETING", "language": "id", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Promo Spesial!" }, { "type": "BODY", "text": "Halo {{1}}, nikmati diskon khusus {{2}}% untuk semua produk. Gunakan kode: {{3}}." }, { "type": "FOOTER", "text": "Kirim STOP untuk berhenti berlangganan." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Tertarik!" }, { "type": "URL", "text": "Kunjungi Situs", "url": "https://kirem.co.id/promo" } ] } ] } ``` -------------------------------- ### Create Message Template Source: https://kirem.co/docs/broadcast-spreadsheet Use this endpoint to create a new message template for broadcasting. Ensure the template is approved before proceeding. ```APIDOC ## POST /v1/templates ### Description Creates a new message template for broadcasting purposes. ### Method POST ### Endpoint /v1/templates ### Request Body - **name** (string) - Required - The name of the template. - **category** (string) - Required - The category of the template (e.g., MARKETING). - **language** (string) - Required - The language of the template (e.g., id). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., HEADER, BODY, BUTTONS). - **format** (string) - Optional - The format of the header component (e.g., TEXT). - **text** (string) - Required - The text content of the component. Supports variables like {{1}}, {{2}}. - **buttons** (array) - Optional - An array of buttons for the template. - **type** (string) - Required - The type of button (e.g., URL). - **text** (string) - Required - The text displayed on the button. - **url** (string) - Required - The URL the button links to. ### Request Example ```json { "name": "broadcast_promo", "category": "MARKETING", "language": "id", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Promo Spesial!" }, { "type": "BODY", "text": "Halo {{1}},\n\nJangan lewatkan promo spesial kami! \ud83c\udf89\nGunakan kode *{{2}}* untuk mendapatkan diskon di seluruh produk.\n\nKlik di sini: https://kirem.co.id/promo" }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Lihat Promo", "url": "https://kirem.co.id/promo" } ] } ] } ``` ### Variables - `{{1}}` - Nama penerima (dari kolom B) - `{{2}}` - Kode promo (dari kolom C) **Note:** Wait until the template status becomes `APPROVED` before proceeding. ``` -------------------------------- ### Memperbarui Informasi Profil Bisnis Source: https://kirem.co/docs/manage-profile Kirim permintaan POST dengan body JSON yang berisi detail profil yang ingin Anda perbarui. Bidang yang tersedia bersifat opsional dan memiliki batasan karakter tertentu. ```json { "about": "Solusi Komunikasi Bisnis Terpadu", "address": "Gedung Cyber 2, Lt. 17, Jakarta Selatan", "description": "Kirem menyediakan API WhatsApp handal untuk integrasi enterprise.", "email": "help@kirem.id", "vertical": "RETAIL", "websites": [ "https://kirem.id", "https://kirem.id/blog" ] } ``` -------------------------------- ### Respons Sukses Mengambil Daftar Templat Pesan Source: https://kirem.co/docs/list-templates Contoh respons JSON yang berhasil diambil dari endpoint /v1/templates. Ini menunjukkan struktur data templat pesan, termasuk nama, status, kategori, bahasa, dan komponennya. ```json { "status": 200, "message": "Templates retrieved successfully", "data": [ { "name": "otp_verification", "status": "APPROVED", "category": "AUTHENTICATION", "language": "id", "components": [ { "type": "BODY", "text": "Kode keamanan OTP Kirem Anda adalah: {{1}}." } ], "id": "18491849184919" }, { "name": "promo_diskon_baru", "status": "PENDING", "category": "MARKETING", "language": "id", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Promo Spesial!" }, { "type": "BODY", "text": "Halo {{1}}, nikmati diskon {{2}}% untuk semua produk." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Ya, saya tertarik" } ] } ], "id": "194819481948194" } ] } ``` -------------------------------- ### Successful API Response (200 OK) Source: https://kirem.co/docs/pull-message-logs This is a sample JSON response indicating that message logs were retrieved successfully. It includes details about the total number of logs, limits, offsets, and the log entries themselves. ```json { "status": 200, "message": "Message logs retrieved successfully", "data": { "total": 1, "limit": 10, "offset": 0, "logs": [ { "id": "msg-12345", "message_id": "wamid.HBgLNjI4MTIzND...", "recipient": "62812345678", "direction": "outbound", "type": "template", "status": "failed", "error_message": "(#131026) Message Undeliverable", "created_at": "2026-06-26T00:20:00Z" } ] } } ``` -------------------------------- ### Menghapus Templat Pesan dengan PHP Source: https://kirem.co/docs/delete-template Contoh penghapusan templat pesan WhatsApp menggunakan PHP cURL. Nama templat di-URL encode menggunakan urlencode sebelum dikirimkan dalam permintaan DELETE. ```php ``` -------------------------------- ### Mengirim Video Menggunakan Tautan URL Langsung Source: https://kirem.co/docs/send-video Gunakan payload ini untuk mengirim video dari URL eksternal. Tautan harus langsung mengarah ke file video (misalnya, .mp4 atau .3gp) dan dapat diakses publik. Perhatikan batasan ukuran file 16 MB. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "video", "video": { "link": "https://kirem.id/assets/demo-video.mp4", "caption": "Video Tutorial Penggunaan Kirem API" } } ``` -------------------------------- ### POST /v1/templates Source: https://kirem.co/docs/create-template Endpoint to create and submit a new WhatsApp message template to Meta for review. After approval, the template can be used for sending messages to customers. ```APIDOC ## POST /v1/templates ### Description This endpoint is used to create and submit a new WhatsApp message template to Meta for review. Once the template is approved by Meta, you can use it to send messages to customers. ### Method POST ### Endpoint /v1/templates ### Request Body (JSON) ```json { "name": "promo_diskon_baru", "category": "MARKETING", "language": "id", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Promo Spesial!" }, { "type": "BODY", "text": "Halo {{1}}, nikmati diskon khusus {{2}}% untuk semua produk. Gunakan kode: {{3}}." }, { "type": "FOOTER", "text": "Kirim STOP untuk berhenti berlangganan." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Tertarik!" }, { "type": "URL", "text": "Kunjungi Situs", "url": "https://kirem.co.id/promo" } ] } ] } ``` ### Parameters #### Request Body Parameters - **name** (String) - Required - Unique name for the template (only lowercase letters, numbers, and underscores; e.g., `promo_diskon_baru`) - **category** (String) - Required - Template category (refer to the table below for options) - **language** (String) - Required - Template language code (e.g., `id` for Indonesian, `en` for English) - **components** (Array) - Required - List of components that make up the template ``` -------------------------------- ### Mengirim Daftar Menu Pilihan (List Messages) Source: https://kirem.co/docs/send-interactive Menampilkan tombol dropdown menu yang dapat memuat hingga 10 pilihan baris menu terorganisir. Cocok untuk navigasi menu yang lebih kompleks. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "interactive", "interactive": { "type": "list", "header": { "type": "text", "text": "Pusat Layanan Kirem" }, "body": { "text": "Silakan pilih menu bantuan di bawah ini untuk memulai interaksi." }, "footer": { "text": "Kirem Bot Service" }, "action": { "button": "Pilih Bantuan", "sections": [ { "title": "Layanan Umum", "rows": [ { "id": "menu_billing", "title": "Cek Tagihan", "description": "Melihat rincian tagihan bulanan Anda" }, { "id": "menu_support", "title": "Hubungi Support", "description": "Hubungkan dengan tim developer support" } ] }, { "title": "Layanan Teknis", "rows": [ { "id": "menu_webhook_test", "title": "Uji Webhook", "description": "Kirim payload testing ke server Anda" } ] } ] } } } ``` -------------------------------- ### Kirem Node - Send Pricing Information Source: https://kirem.co/docs/n8n-whatsapp-bot Configure the Kirem node to send product pricing details. Ensure the 'To' field is set to the sender's number and the 'Body' contains the pricing information and a link to the pricing page. ```text To : {{ $json.body.entry[0].changes[0].value.messages[0].from }} Message Type : Text Body :📋 Daftar Harga Produk Kami: - Paket Basic: Rp 99.000/bulan - Paket Pro: Rp 249.000/bulan - Paket Enterprise: Rp 499.000/bulan Kunjungi https://kirem.co.id/harga untuk detail lengkap! ``` -------------------------------- ### Payload Request JSON untuk Pesan Templat Source: https://kirem.co/docs/send-template Sertakan objek 'template' dengan memetakan nilai variabel dinamis pada array 'components'. Gunakan ini untuk mengirim pesan WhatsApp yang terstruktur dengan parameter yang dapat disesuaikan. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "template", "template": { "name": "promo_diskon_baru", "language": { "code": "id" }, "components": [ { "type": "header", "parameters": [ { "type": "text", "text": "Budi" } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "50" }, { "type": "text", "text": "HEMAT50" } ] } ] } } ``` -------------------------------- ### Contoh cURL Request dengan Idempotency Key Source: https://kirem.co/docs/idempotency Sertakan header 'Idempotency-Key' dengan nilai unik (disarankan UUID v4) saat mengirim pesan via endpoint POST /v1/messages untuk memastikan idempotensi. ```bash curl -X POST https://api.kirem.id/v1/messages \ -H "Authorization: Bearer kirem_live_xxx" \ -H "Idempotency-Key: e7b2a95c-9c2f-4b0d-9ea1-df3d686bc456" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "text", "text": { "body": "Halo Budi, tagihan Anda sebesar Rp 150.000 telah terbit." } }' ``` -------------------------------- ### send_message (via tools/call) Source: https://kirem.co/docs/mcp Enables AI Agents to directly reply to customer WhatsApp messages. Requires a valid UUID for the session ID. ```APIDOC ## send_message (via tools/call) ### Description Used by AI Agents to reply directly to customer WhatsApp messages. Requires a valid UUID for the session ID. ### Method POST ### Endpoint /tools/call ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON RPC version. - **method** (string) - Required - The method to call, which is 'tools/call'. - **params** (object) - Required - Parameters for the tool call. - **name** (string) - Required - The name of the tool to call, which is 'send_message'. - **arguments** (object) - Required - Arguments for the 'send_message' tool. - **session_id** (string) - Required - The ID of the chat session/conversation. Must be a valid UUID. - **text** (string) - Required - The text content of the message to send. - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "send_message", "arguments": { "session_id": "8a3d12d4-1a9b-4bfa-a7b3-c123456789ab", "text": "Halo! Produk X saat ini ready stock. Ingin langsung kami buatkan pesanannya?" } }, "id": 4 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON RPC version. - **result** (object) - The result of the RPC call. - **content** (array) - Contains the result of the message sending operation. - **type** (string) - The type of content, usually 'text'. - **text** (string) - A confirmation message, typically including the message ID. - **id** (integer) - The request ID. #### Response Example ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "Pesan berhasil dikirim. Message ID: msg_abc123" } ] }, "id": 4 } ``` ``` -------------------------------- ### Respons Sukses Pembaruan Profil Source: https://kirem.co/docs/manage-profile Contoh respons JSON yang menunjukkan bahwa pembaruan profil bisnis berhasil diproses. Respons ini mengonfirmasi status keberhasilan operasi. ```json { "status": 200, "message": "Business profile updated successfully", "data": { "success": true } } ``` -------------------------------- ### Add Product List to Notification Template Source: https://kirem.co/docs/woocommerce-order-notif Update the template to include a variable for the product list. This requires adding `{{5}}` to the template's text. ```json { "type": "BODY", "text": "Halo {{1}}, terima kasih telah berbelanja di {{2}}!\n\nPesanan #{{3}}\nTotal: Rp {{4}}\n\nProduk:\n{{5}}" } ``` -------------------------------- ### Respons Sukses Penghapusan Templat Source: https://kirem.co/docs/delete-template Contoh respons JSON yang menunjukkan keberhasilan penghapusan templat pesan WhatsApp. Status 200 OK mengindikasikan operasi berhasil. ```json { "status": 200, "message": "Template deleted successfully", "data": { "success": true } } ``` -------------------------------- ### Contoh Body Template dengan Variabel Source: https://kirem.co/docs/create-template Menentukan isi utama pesan yang mendukung parameter variabel seperti {{1}} dan {{2}}. ```json { "type": "BODY", "text": "Halo {{1}}, pesanan Anda #{{2}} sedang diproses." } ``` -------------------------------- ### Contoh Kode (PHP — file_put_contents) Source: https://kirem.co/docs/download-media Mengunduh file media di PHP menggunakan cURL dan menyimpannya ke file lokal menggunakan file_put_contents. Pastikan untuk menangani error cURL. ```php ``` -------------------------------- ### Customer Support AI Agent Interaction Flow with Kirem MCP API Source: https://kirem.co/docs/mcp This sequence diagram illustrates the step-by-step communication between an AI Agent and the Kirem MCP API for handling customer support inquiries. It covers checking for new messages, retrieving conversation history, and sending replies. ```sequenceDiagram sequenceDiagram participant Agent as AI Agent (Claude/Custom) participant Kirem as Kirem MCP API participant DB as Kirem Database Note over Agent, Kirem: Tahap 1: Cek Pesan Masuk Agent->>Kirem: POST /v1/mcp (Method: tools/call, Tool: list_conversations, status: open) Kirem->>Agent: Kembalikan daftar session aktif dengan UUID-nya Note over Agent, Kirem: Tahap 2: Tarik Konteks Obrolan Agent->>Kirem: POST /v1/mcp (Method: tools/call, Tool: get_conversation, session_id: ) Kirem->>Agent: Kembalikan riwayat pesan chat dari pelanggan tersebut Note over Agent: Berpikir & Memformulasikan Balasan Note over Agent, Kirem: Tahap 3: Kirim Balasan ke WhatsApp Agent->>Kirem: POST /v1/mcp (Method: tools/call, Tool: send_message, session_id: , text: "...") Kirem->>DB: Validasi & Simpan Pesan (UUID check) DB-->>Kirem: Berhasil Kirem->>Agent: Kembalikan status sukses (Pesan berhasil dikirim) ``` -------------------------------- ### Contoh Tombol Template Source: https://kirem.co/docs/create-template Menentukan tombol aksi interaktif, mendukung tipe QUICK_REPLY dan URL. Maksimal 2 tombol per template. ```json { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Ya, lanjutkan" }, { "type": "URL", "text": "Lihat Detail", "url": "https://kirem.co.id/pesanan/123" } ] } ``` -------------------------------- ### Successful Template Creation Response Source: https://kirem.co/docs/create-template This is the expected JSON response upon successful creation of a message template. It includes the status code, a success message, and data about the newly created template. ```json { "status": 200, "message": "Template created successfully", "data": { "id": "194819481948194", "status": "PENDING", "category": "UTILITY" } } ``` -------------------------------- ### MCP JSON-RPC 2.0 Endpoint Source: https://kirem.co/docs/mcp This endpoint allows AI agents to securely use tools provided by the Kirem platform, enabling them to read WhatsApp conversation history, view active conversations, and send reply messages. ```APIDOC ## POST /v1/mcp ### Description This endpoint facilitates interaction with AI agents via a JSON-RPC 2.0 protocol compatible with the Model Context Protocol (MCP). It enables agents to access WhatsApp conversation data and send messages. ### Method POST ### Endpoint https://api.kirem.co/v1/mcp ### Headers - **Content-Type**: application/json - **Authorization**: Bearer (Use the API Key generated from the Kirem dashboard https://kirem.co/dashboard/keys) ### Request Body Requests must follow the JSON-RPC 2.0 specification. The specific method and parameters will depend on the desired action (e.g., reading history, sending messages). ### Response Responses will follow the JSON-RPC 2.0 specification, indicating success or failure of the requested method. #### Success Response (200) - **result** (any) - The result of the JSON-RPC method call. - **id** (string or number) - The identifier for the request. #### Error Response - **error** (object) - An object containing error details. - **code** (number) - The error code. - **message** (string) - A description of the error. - **data** (any) - Optional additional data about the error. - **id** (string or number) - The identifier for the request. ``` -------------------------------- ### Payload JSON Mengirim Gambar via Media ID Source: https://kirem.co/docs/send-image Gunakan metode ini untuk mengirim gambar yang telah diunggah ke server Meta. Pastikan Anda memiliki Media ID yang valid. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "image", "image": { "id": "18471948194819", "caption": "Silakan lihat gambar brosur promo kami" } } ``` -------------------------------- ### Fallback Message Configuration Source: https://kirem.co/docs/n8n-whatsapp-bot Configure a Kirem node to send a fallback message when no keywords are matched. This is used for unknown user inputs. ```json { "body": "Maaf, saya belum mengerti pesan Anda. Ketik *Bantuan* untuk melihat menu yang tersedia." } ``` -------------------------------- ### Payload JSON Mengirim Gambar via Tautan URL Langsung Source: https://kirem.co/docs/send-image Kirim gambar menggunakan tautan URL eksternal yang dapat diakses publik. Pastikan URL mengarah langsung ke file gambar (misal: .jpg/.png). ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "image", "image": { "link": "https://kirem.id/assets/promo-poster.png", "caption": "Brosur Promo Akhir Tahun Kirem" } } ``` -------------------------------- ### Payload JSON untuk Mengirim Pesan Lokasi Source: https://kirem.co/docs/send-location Gunakan payload ini untuk mengirim koordinat lokasi geografis. Sertakan longitude, latitude, dan opsional nama serta alamat tempat. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "location", "location": { "longitude": 106.827153, "latitude": -6.175392, "name": "Monumen Nasional", "address": "Gambir, Kota Jakarta Pusat, DKI Jakarta" } } ``` -------------------------------- ### Contoh Footer Template Source: https://kirem.co/docs/create-template Menentukan catatan kaki untuk pesan dengan batasan maksimal 60 karakter. ```json { "type": "FOOTER", "text": "Balas STOP untuk berhenti." } ``` -------------------------------- ### WhatsApp Template Structure Source: https://kirem.co/docs/manage-templates Visual representation of the main sections within a WhatsApp message template. ```text +-------------------------------------------------------+ | HEADER (Opsional: Teks, Gambar, Video, Dokumen) | +-------------------------------------------------------+ | BODY (Wajib: Teks utama + Variabel {{1}}, {{2}}) | +-------------------------------------------------------+ | FOOTER (Opsional: Teks disclaimer / Tombol Berhenti) | +-------------------------------------------------------+ | BUTTONS (Opsional: Quick Reply atau Call to Action) | +-------------------------------------------------------+ ``` -------------------------------- ### Webhook Event for Customer Click Source: https://kirem.co/docs/send-interactive This section describes the webhook callback received when a customer clicks a Quick Reply button or selects a List Message option. The event type is `messages.received`. ```APIDOC ## Webhook Event: messages.received (Interactive Reply) ### Description This event is triggered when a customer interacts with an interactive message (Quick Reply or List Message) by clicking a button or selecting an option. ### Event Type `messages.received` ### Callback Payload Example (Quick Reply Button Click): ```json { "event": "messages.received", "data": { "from": "62812345678", "message_id": "wamid.HBgLN...", "type": "interactive", "interactive": { "type": "button_reply", "button_reply": { "id": "btn_yes", "title": "Ya, bersedia" } } } } ``` ### Key Fields: - `data.interactive.button_reply.id`: The unique identifier of the button clicked (e.g., `btn_yes`). This can be used server-side to trigger subsequent bot logic. ``` -------------------------------- ### Fetch Failed Webhook Logs (PHP) Source: https://kirem.co/docs/pull-webhook-logs Fetch failed webhook logs in PHP using cURL. This snippet shows how to set the Authorization header and query parameters, execute the request, and parse the JSON response to display total failures and log details. ```php get_billing_phone(); $customer_name = $order->get_billing_first_name(); $order_total = number_format($order->get_total(), 0, ',', '.'); // Bersihkan nomor telepon — hapus awalan 0 atau +62 $customer_phone = preg_replace('/[^0-9]/', '', $customer_phone); if (strpos($customer_phone, '0') === 0) { $customer_phone = '62' . substr($customer_phone, 1); } // Siapkan payload sesuai format Kirem $payload = [ 'messaging_product' => 'whatsapp', 'recipient_type' => 'individual', 'to' => $customer_phone, 'type' => 'template', 'template' => [ 'name' => KIREM_TEMPLATE_NAME, 'language' => [ 'code' => 'id' ], 'components' => [ [ 'type' => 'body', 'parameters' => [ ['type' => 'text', 'text' => $customer_name], ['type' => 'text', 'text' => STORE_NAME], ['type' => 'text', 'text' => (string) $order_id], ['type' => 'text', 'text' => 'Rp ' . $order_total], ] ] ] ] ]; // Kirim ke Kirem API $response = wp_remote_post(KIREM_API_URL, [ 'headers' => [ 'Authorization' => 'Bearer ' . KIREM_API_KEY, 'Content-Type' => 'application/json', ], 'body' => json_encode($payload), 'timeout' => 30, ]); // Log hasil (opsional) if (is_wp_error($response)) { error_log('Kirem Notification Error: ' . $response->get_error_message()); } else { $body = json_decode(wp_remote_retrieve_body($response), true); $message_id = $body['data']['messages'][0]['id'] ?? 'unknown'; error_log("Kirem Notification Sent. Order #{$order_id}, WAID: {$message_id}"); } } ``` -------------------------------- ### Create Broadcast Message Template Source: https://kirem.co/docs/broadcast-spreadsheet Use this JSON payload to create a new message template for broadcasts. The template includes header, body, and button components with placeholders for dynamic content. ```json { "name": "broadcast_promo", "category": "MARKETING", "language": "id", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Promo Spesial!" }, { "type": "BODY", "text": "Halo {{1}}, Jangan lewatkan promo spesial kami! 🎉 Gunakan kode *{{2}}* untuk mendapatkan diskon di seluruh produk. Klik di sini: https://kirem.co.id/promo" }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Lihat Promo", "url": "https://kirem.co.id/promo" } ] } ] } ``` -------------------------------- ### Mengirim Video Menggunakan Media ID Source: https://kirem.co/docs/send-video Gunakan payload ini untuk mengirim video yang sudah diunggah ke Meta menggunakan Media ID. Pastikan ID media valid dan video memenuhi persyaratan format dan ukuran. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "video", "video": { "id": "18471948194820", "caption": "Silakan tonton video demo produk kami" } } ``` -------------------------------- ### Contoh Header Gambar Template Source: https://kirem.co/docs/create-template Menentukan header template berupa gambar dengan menyertakan URL gambar. ```json { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": ["https://contoh.com/banner.jpg"] } } ``` -------------------------------- ### List Open Conversations Source: https://kirem.co/docs/mcp Retrieves a list of active conversations with an 'open' status. This is typically the first step for an AI agent to check for new or pending customer messages. ```APIDOC ## POST /v1/mcp ### Description Retrieves a list of active conversations with an 'open' status. ### Method POST ### Endpoint /v1/mcp ### Parameters #### Request Body - **method** (string) - Required - The tool to call, should be 'tools/call'. - **tool** (string) - Required - The specific tool to use, should be 'list_conversations'. - **status** (string) - Required - Filters conversations by status, should be 'open'. ``` -------------------------------- ### list_conversations (via tools/call) Source: https://kirem.co/docs/mcp Used by AI Agents to retrieve a list of all active WhatsApp chat sessions within your project. Supports filtering by status. ```APIDOC ## list_conversations (via tools/call) ### Description Used by AI Agents to pull a list of all active WhatsApp chat sessions (conversations) in your project. ### Method POST ### Endpoint /tools/call ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON RPC version. - **method** (string) - Required - The method to call, which is 'tools/call'. - **params** (object) - Required - Parameters for the tool call. - **name** (string) - Required - The name of the tool to call, which is 'list_conversations'. - **arguments** (object) - Optional - Arguments for the 'list_conversations' tool. - **status** (string) - Optional - Filter conversations by status (e.g., "open", "pending", "resolved", "on_hold"). - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "list_conversations", "arguments": { "status": "open" } }, "id": 2 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON RPC version. - **result** (object) - The result of the RPC call. - **content** (array) - A list of conversation objects. - **type** (string) - The type of content, usually 'text'. - **text** (string) - A JSON string representing the list of conversations. Each conversation object contains 'id', 'status', 'customer_phone', and 'updated_at'. - **id** (integer) - The request ID. #### Response Example ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "[{{\"id\":\"8a3d12d4-1a9b-4bfa-a7b3-c123456789ab\",\"status\":\"open\",\"customer_phone\":\"62812345678\",\"updated_at\":\"2026-06-28T16:00:00Z\"}}]" } ] }, "id": 2 } ``` ``` -------------------------------- ### Send First Message with Kirem API Source: https://kirem.co/docs/quickstart Use this cURL command to send a test text message via the Kirem API. Ensure you replace 'kd_live_your_actual_key' with your actual API key and '62812345678' with the recipient's phone number. ```bash curl -X POST https://api.kirem.id/v1/messages \ -H "Authorization: Bearer kd_live_your_actual_key" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "text", "text": { "body": "Halo! Ini adalah pesan uji coba pertama saya menggunakan Kirem API." } }' ``` -------------------------------- ### get_conversation (via tools/call) Source: https://kirem.co/docs/mcp Allows AI Agents to fetch the complete message history of a specific conversation to provide context before responding. ```APIDOC ## get_conversation (via tools/call) ### Description Used by AI Agents to get the complete message history of a conversation (chat session) so the agent has chat context before responding. ### Method POST ### Endpoint /tools/call ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON RPC version. - **method** (string) - Required - The method to call, which is 'tools/call'. - **params** (object) - Required - Parameters for the tool call. - **name** (string) - Required - The name of the tool to call, which is 'get_conversation'. - **arguments** (object) - Required - Arguments for the 'get_conversation' tool. - **session_id** (string) - Required - The ID of the chat session/conversation. Must be a valid UUID. - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_conversation", "arguments": { "session_id": "8a3d12d4-1a9b-4bfa-a7b3-c123456789ab" } }, "id": 3 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON RPC version. - **result** (object) - The result of the RPC call. - **content** (array) - Contains the conversation details and messages. - **type** (string) - The type of content, usually 'text'. - **text** (string) - A JSON string containing the session details and a list of messages, including sender and text. - **id** (integer) - The request ID. #### Response Example ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "{\"session\":{\"id\":\"8a3d12d4-1a9b-4bfa-a7b3-c123456789ab\",\"status\":\"open\"},\"messages\":[{\"id\":\"msg_1\",\"sender\":\"customer\",\"text\":\"Halo, apakah produk X ready?\",\"created_at\":\"...\"}]}" } ] }, "id": 3 } ``` ``` -------------------------------- ### Handle Opt-Out in Broadcast Source: https://kirem.co/docs/broadcast-spreadsheet This snippet demonstrates how to check for an 'STOP' keyword in a designated column before sending a broadcast message. If 'STOP' is found, the row is marked as skipped and the loop continues to the next recipient. ```javascript // Tambahkan kolom "Opt-Out" (G) // Sebelum mengirim, cek: if (row[6] === 'STOP') { sheet.getRange(i + 1, 4).setValue('DILEWATI (Opt-Out)'); continue; // Lewati nomor ini } ``` -------------------------------- ### Send Contacts (vCard) Source: https://kirem.co/docs/send-contacts This endpoint is used to share contact information (vCard) with your customers in a structured format. Customers can directly save the phone number, email, address, or company name sent to their mobile phone's contact list with a single tap. ```APIDOC ## POST /v1/messages ### Description This endpoint allows you to send contact information (vCard) to your customers. The customer can directly save the contact details to their phone. ### Method POST ### Endpoint `/v1/messages` or `/v1/:phone_number_id/messages` ### Headers - `Authorization: Bearer ` - `Content-Type: application/json` ### Request Body ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "contacts", "contacts": [ { "addresses": [ { "street": "Gedung Cyber 2, Lt. 15", "city": "Jakarta Selatan", "state": "DKI Jakarta", "zip": "12950", "country": "Indonesia", "type": "WORK" } ], "emails": [ { "email": "support@kirem.id", "type": "WORK" } ], "name": { "formatted_name": "Kirem Support", "first_name": "Kirem", "last_name": "Support" }, "org": { "company": "Kirem Indonesia", "department": "Developer Support" }, "phones": [ { "phone": "+62812345678", "type": "WORK", "wa_id": "62812345678" } ], "urls": [ { "url": "https://kirem.id", "type": "WORK" } ] } ] } ``` #### Parameters - `type` (String - Required): Set value to `"contacts"`. - `contacts` (Array - Required): List of contact objects to send (can send multiple contacts at once): - `name` (Object - Required): Contact name. Consists of `formatted_name` (display full name), `first_name` (first name), and `last_name` (last name). - `phones` (Array - Optional): List of phone numbers. The `phone` parameter must be in full international format and `wa_id` should be filled with the corresponding WhatsApp ID (number without the `+` sign). `type` specifies the phone label (e.g., `"WORK"`, `"HOME"`, `"CELL"`). - `emails` (Array - Optional): List of contact emails along with their type labels. - `addresses` (Array - Optional): Complete contact address details. - `org` (Object - Optional): Contact organization/company information. Consists of `company` (company name) and `department` (division). - `urls` (Array - Optional): List of related website links. ### Response #### Success Response (201 Created) ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` - `messages[0].id`: Message ID for monitoring delivery status via webhook. WhatsApp will automatically display an "Add Contact" or "Message" button directly on the customer's phone screen when receiving this vCard message. ``` -------------------------------- ### Contoh Respons Sukses API Source: https://kirem.co/docs/send-image Respons ini menunjukkan bahwa pesan gambar telah berhasil dikirim. Periksa `messages[0].id` untuk memantau status pengiriman. ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` -------------------------------- ### List Active Conversations Source: https://kirem.co/docs/mcp Retrieve a list of active chat sessions within your project. An optional status filter can be applied to narrow down the results. ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "list_conversations", "arguments": { "status": "open" // Opsional: "open", "pending", "resolved", "on_hold" } }, "id": 2 } ``` ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "[{"id":"8a3d12d4-1a9b-4bfa-a7b3-c123456789ab","status":"open","customer_phone":"62812345678","updated_at":"2026-06-28T16:00:00Z"}]" } ] }, "id": 2 } ``` -------------------------------- ### Google Apps Script for Kirem Broadcast Source: https://kirem.co/docs/broadcast-spreadsheet This script enables sending WhatsApp broadcasts via the Kirem API from a Google Sheet. It includes functions to set up custom menus, send messages, clean phone numbers, and reset delivery status. Ensure you configure KIREM_API_KEY, KIREM_API_URL, and TEMPLATE_NAME. ```javascript // ============================================ // KONFIGURASI — Ubah sesuai pengaturan Anda // ============================================ const KIREM_API_KEY = 'kirem_live_xxxxxxxxxxxxxxxx'; const KIREM_API_URL = 'https://api.kirem.co/v1/messages'; const TEMPLATE_NAME = 'broadcast_promo'; const DELAY_MS = 2000; // Jeda 2 detik antar pengiriman /** * Menu kustom di Google Sheets */ function onOpen() { const ui = SpreadsheetApp.getUi(); ui.createMenu('📱 Kirem Broadcast') .addItem('Kirim Broadcast', 'sendBroadcast') .addItem('Reset Status', 'resetStatus') .addToUi(); } /** * Fungsi utama: Membaca spreadsheet dan mengirim broadcast */ function sendBroadcast() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const data = sheet.getDataRange().getValues(); const total = data.length - 1; // Kurangi header const ui = SpreadsheetApp.getUi(); const response = ui.alert( 'Konfirmasi Broadcast', `Anda akan mengirim broadcast ke ${total} nomor. Lanjutkan?`, ui.ButtonSet.YES_NO ); if (response !== ui.Button.YES) { return; } let successCount = 0; let failCount = 0; // Mulai dari baris 2 (baris 1 adalah header) for (let i = 1; i < data.length; i++) { const row = data[i]; const phone = String(row[0]).trim(); const name = row[1] || 'Pelanggan'; const promoCode = row[2] || ''; // Lewati baris kosong if (!phone) { continue; } // Bersihkan nomor telepon const cleanPhone = cleanPhoneNumber(phone); try { const result = sendWhatsAppMessage(cleanPhone, name, promoCode); const messageId = result.data.messages[0].id; // Update status di spreadsheet sheet.getRange(i + 1, 4).setValue('SUKSES'); sheet.getRange(i + 1, 5).setValue(messageId); sheet.getRange(i + 1, 6).setValue(new Date().toISOString()); successCount++; console.log(`✅ ${cleanPhone} — ${messageId}`); } catch (error) { // Update status error di spreadsheet sheet.getRange(i + 1, 4).setValue('GAGAL: ' + error.message); sheet.getRange(i + 1, 6).setValue(new Date().toISOString()); failCount++; console.log(`❌ ${cleanPhone} — ${error.message}`); } // Jeda antar pengiriman (rate limiting) Utilities.sleep(DELAY_MS); } // Tampilkan ringkasan ui.alert( 'Broadcast Selesai', `Total: ${total}\nSukses: ${successCount}\nGagal: ${failCount}`, ui.ButtonSet.OK ); } /** * Membersihkan format nomor telepon ke format internasional */ function cleanPhoneNumber(phone) { // Hapus semua karakter non-digit let cleaned = phone.replace(/[^0-9]/g, ''); // Konversi 08xx → 628xx if (cleaned.startsWith('0')) { cleaned = '62' + cleaned.substring(1); } // Konversi 8xx → 628xx (jika pendek) if (cleaned.startsWith('8') && cleaned.length < 12) { cleaned = '62' + cleaned; } return cleaned; } /** * Mengirim pesan WhatsApp via Kirem API */ function sendWhatsAppMessage(to, name, promoCode) { const payload = { messaging_product: 'whatsapp', recipient_type: 'individual', to: to, type: 'template', template: { name: TEMPLATE_NAME, language: { code: 'id' }, components: [ { type: 'body', parameters: [ { type: 'text', text: name }, { type: 'text', text: promoCode } ] } ] } }; const options = { method: 'post', contentType: 'application/json', headers: { 'Authorization': 'Bearer ' + KIREM_API_KEY }, payload: JSON.stringify(payload), muteHttpExceptions: true }; const response = UrlFetchApp.fetch(KIREM_API_URL, options); const responseCode = response.getResponseCode(); const responseBody = JSON.parse(response.getContentText()); if (responseCode !== 200 && responseCode !== 201) { throw new Error( responseBody.message || `HTTP ${responseCode}` ); } return responseBody; } /** * Reset kolom status, WA ID, dan waktu */ function resetStatus() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const data = sheet.getDataRange().getValues(); const ui = SpreadsheetApp.getUi(); const response = ui.alert( 'Reset Status', 'Ini akan menghapus semua status, WA ID, dan waktu kirim. Lanjutkan?', ui.ButtonSet.YES_NO ); if (response !== ui.Button.YES) { return; } for (let i = 1; i < data.length; i++) { sheet.getRange(i + 1, 4).setValue(''); sheet.getRange(i + 1, 5).setValue(''); sheet.getRange(i + 1, 6).setValue(''); } ui.alert('Status berhasil direset!', ui.ButtonSet.OK); } ``` -------------------------------- ### Send WhatsApp Message Source: https://kirem.co/docs/mcp Send a direct WhatsApp message to a customer within a specific chat session. Ensure the `session_id` is a valid UUID string to avoid database errors. ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "send_message", "arguments": { "session_id": "8a3d12d4-1a9b-4bfa-a7b3-c123456789ab", // Wajib UUID valid "text": "Halo! Produk X saat ini ready stock. Ingin langsung kami buatkan pesanannya?" } }, "id": 4 } ``` ```json { "jsonrpc": "2.0", "result": { "content": [ { "type": "text", "text": "Pesan berhasil dikirim. Message ID: msg_abc123" } ] }, "id": 4 } ``` -------------------------------- ### Add Custom Admin Notification Settings Tab in WooCommerce Source: https://kirem.co/docs/woocommerce-order-notif This PHP code adds a new settings tab named 'Kirem WhatsApp' under WooCommerce > Settings > Advanced. It uses WordPress filters to modify WooCommerce's settings sections. ```php // Tambahkan tab pengaturan add_filter('woocommerce_get_sections_advanced', function($sections) { $sections['kirem_notif'] = 'Kirem WhatsApp'; return $sections; }); ``` -------------------------------- ### cURL Request: All Failed Messages Source: https://kirem.co/docs/pull-message-logs Use this cURL command to retrieve a list of all failed message logs. It filters messages by 'failed' status and limits the results to 10. ```bash curl -X GET "https://api.kirem.co/v1/analytics/messages?status=failed&limit=10" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Retrieve Failed Messages Source: https://kirem.co/docs/pull-message-logs Fetches a list of messages with a 'failed' status. You can specify the limit for the number of results. ```APIDOC ## GET /v1/analytics/messages?status=failed ### Description Retrieves message logs filtered by a 'failed' status. ### Method GET ### Endpoint /v1/analytics/messages ### Query Parameters - **status** (string) - Required - Filters messages by status. Use 'failed' to get failed messages. - **limit** (integer) - Optional - The maximum number of messages to return. ``` -------------------------------- ### Send Message Source: https://kirem.co/docs/mcp Sends a reply message to a customer within a specific conversation. The AI agent uses this after formulating a response based on the conversation history. ```APIDOC ## POST /v1/mcp ### Description Sends a reply message to a customer within a specific conversation. ### Method POST ### Endpoint /v1/mcp ### Parameters #### Request Body - **method** (string) - Required - The tool to call, should be 'tools/call'. - **tool** (string) - Required - The specific tool to use, should be 'send_message'. - **session_id** (string) - Required - The unique identifier (UUID) of the conversation session to which the message will be sent. - **text** (string) - Required - The content of the message to be sent. ``` -------------------------------- ### Retrieve Inbound Messages Source: https://kirem.co/docs/pull-message-logs Fetches inbound messages received by your system. You can specify the limit and offset for pagination. ```APIDOC ## GET /v1/analytics/messages?direction=inbound&limit={limit}&offset={offset} ### Description Retrieves inbound message logs received by your system. ### Method GET ### Endpoint /v1/analytics/messages ### Query Parameters - **direction** (string) - Required - Filters messages by direction. Use 'inbound' for messages received by your system. - **limit** (integer) - Optional - The maximum number of messages to return. - **offset** (integer) - Optional - The number of messages to skip before starting to collect the result set. ``` -------------------------------- ### POST /v1/messages Source: https://kirem.co/docs/send-location Sends a location message to a recipient. This endpoint uses automatic routing through the first active channel. It requires an Authorization header with your API key and a JSON content type. ```APIDOC ## POST /v1/messages ### Description Sends a location message to a recipient using the default routing through the first active channel. ### Method POST ### Endpoint /v1/messages ### Headers - **Authorization** (string) - Required - Bearer - **Content-Type** (string) - Required - application/json ### Request Body - **messaging_product** (string) - Required - Set to "whatsapp". - **recipient_type** (string) - Required - Set to "individual". - **to** (string) - Required - The recipient's phone number. - **type** (string) - Required - Set to "location". - **location** (object) - Required - Contains location details. - **longitude** (float) - Required - The longitude coordinate of the location. - **latitude** (float) - Required - The latitude coordinate of the location. - **name** (string) - Optional - The name of the place or building. - **address** (string) - Optional - The full address of the location. ### Request Example ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "location", "location": { "longitude": 106.827153, "latitude": -6.175392, "name": "Monumen Nasional", "address": "Gambir, Kota Jakarta Pusat, DKI Jakarta" } } ``` ### Response #### Success Response (201 Created) - **status** (integer) - The HTTP status code. - **message** (string) - A confirmation message. - **data** (object) - Contains details about the sent message. - **messaging_product** (string) - The messaging product used. - **contacts** (array) - Information about the recipient. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the recipient. - **messages** (array) - Information about the sent messages. - **id** (string) - The unique ID of the message. #### Response Example ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` ``` -------------------------------- ### Standard Success Response Format Source: https://kirem.co/docs/response-wrapper This JSON structure is returned for all successful API requests, typically with a 2xx HTTP status code. It includes a status code, a success message, and the main data payload. ```json { "status": 200, "message": "Pesan deskripsi keberhasilan operasi", "data": { "key_1": "value_1", "key_2": "value_2" } } ``` -------------------------------- ### Interactive Button Message Source: https://kirem.co/docs/n8n-whatsapp-bot Send an interactive message with buttons instead of plain text. This allows users to select predefined options easily. ```json { "type": "interactive", "interactive": { "type": "button", "body": { "text": "Halo! Apa yang bisa saya bantu?" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "harga", "title": "💰 Harga" } }, { "type": "reply", "reply": { "id": "bantuan", "title": "🆘 Bantuan" } } ] } } } ``` -------------------------------- ### Define Admin Phone Number Setting Field in WooCommerce Source: https://kirem.co/docs/woocommerce-order-notif This PHP code defines the input field for the admin's WhatsApp number within the 'Kirem WhatsApp' settings tab. It creates a text input field with the ID `kirem_admin_phone`. ```php // Field pengaturan add_filter('woocommerce_get_settings_advanced', function($settings, $current_section) { if ($current_section === 'kirem_notif') { return [ [ 'title' => 'Pengaturan Notifikasi WhatsApp', 'type' => 'title', 'id' => 'kirem_notif_options' ], [ 'title' => 'Nomor Admin', 'desc' => 'Nomor WhatsApp yang akan menerima notifikasi setiap pesanan baru', 'id' => 'kirem_admin_phone', 'type' => 'text', 'default' => '', ], [ 'type' => 'sectionend', 'id' => 'kirem_notif_options' ] ]; } return $settings; }, 10, 2); ``` -------------------------------- ### Standard Error Response Format Source: https://kirem.co/docs/response-wrapper This JSON structure is returned when an API request fails, indicated by a 4xx or 5xx HTTP status code. It provides a status code, a global error message, and a detailed breakdown of specific errors. ```json { "status": 400, "message": "Pesan deskriptif mengenai jenis error utama", "errors": { "field_name": "Detail penjelasan spesifik mengenai error pada field ini" } } ``` -------------------------------- ### POST /v1/:phone_number_id/messages Source: https://kirem.co/docs/send-location Sends a location message to a recipient using a specific phone number ID for routing. This is useful for directing messages through a particular WhatsApp Business account. It requires an Authorization header with your API key and a JSON content type. ```APIDOC ## POST /v1/:phone_number_id/messages ### Description Sends a location message to a recipient, routing the message through a specific phone number ID. ### Method POST ### Endpoint /v1/:phone_number_id/messages ### Headers - **Authorization** (string) - Required - Bearer - **Content-Type** (string) - Required - application/json ### Parameters #### Path Parameters - **phone_number_id** (string) - Required - The ID of the phone number to use for sending the message. ### Request Body - **messaging_product** (string) - Required - Set to "whatsapp". - **recipient_type** (string) - Required - Set to "individual". - **to** (string) - Required - The recipient's phone number. - **type** (string) - Required - Set to "location". - **location** (object) - Required - Contains location details. - **longitude** (float) - Required - The longitude coordinate of the location. - **latitude** (float) - Required - The latitude coordinate of the location. - **name** (string) - Optional - The name of the place or building. - **address** (string) - Optional - The full address of the location. ### Request Example ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "location", "location": { "longitude": 106.827153, "latitude": -6.175392, "name": "Monumen Nasional", "address": "Gambir, Kota Jakarta Pusat, DKI Jakarta" } } ``` ### Response #### Success Response (201 Created) - **status** (integer) - The HTTP status code. - **message** (string) - A confirmation message. - **data** (object) - Contains details about the sent message. - **messaging_product** (string) - The messaging product used. - **contacts** (array) - Information about the recipient. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the recipient. - **messages** (array) - Information about the sent messages. - **id** (string) - The unique ID of the message. #### Response Example ```json { "status": 201, "message": "Message sent successfully", "data": { "messaging_product": "whatsapp", "contacts": [{"input": "62812345678", "wa_id": "62812345678"}], "messages": [{"id": "wamid.HBgLNjI4MTIzNDU2NzhGFgQ0NDMzMzc3RUQ1OEFG"}] } } ``` ``` -------------------------------- ### Request Payload for Sending Contacts Source: https://kirem.co/docs/send-contacts This JSON payload is used to send contact information, including addresses, emails, names, organizations, phone numbers, and URLs, to customers. Ensure the 'to' field contains the recipient's phone number and the 'contacts' array is populated with valid vCard data. ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "62812345678", "type": "contacts", "contacts": [ { "addresses": [ { "street": "Gedung Cyber 2, Lt. 15", "city": "Jakarta Selatan", "state": "DKI Jakarta", "zip": "12950", "country": "Indonesia", "type": "WORK" } ], "emails": [ { "email": "support@kirem.id", "type": "WORK" } ], "name": { "formatted_name": "Kirem Support", "first_name": "Kirem", "last_name": "Support" }, "org": { "company": "Kirem Indonesia", "department": "Developer Support" }, "phones": [ { "phone": "+62812345678", "type": "WORK", "wa_id": "62812345678" } ], "urls": [ { "url": "https://kirem.id", "type": "WORK" } ] } ] } ``` -------------------------------- ### cURL Request: Outbound Messages to Specific Number Source: https://kirem.co/docs/pull-message-logs This cURL command fetches outbound messages sent to a specific recipient number. It filters by 'outbound' direction, specifies the recipient's number, and limits results to 20. ```bash curl -X GET "https://api.kirem.co/v1/analytics/messages?direction=outbound&recipient=62812345678&limit=20" \ -H "Authorization: Bearer kirem_live_xxx" ``` -------------------------------- ### Retrieve Outbound Messages to a Specific Number Source: https://kirem.co/docs/pull-message-logs Fetches outbound messages sent to a particular recipient number. You can set a limit for the number of records. ```APIDOC ## GET /v1/analytics/messages?direction=outbound&recipient={recipient}&limit={limit} ### Description Retrieves outbound message logs directed to a specific recipient. ### Method GET ### Endpoint /v1/analytics/messages ### Query Parameters - **direction** (string) - Required - Filters messages by direction. Use 'outbound' for messages sent from your system. - **recipient** (string) - Required - The phone number of the recipient (international format). - **limit** (integer) - Optional - The maximum number of messages to return. ``` --- ## 🔗 Tautan Halaman Resmi - Website Utama: [https://kirem.co](https://kirem.co) - Dokumentasi Lengkap: [https://kirem.co/docs](https://kirem.co/docs) - Harga Layanan: [https://kirem.co/pricing](https://kirem.co/pricing) - Integrasi Platform: [https://kirem.co/integrations](https://kirem.co/integrations)