API Send Message

Basic code for sending message through API

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.fonnte.com/send',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
'target' => '08123456789|Fonnte|Admin,08123456789|Lili|User',
'message' => 'test message to {name} as {var1}',
'url' => 'https://md.fonnte.com/images/wa-logo.png',
'filename' => 'filename',
'schedule' => '0',
'delay' => '2',
'countryCode' => '62',
'buttonJSON' => '{"message":"fonnte button message","footer":"fonnte footer message","buttons":[{"id":"mybutton1","message":"hello fonnte"},{"id":"mybutton2","message":"fonnte pricing"},{"id":"mybutton3","message":"tutorial fonnte"}]}',
'templateJSON' => '{"message":"fonnte template message","footer":"fonnte footer message","buttons":[{"message":"fonnte","url":"https://fonnte.com"},{"message":"call me","tel":"6282227097005"},{"id":"mybutton1","message":"hello fonnte"}]}',
'listJSON' => '{"message":"fonnte list message","footer":"fonnte footer message","buttonTitle":"fonnte's packages","title":"fonnte title","buttons":[{"title":"text only","list":[{"message":"regular","footer":"10k messsages/month","id":"list-1"},{"message":"regular pro","footer":"25k messsages/month","id":"list-2"},{"message":"master","footer":"unlimited messsages/month","id":"list-3"}]},{"title":"all feature","list":[{"message":"super","footer":"10k messsages/month","id":"list-4"},{"message":"advanced","footer":"25k messsages/month","id":"list-5"},{"message":"ultra","footer":"unlimited messsages/month","id":"list-6"}]}]}'
),
  CURLOPT_HTTPHEADER => array(
    'Authorization: TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

If you prefer to see on postman, see here.

Available parameter

  • target (required) (string) - target number, separate with comma, support variable
  • message (optional) (string) - text message, support variable
  • url (optional) (string) - support image, file, audio, video, optional
  • filename (optional) (string) - custom filename, optional
  • schedule (optional) (int) - unix timestamp to send message on schedule
  • delay (optional) (int) - min 0, optional
  • countryCode (int) - replace first zero with country code, default 62, optional
  • buttonJSON (string) - json format for sending button message, footer is optional, max 3 buttons, id is optional if the response is not needed, support image/video combined with url field
  • templateJSON (string) - json format for sending template message, footer is optional, support call/url/normal button, id is optional if the response is not needed, text only, does not work on iphone yet
  • listJSON (string) - json format for sending list message, footer is optional, title is optional, buttons->title is optional, list->footer is optional, id is optional if the response is not needed, text only

TOKEN must be filled by your own token. See how to get token.

Sending multiple numbers can be done by adding comma. ex: 6282xxxxxx,6285xxxxxxxx,6283xxxxxxxxx.

Sending variable supported on API.

Filename only works on file and audio type.

Response

successfull run response example

{
    "detail": "success! message in queue",
    "id": [
        "15362"
    ],
    "process": "processing",
    "status": true,
    "target": [
        "6282227097005"
    ]
}

There are 3 detail on successfull run API

  1. Success! message in queue : will be processed immediately
  2. Success! message will be sent on scheduled time : will be processed on scheduled time
  3. Success! message pending due to server issue, will be sent later : there is something wrong with the server, but your message will be sent shortly after the server run again.

On 3rd detail, it may happen if server is restarting, server is not responding, server is down, trouble on the network and so on.

It's not your fault, but ours.

Again, your message is saved and will be sent shortly after the server run again.

Failed run response always return status : false

- Invalid token : if the token is invalid

{
    "Status": false,
    "reason": "token invalid"
}

- Input invalid : if any of the value is invalid

{
    "reason": "input invalid",
    "status": false
}

- Url invalid : if url provided invalid

{
    "reason": "url invalid",
    "status": false
}

- Url unreachable : if url not responding

{
    "reason": "url unreachable",
    "status": false
}

- File format not supported : use supported format

Image"png", "jpg", "jpeg", "webp"
Video"mp4"
File"pdf", "doc", "docx", "xls", "xlsx", "csv", "txt"
Audio"mp3"
Max size4MB
{
    "reason": "file format not supported",
    "status": false
}

- File size must under 4MB : file cannot exceed 4MB

{
    "reason": "file size must under 4MB",
    "status": false
}

- Target invalid : target is not a valid number

{
    "reason": "target invalid",
    "status": false
}

- JSON format invalid : invalid JSON format, check your json format

{
    "reason": "JSON format invalid",
    "status": false
}

- Insufficient quota : requested message count > remaining quota. The message(s) will not be saved

{
    "reason": "insufficient quota",
    "status": false
}

Related knowledge

See more
Made with in Indonesia