Trimite mesaj text
Trimite un mesaj simplu catre un numar WhatsApp. Optional, poti crea contactul automat daca nu exista.
| Câmp | Tip | Obligatoriu | Descriere |
|---|---|---|---|
phone_number | string | Da | Numărul destinatarului în format internațional, fără + |
message_body | string | Da | Textul mesajului de trimis |
from_phone_number_id | string | Nu | ID-ul numărului sursă; dacă lipsește se folosește cel implicit |
contact | object | Nu | Crează sau actualizează contactul dacă nu există deja |
contact.groups | string | Nu | Grupuri separate prin virgulă, ex: grup1,grup2 |
contact.custom_fields | object | Nu | Câmpuri custom, ex: {"BDay":"2025-09-04"} |
{
"from_phone_number_id": "",
"phone_number": "918856066529",
"message_body": "your message body",
"contact": {
"first_name": "Johan",
"last_name": "Doe",
"email": "johndoe@doamin.com",
"country": "india",
"language_code": "en",
"groups": "examplegroup1,examplegroup2",
"custom_fields": { "BDay": "2025-09-04" }
}
}
curl -X POST "https://app.whapi.ro/api/{vendorUid}/contact/send-message" \
-H "Authorization: Bearer {bearerToken}" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "918856066529",
"message_body": "your message body"
}'
<?php
$ch = curl_init('https://app.whapi.ro/api/{vendorUid}/contact/send-message');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer {bearerToken}',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '918856066529',
'message_body' => 'your message body',
]),
]);
echo curl_exec($ch);
curl_close($ch);
const res = await fetch(
'https://app.whapi.ro/api/{vendorUid}/contact/send-message',
{
method: 'POST',
headers: {
'Authorization': 'Bearer {bearerToken}',
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone_number: '918856066529',
message_body: 'your message body',
}),
}
);
const data = await res.json();
console.log(data);
import requests
response = requests.post(
'https://app.whapi.ro/api/{vendorUid}/contact/send-message',
headers={
'Authorization': 'Bearer {bearerToken}',
'Content-Type': 'application/json',
},
json={
'phone_number': '918856066529',
'message_body': 'your message body',
}
)
print(response.json())
{
"contact": {
"status": "existing",
"phone_number": "918856066529",
"uid": "2c3199e8-ba01-4988-b752-a95250cc3ea4",
"first_name": "Johan",
"last_name": "Doe",
"email": "johndoe@doamin.com",
"language_code": "en",
"country": "india"
},
"message": {
"whatsapp_business_phone_number_id": "669217672941135",
"whatsapp_message_id": "wamid.HBgMOTE4ODU2MDY2NTI5FQIAERgSREE4MzBCNjRBQjY5NkNCQzVCAA==",
"is_new_message": true,
"body": "your message body",
"status": "sent"
}
}