Appearance
Send Text Message
About 719 wordsAbout 2 min
Send Basic Text Messages
Use this endpoint to send basic text messages. You can specify a single recipient phone number.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
number | string | Yes | Recipient phone number in any format (digits only extracted internally). |
message | string | Yes | Text content of the message. Required for text, buttons, interactive, and optional for others. |
message_type | string | Yes | Type of message to send. One of: text, image, video, audio, document, location, buttons, interactive. |
media_url | string | No | URL of media file (image/video/audio/document) to send, depending on message_type. |
file_name | string | No | File name for documents (e.g. document.pdf). |
mimetype | string | No | MIME type of media, e.g., image/jpeg, video/mp4, audio/mp4, application/pdf. |
latitude | number | No | Latitude coordinate for location messages. |
longitude | number | No | Longitude coordinate for location messages. |
buttons | array | No | Array of button objects for interactive messages. Each button should have buttonId and displayText. |
quoted_message_id | string | No | ID of the message to quote (reply to). |
quoted_message | string | No | Fallback text content for the quoted message if the original message is not found in the store. |
API Endpoint
POST https://app.rapiwa.com/api/send-messageHeader
Content-Type: application/json
Authorization: Bearer Your_Device_KeyBody
{
"number": "88017XXXXXXXX",
"message_type": "text",
"message": "Hello!"
}###Response:
{
"success": true,
"message_type": "text",
"message_id": "3EB0FAC204D805F0E22293",
"to": "88017XXXXXXXXX"
}Code examples
bash
curl -X POST "https://app.rapiwa.com/api/send-message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Your_Device_Key" \
-d '{"number":"88017XXXXXXXX","message_type":"text","message":"Hello!"}'python
import requests
url = "https://app.rapiwa.com/api/send-message"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer Your_Device_Key"
}
payload = {
"number": "88017XXXXXXXX",
"message_type": "text",
"message": "Hello!"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())javascript
const response = await fetch('https://app.rapiwa.com/api/send-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer Your_Device_Key'
},
body: JSON.stringify({
number: '88017XXXXXXXX',
message_type: 'text',
message: 'Hello!'
})
});
const data = await response.json();
console.log(data);php
<?php
$url = 'https://app.rapiwa.com/api/send-message';
$data = [
'number' => '88017XXXXXXXX',
'message_type' => 'text',
'message' => 'Hello!'
];
$options = [
'http' => [
'header' => "Content-Type: application/json\r\nAuthorization: Bearer Your_Device_Key\r\n",
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;ruby
require 'net/http'
require 'json'
uri = URI('https://app.rapiwa.com/api/send-message')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer Your_Device_Key'
request.body = {
number: '88017XXXXXXXX',
message_type: 'text',
message: 'Hello!'
}.to_json
response = http.request(request)
puts response.bodygo
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
url := "https://app.rapiwa.com/api/send-message"
payload := map[string]string{
"number": "88017XXXXXXXX",
"message_type": "text",
"message": "Hello!",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer Your_Device_Key")
client := &http.Client{}
client.Do(req)
}csharp
using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer Your_Device_Key");
var payload = new {
number = "88017XXXXXXXX",
message_type = "text",
message = "Hello!"
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://app.rapiwa.com/api/send-message", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://app.rapiwa.com/api/send-message"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer Your_Device_Key")
.method("POST", HttpRequest.BodyPublishers.ofString(
"{\"number\":\"88017XXXXXXXX\",\"message_type\":\"text\",\"message\":\"Hello!\"}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());swift
import Foundation
let url = URL(string: "https://app.rapiwa.com/api/send-message")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("Bearer Your_Device_Key", forHTTPHeaderField: "Authorization")
request.httpBody = try? JSONEncoder().encode([
"number": "88017XXXXXXXX",
"message_type": "text",
"message": "Hello!"
])
let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)powershell
$headers = @{
"Content-Type" = "application/json"
"Authorization" = "Bearer Your_Device_Key"
}
$body = @{
number = "88017XXXXXXXX"
message_type = "text"
message = "Hello!"
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://app.rapiwa.com/api/send-message" -Method Post -Headers $headers -Body $bodytypescript
const response = await fetch('https://app.rapiwa.com/api/send-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer Your_Device_Key'
},
body: JSON.stringify({
number: '88017XXXXXXXX',
message_type: 'text',
message: 'Hello!'
})
});
const data = await response.json();
console.log(data);rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.post("https://app.rapiwa.com/api/send-message")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer Your_Device_Key")
.json(&json!({
"number": "88017XXXXXXXX",
"message_type": "text",
"message": "Hello!"
}))
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}💡 Tip: Keep your Device Key secure. Never share it publicly.
