# Cara Mengirim Pesan Text via API

## Intro
Artikel ini merupakan dokumentasi API yang dapat membantu kamu dalam pengembangan serta integrasi ke sistem kamu melalui API alatwa, pastikan kamu telah **memiliki API KEY** untuk melanjutkan tutorial ini, namun jika kamu belum memiliki API KEY bisa kunjungi halaman cara mendapatkan API KEY.

## Tutorial
### Request
#### Target URL
```html
https://app.alatwa.com/api/send/message/text
``` 
#### Header
- Content-Type: application/json
- Authorization: **API KEY**

#### Body

```json
{
  "device": "Your Device ID",
  "phone": "WhatsApp Number Receiver",
  "message": "Your Message"
}
``` 
### Response

```json
{
  "status": "ok",
  "message_id": "3EB07186F0298BF9E5E8",
  "from": "628129876543",
  "to": "628123456789"
}
``` 
## Example for PHP

```php
$header = array(
    "Content-Type: application/json",
    "Authorization: Your API KEY"
);

$data = array(
    "device" => "Your Device ID",
    "type" => "text",
    "phone" => "628123456789",
    "message" => "test message"
);

$param_post = json_encode($data, JSON_PRETTY_PRINT);
$post        = curl_init("https://app.alatwa.com/api/send/message/text");
curl_setopt($post, CURLOPT_HTTPHEADER, $header);
curl_setopt($post, CURLOPT_POST, 1);
curl_setopt($post, CURLOPT_POSTFIELDS, $param_post);
curl_setopt($post, CURLOPT_RETURNTRANSFER, true);
curl_setopt($post, CURLOPT_CONNECTTIMEOUT, 0); 
curl_setopt($post, CURLOPT_TIMEOUT, 5);
$response = curl_exec($post);
curl_close($post);
echo $response;
``` 
## Conclusion
API alatwa dibuat sesimpel mungkin agar mudah dipahami dan diintegrasikan, jika masih ada yang belum dipahami bisa ditanyakan dikolom komentar atau chat melalui [WhatsApp](https://api.whatsapp.com/send?phone=6289669342954).

> Device ID bisa dilihat di menu device, masing-masing device memiliki Device ID
