Tokolaku Messaging API
Endpoint publik (Bearer secret key) untuk membalas & mengirim pesan.
Endpoint publik (Bearer secret key) untuk membalas & mengirim pesan.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/tokolaku-id:tokolaku-id-messaging-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Tokolaku Engine Messaging API
version: 1.0.0
description: 'REST API untuk integrasi bot AI, pengiriman pesan (WhatsApp/Instagram/Messenger via BYON), webhook real-time, dan manajemen sub-akun/reseller di Tokolaku.
**Autentikasi**
- Endpoint publik `/api/v1/*` (Messaging): header `Authorization: Bearer ` (format `tk_live_sk_...` / `tk_test_sk_...`). Setiap key punya scope (`chat:write`, `messages:write`, dst).
- Endpoint dashboard `/api/dev/*`: sesi login (cookie) developer — dipanggil dari aplikasi/dashboard kamu sendiri, bukan server-to-server publik.
**Webhook (kami → aplikasi kamu)**
Event `message.received` dan `message.status` dikirim sebagai `POST` ke URL webhook yang kamu daftarkan, dengan header:
- `X-Tokolaku-Event`: nama event (mis. `message.received`)
- `X-Tokolaku-Signature`: `sha256=`
- `X-Tokolaku-Delivery`: id pengiriman (dipakai juga untuk dedup saat retry)
Body mengikuti skema `WebhookEvent`. Balas `2xx` untuk menandai sukses; kegagalan di-retry dengan backoff eksponensial (60s → 1920s, hingga 6x).'
contact:
name: Tokolaku
url: https://tokolaku.id
servers:
- url: https://api.tokolaku.id
description: Production
security:
- bearerAuth: []
tags:
- name: Messaging
description: Endpoint publik (Bearer secret key) untuk membalas & mengirim pesan.
paths:
/api/v1/bot/reply:
post:
tags:
- Messaging
summary: Balas pesan pelanggan pakai engine bot tenant
description: Membalas satu pesan pelanggan memakai AI Agent tenant. Butuh scope `chat:write`.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BotReplyRequest'
example:
message: ayam geprek masih ada?
session_id: sess_abc
history: []
responses:
'200':
description: Balasan bot berhasil dibuat
content:
application/json:
schema:
$ref: '#/components/schemas/BotReplyResponse'
example:
reply: Halo kak! Ayam geprek ready ya, Rp18.000/porsi. Mau pesan berapa?
parts:
- Halo kak! Ayam geprek ready ya, Rp18.000/porsi. Mau pesan berapa?
'401':
description: API key tak ada / tidak valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: no_key
message: API key tak ada / tidak valid
'402':
description: Saldo API tidak cukup
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: insufficient_balance
message: Saldo API tidak cukup
'403':
description: Key tidak punya scope chat:write
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: invalid_scope
message: Key tidak punya scope chat:write
'422':
description: AI Agent belum diaktifkan untuk sub-akun ini
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: ai_not_configured
message: AI Agent belum diaktifkan untuk sub-akun ini
'429':
description: Kuota percakapan bulan ini habis
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: quota_exceeded
message: Kuota percakapan bulan ini habis
operationId: postApiV1BotReply
x-operation-id-source: derived
/api/v1/messages:
post:
tags:
- Messaging
summary: Kirim pesan (text/template) via channel resmi
description: 'Model BYON (Bring Your Own Number): nomor klien di-connect lewat Tokolaku (Tech Provider resmi Meta), dikirim dari app kamu. Butuh scope `messages:write`. Pesan sesi (dalam 24 jam) gratis; pesan template (business-initiated) berbayar passthrough Meta + markup.'
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MessageRequest'
examples:
session_text:
summary: Pesan sesi (dalam 24 jam, gratis)
value:
to: '6281234567890'
type: text
text: Halo, pesanan kakak sudah dikirim ya!
template:
summary: Template (business-initiated, berbayar)
value:
to: '6281234567890'
type: template
channel_id: ch_...
template:
name: order_update
language: id
category: utility
responses:
'200':
description: Pesan berhasil dikirim
content:
application/json:
schema:
$ref: '#/components/schemas/MessageResponse'
example:
id: msg_...
channel_id: ch_...
to: '6281234567890'
type: template
status: sent
provider_message_id: wamid.HBg...
charged_idr: 840
'400':
description: Body request tidak valid / channel tidak sesuai
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
examples:
no_channel:
value:
error:
code: no_channel
message: Belum ada channel resmi aktif
channel_id_required:
value:
error:
code: channel_id_required
message: Sertakan channel_id (channel > 1)
template_not_supported:
value:
error:
code: template_not_supported
message: 'Template hanya untuk WhatsApp (IG/Messenger: text saja)'
'402':
description: Saldo API tidak cukup
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: insufficient_balance
message: Saldo API tidak cukup
'422':
description: Tarif pesan belum diset
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: unpriced_category
message: Tarif pesan belum diset
'502':
description: Gagal kirim ke Meta
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
example:
error:
code: send_failed
message: Gagal kirim ke Meta
operationId: postApiV1Messages
x-operation-id-source: derived
components:
schemas:
ErrorEnvelope:
type: object
description: Envelope error konsisten untuk semua endpoint Engine API.
properties:
error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
required:
- error
MessageResponse:
type: object
properties:
id:
type: string
description: Id internal (dipakai untuk idempotensi charge)
channel_id:
type: string
to:
type: string
type:
type: string
enum:
- text
- template
status:
type: string
provider_message_id:
type: string
charged_idr:
type: number
description: 0 untuk pesan sesi atau saat billing pesan OFF
required:
- id
- channel_id
- to
- type
- status
- provider_message_id
- charged_idr
BotReplyRequest:
type: object
properties:
message:
type: string
session_id:
type: string
history:
type: array
items:
type: object
required:
- message
BotReplyResponse:
type: object
properties:
reply:
type: string
parts:
type: array
items:
type: string
required:
- reply
- parts
MessageRequest:
type: object
properties:
to:
type: string
description: Nomor tujuan (format 62...)
type:
type: string
enum:
- text
- template
text:
type: string
description: Wajib jika type=text
channel_id:
type: string
description: Wajib jika sub-akun punya > 1 channel resmi
template:
type: object
description: Wajib jika type=template
properties:
name:
type: string
language:
type: string
category:
type: string
required:
- to
- type
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: 'Secret key developer, format `tk_live_sk_...` (produksi) atau `tk_test_sk_...` (sandbox). Kirim via header `Authorization: Bearer <key>` (atau `X-API-Key: <key>`).'
sessionAuth:
type: apiKey
in: cookie
name: session
description: Endpoint dashboard `/api/dev/*` diautentikasi via sesi login developer (cookie), bukan API key — dipanggil dari aplikasi/dashboard kamu sendiri saat sudah login.