OneBloc

Message API Developer Documentation

Getting Started

Get your API Key

Contact admin to create a tenant account. You'll receive a unique API key for authentication.

Connect WhatsApp

Open the Tenant Portal, scan the QR code with your phone, and your WhatsApp is linked.

Open Tenant Portal →

Start Sending

Use any of the SDK libraries below, or call the API directly from your application.

Authentication

All API requests require the x-api-key header:

// Add this header to every request
x-api-key: your-api-key-here

API Endpoints

POST/send-message

Send a WhatsApp message to any phone number.

{
  "recipientPhone": "60123456789",
  "message": "Hello! Your booking is confirmed.",
  "messageType": "text"
}

Phone formats accepted: 60123456789, +60 12-345 6789, 012-345 6789

POST/send-job

Dispatch a work job to a worker. They receive a formatted WhatsApp message with reply options.

{
  "workerPhone": "60123456789",
  "clientName": "Puan Siti",
  "task": "Deep cleaning - 3BR apartment",
  "location": "123 Jalan Ampang, KL",
  "mapLink": "https://maps.google.com/..."
}
GET/tenant/status

Check your WhatsApp connection status.

GET/tenant/usage

Get your daily token usage and remaining balance.

GET/jobs?status=PENDING&limit=50

List your dispatched jobs. Filter by status: PENDING, IN_PROGRESS, DONE, ISSUE, DELAYED.

GET/messages/status?phone=60123456789

Check message delivery status for a specific phone number.

POST/messages/retry

Retry all failed messages in your queue.

Token System

Message TypeToken Cost
Text message1 token
Image2 tokens
Voice note2 tokens

Tokens reset daily at midnight UTC. Contact admin to increase your daily limit.

Code Examples

VB.NET
JavaScript
PHP
cURL
' Initialize
Dim wa As New MessageAPI("https://messageapi.onebloc.io", "your-api-key")

' Send a message
Dim result = Await wa.SendMessage("60123456789", "Booking confirmed!")
If result.Success Then
    MessageBox.Show("Message sent!")
End If

' Send a job
Dim job = Await wa.SendJob( _
    workerPhone:="60123456789", _
    clientName:="Puan Siti", _
    task:="Deep cleaning - 3BR apartment", _
    location:="Jalan Ampang, KL" _
)

' Check usage
Dim usage = Await wa.GetUsage()

Download: MessageAPI.vb

// Initialize
const wa = new MessageAPI('https://messageapi.onebloc.io', 'your-api-key');

// Send a message
const result = await wa.sendMessage('60123456789', 'Booking confirmed!');
console.log(result.data);

// Send a job
const job = await wa.sendJob(
  '60123456789', 'Puan Siti',
  'Deep cleaning', 'Jalan Ampang KL'
);

// Check usage
const usage = await wa.getUsage();

Download: MessageAPI.js

// Initialize
$wa = new MessageAPI('https://messageapi.onebloc.io', 'your-api-key');

// Send a message
$result = $wa->sendMessage('60123456789', 'Booking confirmed!');
if ($result['success']) {
    echo "Sent!";
}

// Send a job
$job = $wa->sendJob(
  '60123456789', 'Puan Siti',
  'Deep cleaning', 'Jalan Ampang KL'
);

// Check usage
$usage = $wa->getUsage();

Download: MessageAPI.php

# Send a message
curl -X POST https://messageapi.onebloc.io/send-message \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-api-key" \
  -d '{"recipientPhone":"60123456789","message":"Hello!","messageType":"text"}'

# Check status
curl https://messageapi.onebloc.io/tenant/status \
  -H "x-api-key: your-api-key"

# Get usage
curl https://messageapi.onebloc.io/tenant/usage \
  -H "x-api-key: your-api-key"

Worker Reply Commands

When workers receive a job via WhatsApp, they can reply with:

ReplyAction
DONEMark job as completed
ISSUEFlag a problem with the job
DELAY 30Delay job by 30 minutes
STARTMark job as in progress
ARRIVEDConfirm arrival at location
Send a photoAttached as proof to the job
Send a voice noteTranscribed and logged