Enviar Mensaje de WhatsApp sin Plantilla
URL:https://www.onurix.com/api/v1/whatsapp/send/no-template
Con este método puedes enviar mensajes de texto con contenido libre a través de WhatsApp. A diferencia de otros métodos, no necesitas utilizar una plantilla preaprobada por Meta, lo que te brinda la flexibilidad de enviar el contenido que desees, siempre que cumplas con las políticas de la plataforma.
CONSIDERACIONES:
- Para poder hacer uso de este servicio, es necesario que el usuario haya iniciado una conversación previamente con la línea de WhatsApp.
- Antes de enviar un mensaje, asegúrese de que el negocio y el número telefónico estén en estado saludable. Si alguno presenta advertencias o bloqueos, el mensaje será rechazado por Meta.
- Si desea recibir las respuestas de los usuarios o eventos como entregas y errores, debe configurar un webhook desde el panel de control en onurix.com.
Parámetros.
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
| client | integer(int64) | true | El Id del cliente. (Query parameter) |
| key | string | true | Key de la cuenta onurix. (Query parameter) |
| phone-sender-id | string | true | Id del número de teléfono remitente. |
| message | json | true | Objeto con el mensaje a enviar. |
Respuesta.
| Estado | Significado | Descripción | Esquema |
|---|---|---|---|
| 200 | OK | Operación exitosa | JsonResponse |
| 400 | Client Error | Parámetros inválidos | JsonResponse |
| 520 | Unknown | Error interno del sistema | ErrorResponse |
Code request
curl --location --globoff 'https://www.onurix.com/api/v1/whatsapp/send/no-template?key=AQUI_SU_SECRET_KEY&client=AQUI_SU_CLIENT_ID&phone-sender-id=AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE' --header 'Content-Type: application/json' --data '{"from_phone_meta_id":"AQUI_EL_META_ID_DEL_TELEFONO","phone":"AQUI_EL_TELEFONO_DESTINO","message":{"type":"text","value":"AQUI_EL_MENSAJE"}}'
Code request
<?php
// Ejecutar: composer require guzzlehttp/guzzle:*
require 'vendor/autoload.php';
$clientId = "AQUI_SU_CLIENT_ID";
$key = "AQUI_SU_SECRET_KEY";
$phoneSenderId = "AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE";
$from_phone_meta_id = "AQUI_EL_META_ID_DEL_TELEFONO";
$phone = "AQUI_EL_TELEFONO_DESTINO";
$message = "AQUI_EL_MENSAJE";
$client = new \GuzzleHttp\Client();
$body = [
"from_phone_meta_id" => $from_phone_meta_id,
"phone" => $phone,
"message" => [
"type" => "text",
"value" => $message
]
];
$response = $client->post("https://www.onurix.com/api/v1/whatsapp/send/no-template?key=$key&client=$clientId&phone-sender-id=$phoneSenderId", [
'headers' => ['Content-Type' => 'application/json'],
'body' => json_encode($body)
]);
echo $response->getBody()->getContents();
Code request
import requests
import json
url = "https://www.onurix.com/api/v1/whatsapp/send/no-template?key=AQUI_SU_KEY&client=AQUI_SU_CLIENT_ID&phone-sender-id=AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE"
payload = {
"from_phone_meta_id": "AQUI_ID_META_PHONE",
"phone": "AQUI_EL_NUMERO_DE_CELULAR",
"message": {
"type" : "text",
"value": "AQUI_EL_MENSAJE"
}
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.json())
Code request
//Este codigo fue hecho en .net 6
using System.Text;
using System.Net.Http;
namespace PruebaOnurix
{
public class Program
{
public static void Main(string[] args)
{
WhatsAppSendWithoutTemplate();
}
public static void WhatsAppSendWithoutTemplate()
{
string key = "AQUI_SU_SECRET_KEY";
string client = "AQUI_SU_CLIENT_ID";
string phoneSenderId = "AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE";
string jsonBody = @"{
""from_phone_meta_id"": ""AQUI_EL_META_ID_DEL_TELEFONO"",
""phone"": ""AQUI_EL_TELEFONO_DESTINO"",
""message"": {
""type"" : ""text"",
""value"": ""AQUI_EL_MENSAJE""
}
}";
using var httpClient = new HttpClient()
{
BaseAddress = new Uri("https://www.onurix.com/"),
};
HttpResponseMessage request = httpClient.PostAsync($"api/v1/whatsapp/send/no-template?client={client}&key={key}&phone-sender-id={phoneSenderId}", new StringContent(jsonBody, Encoding.UTF8, "application/json")).Result;
string responseString = request.Content.ReadAsStringAsync().Result;
Console.WriteLine(responseString);
}
}
}
Code request
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://www.onurix.com/api/v1/whatsapp/send/no-template?key=AQUI_SU_SECRET_KEY&client=AQUI_SU_CLIENT_ID&phone-sender-id=AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE"
method := "POST"
payload := strings.NewReader(`{
"from_phone_meta_id": "AQUI_EL_META_ID_DEL_TELEFONO",
"phone": "AQUI_EL_TELEFONO_DESTINO",
"message": {
"type" : "text",
"value": "AQUI_EL_MENSAJE"
}
}`)
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Code request
// Run: npm install axios --save
const axios = require('axios').default;
const url = 'https://www.onurix.com/api/v1/whatsapp/send_without_template?key=AQUI_SU_SECRET_KEY&client=AQUI_SU_CLIENT_ID&phone-sender-id=AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE';
const data = {
"from_phone_meta_id": "AQUI_EL_META_ID_DEL_TELEFONO",
"phone": "AQUI_EL_TELEFONO_DESTINO",
"message": {
"type" : "text",
"value": "AQUI_EL_MENSAJE"
}
};
const headers = {
'Content-Type': 'application/json'
};
axios.post(url, data, { headers })
.then(resp => {
console.log(resp.data);
})
.catch(error => {
console.log(error);
});
Code request
//Para este codigo se uso jdk 11
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class SendWhatsAppWithoutTemplate {
public static void main(String[] args) {
String apiUrl = "https://www.onurix.com/api/v1/whatsapp/send/no-template";
String apiKey = "AQUI_SU_SECRET_KEY"; // Replace with your actual API key
String client = "AQUI_SU_CLIENT_ID"; // Replace with your actual client ID
String phoneSenderId = "AQUI_EL_ID_DEL_NUMERO_DE_TELEFONO_REMITENTE"; // Replace with your phone sender meta ID
try {
// Construct the URL with query parameters
String fullUrl = apiUrl + "?key=" + apiKey + "&client=" + client + "&phone-sender-id=" + phoneSenderId;
URL url = new URL(fullUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// Set the request method to POST
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
// ✅ JSON payload usando text block (Java 15+)
String jsonInputString = """
{
"from_phone_meta_id": "AQUI_EL_META_ID_DEL_TELEFONO",
"phone": "AQUI_EL_TELEFONO_DESTINO",
"message": {
"type": "text",
"value": "AQUI_EL_MENSAJE"
}
}
""";
// Write the JSON data to the request body
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// Get the response code
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
// Read the response
try (BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
response.append(line.trim());
}
System.out.println("Response Body: " + response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Url parameters
client : 0,
key : "string"
Body parameters example
{
"phone": "3201234567",
"message": {
"type": "text",
"value": "Esto es un mensaje sin plantilla"
}
}
Respuesta de ejemplo
Response 200
{
"id": "string",
"status": "string",
"data": {
"meta_message_id": "string",
"state": "string"
}
}
Response 400 o 520
{
"error": 1000,
"msg": "string"
}
Si requiere asistencia o tiene un problema, envienos un mensaje para poder ayudarlo
soporte@onurix.com