# Send your first WhatsApp message from your system in 5 minutes.

Four steps with API v2: create a test key, register your phone number as a test number, send one message, then read its status. All examples use the address https://klikflow.id.

Sumber: https://klikflow.id/docs/en/api/quickstart

## What do I need to use the Klik Flow API?

A Klik Flow account and one connected WhatsApp number (scan QR or WhatsApp Official). Test keys can be created on every plan; live keys need a plan with the API feature. The key is sent in the header of every request; no SDK has to be installed.

## 1. Create a test API key

Open Settings › API & Webhook › Create key (Pengaturan › API & Webhook › Buat kunci). Choose the Test type (Tes), give it a name, then tick the permissions View business and channels (Lihat bisnis dan saluran) and Send messages (Kirim pesan). The `kf_test_…` key is shown only once: store it as a secret on your server, not in a mobile app or web page code.

- Test keys send only to test numbers and do not use the plan's message quota.
- When the integration is ready, create a Live key (`kf_live_…`) with the same permissions.

## 2. Register a test number

Send one WhatsApp message from your phone to the business's WhatsApp number. Then add that phone number in Settings › API & Webhook › Test numbers (Nomor uji), up to 5 numbers.

## 3. Send a message

The destination number uses the country code; `08…` automatically becomes `628…`.

```
curl -X POST "https://klikflow.id/api/v2/messages" \
  -H "Authorization: Bearer KUNCI_API" \
  -H "Idempotency-Key: 6f1c2a8e-4b1d-4c3a-9e2f-1a2b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{"channel":"whatsapp_qr","to":"6281234567890","type":"text","text":{"body":"Hello from the Klik Flow API"}}'
```

Successful response:

```
{
  "data": { "id": 99140, "object": "message", "conversation_id": 812, "channel": "whatsapp_qr", "to": "6281234567890", "type": "text", "status": "sent", "test": true }
}
```

Sends also appear in the Inbox. For WhatsApp Official, set `channel` to `whatsapp_official`.

## 4. Check the status

```
curl "https://klikflow.id/api/v2/messages/99140" -H "Authorization: Bearer KUNCI_API"
```

`status` holds `pending`, `sent`, `delivered`, `read`, or `failed`.

## If it fails

Every error uses the matching HTTP status and the same shape:

```
{
  "error": {
    "type": "permission_error",
    "code": "test_number_required",
    "message": "Kunci tes hanya mengirim ke nomor uji. …",
    "param": "to",
    "doc_url": "https://klikflow.id/docs/api/error#test_number_required",
    "request_id": "req_8Kx2Qm"
  }
}
```

`doc_url` points to the explanation of that code. When a limit is reached (429), wait for the time in the `Retry-After` header.
