Envia Mensaje por Llamada
URL:https://www.onurix.com/api/v1/call/send
Genera una llamada con cada numero de telefono proporcionado, al cual se le entragara un mensaje generador de acuerdo a los parametros especificados.
Parameters.
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
| client | integer(int64) | true | El Id del cliente |
| key | string | true | Key de la cuenta onurix |
| phone | string | true | Numero de telefono . Ej “573150123456” |
| voice | string | false | Voz a usar en la llamada, puede escoger entre Mariana, Penelope, Conchita, Mia, Lucia, Enrique, Miguel. Este parámetro es requerido si no se usa el parámetro audio-code |
| message | string | false | Mensaje para reproducir al iniciar la llamar. Este parámetro es requerido si no se usa el parámetro audio-code |
| retries | string | false | Numero de intentos de la llamada, maximo 3 |
| leave-voicemail | boolean | false | Valor por defecto "true". Use "false" para no dejar mensaje en buzón de voz en caso de que la llamada no sea atendida |
| audio-code | string | false | Id único que hace referencia a un audio cargado a través de la plataforma de Onurix, si envía este parámetro se usara el correspondiente audio en las llamadas generadas. No se permite el uso de este parámetro junto con el parámetro voice y message |
| groups | string | false | ID de grupos seperados por comas. Ej "1,2,3" |
Responses.
| Estado | Significado | Descripción | Esquema |
|---|---|---|---|
| 200 | OK | Operación exitosa | JsonResponse |
| 400 | Client Error | Parametros invalidos | JsonResponse |
| 520 | Unknown | Error interno del sistema | ErrorResponse |
Code request
# También puede usar wget
curl -X POST "https://www.onurix.com/api/v1/call/send" -d key="AQUI_SU_KEY" -d client="AQUI_SU_CLIENT" -d phone="AQUI_EL_NUMERO_DE_CELULAR" -d message="AQUI_EL_MENSAJE_A_ENVIAR" -d voice="AQUI_TIPO_DE_VOZ" -d retries="AQUI_NUMERO_DE_INTENTOS" -d group="AQUI_ID_DE_GRUPO" -d leave-voicemail="AQUI_CONFIRMACION_BUZON_DE_VOZ" -d audio-code="AQUI_ID_AUDIO" -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: application/json'
Code request
<?php
// Ejecutar: composer require guzzlehttp/guzzle:*
require'vendor/autoload.php';
$headers=array(
'Content-Type'=>'application/x-www-form-urlencoded',
'Accept'=>'application/json',
);
$client= new \GuzzleHttp\Client();
// Define la matriz del cuerpo de la solicitud.
$request_body = array(
"client"=>"AQUI_SU_CLIENT",
"key"=>"AQUI_SU_KEY",
"phone"=>"AQUI_EL_NUMERO_DE_CELULAR",
"message"=>"AQUI_EL_MENSAJE_A_ENVIAR",
"voice"=>"AQUI_TIPO_DE_VOZ",
"retries"=>"AQUI_NUMERO_DE_INTENTOS",
"leave-voicemail"=>"false",
"audio-code"=>"AQUI_ID_AUDIO",
);
try{
$response=$client->request('POST','https://www.onurix.com/api/v1/call/send',array(
'headers'=>$headers,
'form_params'=>$request_body,
)
);
print_r($response->getBody()->getContents());
}
catch(\GuzzleHttp\Exception\BadResponseException $e){
// Manejar excepciones o errores de API
print_r($e->getMessage());
}
Code request
import requests
headers ={
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
}
data = {
'client':'AQUI_SU_CLIENT',
'key':'AQUI_SU_KEY',
'phone':'AQUI_EL_NUMERO_DE_CELULAR',#PARA ENVIAR MULTIPLES TELEFONOS TENDRAN QUE SER SEPARADOS POOR COMAS ","
'message':'AQUI_EL_MENSAJE_A_ENVIAR',#EN CASO DE ENVIAR PARAMETRO AUDIO-CODE NO PASAR PARAMETROS MESSAGE Y VOICE
'voice':'AQUI_TIPO_DE_VOZ',
'retries':'AQUI_NUMERO_DE_INTENTOS',#OPCIONAL POR DEFECTO 1
'leave-voicemail':'false',
#'audio-code':'AQUI_ID_AUDIO',
'groups': 'AQUI_ID_GRUPOS'#PARA ENVIAR MULTIPLES TELEFONOS TENDRAN QUE SER SEPARADOS POOR COMAS ","
}
r = requests.post('https://www.onurix.com/api/v1/call/send', headers = headers, data = data)
print(r.json())
Code request
//Este codigo fue hecho en .net 6
using System.Net.Http;
namespace PruebaOnurix
{
public class Program
{
public static void Main(string[] args)
{
Dictionary<string, string> parameters = new()
{
{ "client", "AQUI_SU_CLIENT"},
{ "key", "AQUI_SU_KEY"},
{ "phone", "AQUI_EL_NUMERO_DE_CELULAR"},
{ "message", "AQUI_EL_MENSAJE_A_ENVIAR"},
{ "voice", "AQUI_TIPO_DE_VOZ" },
{ "retries", "AQUI_NUMERO_DE_INTENTOS"},
{ "leave-voicemail","AQUI_CONFIRMACION_BUZON_DE_VOZ"},
//{ "audio-code","AQUI_ID_AUDIO"},
{ "groups","AQUI_ID_GRUPO"}
};
SendCall(parameters);
}
public static void SendCall(Dictionary<string,string> parameters)
{
using var httpClient = new HttpClient()
{
BaseAddress = new Uri("https://www.onurix.com"),
};
HttpResponseMessage request = httpClient.PostAsync("api/v1/call/send", new FormUrlEncodedContent(parameters)).Result;
string responseString = request.Content.ReadAsStringAsync().Result;
Console.WriteLine(responseString);
}
}
}
Code request
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/x-www-form-urlencoded"},
"Accept": []string{"application/json"},
}
data := strings.NewReader("client=AQUI_SU_CLIENT&key=AQUI_SU_KEY&phone=AQUI_EL_NUMERO_DE_CELULAR&message=AQUI_EL_MENSAJE_A_ENVIAR&voice=AQUI_TIPO_DE_VOZ&retries=AQUI_NUMERO_DE_INTENTOS&leave-voicemail=false&audio-code=AQUI_AUDIO_CODE&groups=AQUI_ID_GRUPO")
req, err := http.NewRequest("POST", "https://www.onurix.com/api/v1/call/send", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Code request
// Ejecutar: npm install axios --save
const axios = require('axios').default;
let headers={
headers:{
'content-type': 'application/x-www-form-urlencoded',
}
}
let data ={
'client':'AQUI_SU_CLIENT',
'key':'AQUI_SU_KEY',
'phone':'AQUI_EL_NUMERO_DE_CELULAR',//PARA ENVIAR MULTIPLES TELEFONOS TENDRAN QUE SER SEPARADOS POOR COMAS ","
'message':'AQUI_EL_MENSAJE_A_ENVIAR',//EN CASO DE ENVIAR PARAMETRO AUDIO-CODE NO PASAR PARAMETROS MESSAGE Y VOICE
'voice':'AQUI_TIPO_DE_VOZ',
'retries':'AQUI_NUMERO_DE_INTENTOS',//OPCIONAL POR DEFECTO 1
'leave-voicemail':'false',
//'audio-code':'AQUI_ID_AUDIO',
'groups': 'AQUI_ID_GRUPOS'//PARA ENVIAR MULTIPLES TELEFONOS TENDRAN QUE SER SEPARADOS POOR COMAS ","
}
axios.post('https://www.onurix.com/api/v1/call/send',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.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class SendCall {
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
Map<String,String> parameters = new HashMap<>();
parameters.put("client", "AQUI_SU_CLIENT");
parameters.put("key", "AQUI_SU_KEY");
parameters.put("phone", "AQUI_EL_NUMERO_DE_CELULAR");//PARA ENVIAR MULTIPLES TELEFONOS TENDRAN QUE SER SEPARADOS POR COMAS ","
parameters.put("message", "AQUI_EL_MENSAJE_A_ENVIAR");//EN CASO DE ENVIAR PARAMETRO AUDIO-CODE NO PASAR PARAMETROS MESSAGE Y VOICE
parameters.put("voice", "AQUI_TIPO_DE_VOZ");
parameters.put("retries", "AQUI_NUMERO_DE_INTENTOS");
parameters.put("leave-voicemail", "false");
//parameters.put("audio-code", "AQUI_ID_AUDIO");
parameters.put("groups","AQUI_ID_GRUPOS");
var httpClient = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.version(HttpClient.Version.HTTP_2)
.POST(ofFormData(parameters))
.uri(URI.create("https://www.onurix.com/api/v1/call/send"))
.header("Content-Type", "application/x-www-form-urlencoded")
.build();
var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
//System.out.println(response.body());
}
public static HttpRequest.BodyPublisher ofFormData(Map<String, String> parameters) {
var builder = new StringBuilder();
for (Entry<String, String> entry : parameters.entrySet()) {
if (builder.length() > 0) {
builder.append("&");
}
builder.append(URLEncoder.encode(entry.getKey().toString(), StandardCharsets.UTF_8));
builder.append("=");
builder.append(URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8));
}
return HttpRequest.BodyPublishers.ofString(builder.toString());
}
}
Body parameters
client: 0,
key: "string",
phone: "string",
message: "string",
voice: "string",
retries: "string",
leave-voicemail: true,
audio-code: "string",
groups: "string"
Respuesta de ejemplo
Response 200
{
"status": "string",
"id": "string",
"data": [
{
"id": "string",
"state": "string",
"credits": 0,
"message": "string",
"phone": "string",
"voice": "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