API Documentations


Authentication

Introduction

This API is authenticated by using Bearer Token authentication for each endpoint request. The HTTP client must send this token in the Authorization header when making requests to protected resources:

Authorization: Bearer [API_TOKEN]

For example, your authentication header will look something like this:

Authorization: Bearer 8d162cc813ce4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Obtaining API token

API token is set per device. You can get your token by the steps:

  1. Log into your account.
  2. Navigate to the device page by clicking on "Devices" on the top navigation bar.
  3. In the actions column, click "View" button to view device.
  4. The token is shown under the "Token" column.

Rate Limits

There are 2 types of rate limits:

  1. Per minute 60 calls.
  2. Per day Based on the user's subscribed package.

Status

This endpoint is to retrieve the status of the device.

GET https://onsend.io/api/v1/status

Code Samples

<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://onsend.io/api/v1/status',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_POSTFIELDS => '',
    CURLOPT_HTTPHEADER => [
        'Accept: application/json',
        'Authorization: Bearer [API_TOKEN]',
    ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo 'cURL Error #:' . $err;
} else {
    echo $response;
}
<?php

$response = \Illuminate\Support\Facades\Http::accept('application/json')
    ->withToken('[API_TOKEN]')
    ->get('https://onsend.io/api/v1/status');

dump($response->body());
curl --header "Accept: application/json" \
    --header "Authorization: Bearer [API_TOKEN]" \
    https://onsend.io/api/v1/status

Send

Send a message to specified receiver.

POST https://onsend.io/api/v1/send

Parameters

Attribute Description
phone_number string
required
Intended phone number of the message receiver with country code.
Example: 60123456789
message string
required IF user wants to send text message only
Text message to be sent. Sent as caption if an image or video is sent.
Example: Hello world
type string
required
Type of message to send. Can be either text, image, video, or document .
Example: image
url string
required IF user wants to send media [image, video, document]
The media URL. Currently only suppot URL from live servers.
Example: https://example.com/logo.png
mimetype string
required IF user wants to send document
MIME type or media type of the document to be sent.
Example: application/pdf
filename string
optional
The file name of document to be sent.
Example: invoice.pdf

Data Samples

{
    "phone_number": "60123456789",
    "message": "Hello world"
}
{
    "phone_number": "60123456789",
    "message": "Logo",
    "type": "image",
    "url": "https://example.com/logo.png"
}
{
    "phone_number": "60123456789",
    "message": "My video",
    "type": "video",
    "url": "https://example.com/myvideo.mp4"
}
{
    "phone_number": "60123456789",
    "type": "document",
    "url": "https://example.com/invoice.pdf",
    "mimetype": "application/pdf",
    "filename": "invoice.pdf"
}

Code Samples

<?php

$curl = curl_init();

$data = [
    'phone_number' => '60123456789',
    'message' => 'Hello world',
];

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://onsend.io/api/v1/send',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'Accept: application/json',
        'Authorization: Bearer [API_TOKEN]',
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo 'cURL Error #:' . $err;
} else {
    echo $response;
}
<?php

$data = [
    'phone_number' => '60123456789',
    'message' => 'Hello world',
];

$response = \Illuminate\Support\Facades\Http::accept('application/json')
    ->withToken('[API_TOKEN]')
    ->post('https://onsend.io/api/v1/send', $data);

dump($response->body());
curl --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer [API_TOKEN]" \
    --request POST \
    --data '{"phone_number":"60123456789","message":"Hello world"}' \
    https://onsend.io/api/v1/send


ONPAY SOLUTIONS SDN BHD

87-3, Third Floor, Block D, Platinum Walk, 53300 Setapak, Kuala Lumpur

Useful Links

Contact Us

+603-2770 2774

Follow Us