Send Message
Send any type of message using the unified send endpoint
Send Message
Send any type of message (text, image, video, file, etc.) using the unified send endpoint.
Endpoint
POST /send
Headers
Name | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token for authentication |
Content-Type | string | Yes | application/json |
Request Body
Field | Type | Required | Description |
---|---|---|---|
session | string | Yes | The session ID |
to | string | Yes | Recipient's phone number in international format (e.g., "+1234567890") |
text | string | No | Message text or caption |
imageUrl | string | No | URL of the image to send |
videoUrl | string | No | URL of the video to send |
documentUrl | string | No | URL of the document to send |
audioUrl | string | No | URL of the audio to send |
mimetype | string | No | MIME type of the media (e.g., "image/jpeg", "video/mp4") |
filename | string | No | Name of the file to send |
preview | object | No | Custom link preview information ({[ key: string ]: string} ) |
Response
{
"id": "string",
"content": "string",
"type": "string",
"timestamp": "string",
"status": "string",
"fromMe": boolean,
"sender": "string",
"to": "string",
"recipient": "string"
}
Examples
# Send a text message
curl -X POST "https://api.wasend.dev/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session": "sessionId",
"to": "+1234567890",
"text": "Hello from WASend!"
}'
# Send an image
curl -X POST "https://api.wasend.dev/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session": "sessionId",
"to": "+1234567890",
"imageUrl": "https://example.com/image.jpg",
"text": "Check out this image!",
"mimetype": "image/jpeg"
}'
import { WasendClient } from '@wasend/core';
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
// Send a text message
const textMessage = await client.send({
session: "sessionId",
to: "+1234567890",
text: "Hello from WASend!"
});
// Send an image
const imageMessage = await client.send({
session: "sessionId",
to: "+1234567890",
imageUrl: "https://example.com/image.jpg",
text: "Check out this image!",
mimetype: "image/jpeg"
});
const { WasendClient } = require('@wasend/core');
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
// Send a text message
const textMessage = await client.send({
session: "sessionId",
to: "+1234567890",
text: "Hello from WASend!"
});
// Send an image
const imageMessage = await client.send({
session: "sessionId",
to: "+1234567890",
imageUrl: "https://example.com/image.jpg",
text: "Check out this image!",
mimetype: "image/jpeg"
});
from wasend import WasendClient
client = WasendClient(
api_key='YOUR_API_KEY',
base_url='https://api.wasend.dev'
)
# Send a text message
text_message = client.send(
session="sessionId",
to="+1234567890",
text="Hello from WASend!"
)
# Send an image
image_message = client.send(
session="sessionId",
to="+1234567890",
image_url="https://example.com/image.jpg",
text="Check out this image!",
mimetype="image/jpeg"
)
package main
import (
"fmt"
"github.com/wasenddev/wasend-sdk-go/wasendcore"
)
func StringPtr(s string) *string { return &s }
func Float64Ptr(f float64) *float64 { return &f }
func main() {
client := wasendcore.NewWasendClient(&wasendcore.WasendConfig{
ApiKey: StringPtr("YOUR_API_KEY"),
BaseUrl: StringPtr("https://api.wasend.dev"),
})
// Send a text message
textMessage := client.Send(&wasendcore.SendRequest{
Session: StringPtr("sessionId"),
To: StringPtr("+1234567890"),
Text: StringPtr("Hello from WASend!"),
})
fmt.Printf("Text message sent: %+v\n", textMessage)
// Send an image
imageMessage := client.Send(&wasendcore.SendRequest{
Session: StringPtr("sessionId"),
To: StringPtr("+1234567890"),
ImageUrl: StringPtr("https://example.com/image.jpg"),
Text: StringPtr("Check out this image!"),
Mimetype: StringPtr("image/jpeg"),
})
fmt.Printf("Image message sent: %+v\n", imageMessage)
}
using Wasend.Core;
var config = new WasendConfig
{
ApiKey = "your-api-key-here" // Required
// BaseUrl and Timeout are optional and have default values
};
var client = new WasendClient(config);
// Send a text message
var textMessage = client.Send(new SendRequest
{
Session = "sessionId",
To = "+1234567890",
Text = "Hello from WASend!"
});
// Send an image
var imageMessage = client.Send(new SendRequest
{
Session = "sessionId",
To = "+1234567890",
ImageUrl = "https://example.com/image.jpg",
Text = "Check out this image!",
Mimetype = "image/jpeg"
});
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
// Send a text message
JSONObject textBody = new JSONObject()
.put("session", "sessionId")
.put("to", "+1234567890")
.put("text", "Hello from WASend!");
HttpRequest textRequest = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/send"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(textBody.toString()))
.build();
HttpResponse<String> textResponse = client.send(textRequest, HttpResponse.BodyHandlers.ofString());
System.out.println("Text message response: " + textResponse.body());
// Send an image
JSONObject imageBody = new JSONObject()
.put("session", "sessionId")
.put("to", "+1234567890")
.put("imageUrl", "https://example.com/image.jpg")
.put("text", "Check out this image!")
.put("mimetype", "image/jpeg");
HttpRequest imageRequest = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/send"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(imageBody.toString()))
.build();
HttpResponse<String> imageResponse = client.send(imageRequest, HttpResponse.BodyHandlers.ofString());
System.out.println("Image message response: " + imageResponse.body());
}
}
<?php
$ch = curl_init();
// Send a text message
$textData = [
'session' => 'sessionId',
'to' => '+1234567890',
'text' => 'Hello from WASend!'
];
curl_setopt($ch, CURLOPT_URL, "https://api.wasend.dev/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($textData));
$textResponse = curl_exec($ch);
echo "Text message response: " . $textResponse . "\n";
// Send an image
$imageData = [
'session' => 'sessionId',
'to' => '+1234567890',
'imageUrl' => 'https://example.com/image.jpg',
'text' => 'Check out this image!',
'mimetype' => 'image/jpeg'
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($imageData));
$imageResponse = curl_exec($ch);
echo "Image message response: " . $imageResponse . "\n";
curl_close($ch);
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://api.wasend.dev/send')
# Send a text message
text_data = {
session: 'sessionId',
to: '+1234567890',
text: 'Hello from WASend!'
}
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = text_data.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts "Text message response: #{response.body}"
# Send an image
image_data = {
session: 'sessionId',
to: '+1234567890',
imageUrl: 'https://example.com/image.jpg',
text: 'Check out this image!',
mimetype: 'image/jpeg'
}
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = image_data.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts "Image message response: #{response.body}"
import Foundation
let url = URL(string: "https://api.wasend.dev/send")!
// Send a text message
var textRequest = URLRequest(url: url)
textRequest.httpMethod = "POST"
textRequest.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
textRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
let textData: [String: Any] = [
"session": "sessionId",
"to": "+1234567890",
"text": "Hello from WASend!"
]
textRequest.httpBody = try? JSONSerialization.data(withJSONObject: textData)
let textTask = URLSession.shared.dataTask(with: textRequest) { data, response, error in
if let data = data {
print("Text message response: \(String(data: data, encoding: .utf8) ?? "")")
}
}
textTask.resume()
// Send an image
var imageRequest = URLRequest(url: url)
imageRequest.httpMethod = "POST"
imageRequest.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
imageRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
let imageData: [String: Any] = [
"session": "sessionId",
"to": "+1234567890",
"imageUrl": "https://example.com/image.jpg",
"text": "Check out this image!",
"mimetype": "image/jpeg"
]
imageRequest.httpBody = try? JSONSerialization.data(withJSONObject: imageData)
let imageTask = URLSession.shared.dataTask(with: imageRequest) { data, response, error in
if let data = data {
print("Image message response: \(String(data: data, encoding: .utf8) ?? "")")
}
}
imageTask.resume()
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str("Bearer YOUR_API_KEY")?
);
headers.insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")?
);
let client = reqwest::Client::new();
// Send a text message
let text_body = json!({
"session": "sessionId",
"to": "+1234567890",
"text": "Hello from WASend!"
});
let text_response = client
.post("https://api.wasend.dev/send")
.headers(headers.clone())
.json(&text_body)
.send()
.await?
.text()
.await?;
println!("Text message response: {}", text_response);
// Send an image
let image_body = json!({
"session": "sessionId",
"to": "+1234567890",
"imageUrl": "https://example.com/image.jpg",
"text": "Check out this image!",
"mimetype": "image/jpeg"
});
let image_response = client
.post("https://api.wasend.dev/send")
.headers(headers)
.json(&image_body)
.send()
.await?
.text()
.await?;
println!("Image message response: {}", image_response);
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the message |
content | string | Content of the message |
type | string | Type of the message (text, image, video, etc.) |
timestamp | string | When the message was sent |
status | string | Current status of the message |
fromMe | boolean | Whether the message was sent by you |
sender | string | Sender's phone number |
to | string | The recipient's phone number or group JID |
recipient | string | The message recipient |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Session or recipient not found |
429 | Too many requests - Rate limit exceeded |
500 | Internal server error |
Notes
- Phone numbers must be in international format (e.g., "+1234567890")
- The @c.us suffix is automatically added by the API
- For media messages, the URL must be publicly accessible
- Supported media types: image, video, document, audio
- Maximum file size: 16MB for media files
- Maximum text length: 4096 characters