Enviar SMS
curl --request POST \
--url https://app.mayahub.ai/api/user/sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": 123,
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://app.mayahub.ai/api/user/sms"
payload = {
"from": 123,
"to": "<string>",
"body": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({from: 123, to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://app.mayahub.ai/api/user/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.mayahub.ai/api/user/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => 123,
'to' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.mayahub.ai/api/user/sms"
payload := strings.NewReader("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.mayahub.ai/api/user/sms")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.mayahub.ai/api/user/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "SMS sent successfully",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Hello! This is a test message from Your Company. How can we help you today?",
"user_id": 1,
"segments": 1,
"segment_price": 0.0075,
"total_cost": 0.0075,
"status": "sent",
"sms_sid": "SM1234567890abcdef1234567890abcdef",
"created_at": "2025-08-04 15:30:00",
"updated_at": "2025-08-04 15:30:02"
}
}
{
"message": "From number not found"
}
{
"message": "Invalid to phone number"
}
{
"message": "Insufficient balance"
}
{
"message": "From number is not SMS capable"
}
{
"message": "Failed to send SMS",
"error": "Twilio API error details"
}
SMS
Enviar SMS
Enviar uma mensagem SMS usando seu número de telefone
POST
/
user
/
sms
Enviar SMS
curl --request POST \
--url https://app.mayahub.ai/api/user/sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": 123,
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://app.mayahub.ai/api/user/sms"
payload = {
"from": 123,
"to": "<string>",
"body": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({from: 123, to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://app.mayahub.ai/api/user/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.mayahub.ai/api/user/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => 123,
'to' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.mayahub.ai/api/user/sms"
payload := strings.NewReader("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.mayahub.ai/api/user/sms")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.mayahub.ai/api/user/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "SMS sent successfully",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Hello! This is a test message from Your Company. How can we help you today?",
"user_id": 1,
"segments": 1,
"segment_price": 0.0075,
"total_cost": 0.0075,
"status": "sent",
"sms_sid": "SM1234567890abcdef1234567890abcdef",
"created_at": "2025-08-04 15:30:00",
"updated_at": "2025-08-04 15:30:02"
}
}
{
"message": "From number not found"
}
{
"message": "Invalid to phone number"
}
{
"message": "Insufficient balance"
}
{
"message": "From number is not SMS capable"
}
{
"message": "Failed to send SMS",
"error": "Twilio API error details"
}
Este endpoint permite enviar mensagens SMS usando os números de telefone adquiridos.
O SMS será enviado por meio do Twilio e os custos serão automaticamente deduzidos do saldo da sua conta.
O SMS será enviado por meio do Twilio e os custos serão automaticamente deduzidos do saldo da sua conta.
Corpo da solicitação
integer
required
O ID do seu número de telefone a partir do qual o SMS será enviado (deve ter capacidade para SMS)
string
required
O número de telefone do destinatário no formato internacional (exemplo: +1234567890)
string
required
O conteúdo da mensagem SMS (máximo de 300 caracteres)
Respostas
string
Mensagem de sucesso confirmando que o SMS foi enviado
object
Show Propriedades
Show Propriedades
integer
O identificador exclusivo do registro do SMS
integer
O ID do número de telefone usado para enviar o SMS
string
O número de telefone do destinatário no formato E.164
string
O conteúdo da mensagem SMS
integer
O ID do usuário que enviou o SMS
integer
Número de segmentos de SMS (para fins de cobrança)
number
Custo por segmento de SMS
number
Custo total do SMS (segment_price * segments)
string
O status atual do SMS
string
SID do SMS do Twilio para rastreamento
string
A data e hora em que o SMS foi criado
string
A data e hora da última atualização do SMS
Respostas de Erro
Show Respostas de Erro
Show Respostas de Erro
string
Mensagem de erro descrevendo o problema (número de telefone inválido, saldo insuficiente, etc.)
{
"message": "SMS sent successfully",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Hello! This is a test message from Your Company. How can we help you today?",
"user_id": 1,
"segments": 1,
"segment_price": 0.0075,
"total_cost": 0.0075,
"status": "sent",
"sms_sid": "SM1234567890abcdef1234567890abcdef",
"created_at": "2025-08-04 15:30:00",
"updated_at": "2025-08-04 15:30:02"
}
}
{
"message": "From number not found"
}
{
"message": "Invalid to phone number"
}
{
"message": "Insufficient balance"
}
{
"message": "From number is not SMS capable"
}
{
"message": "Failed to send SMS",
"error": "Twilio API error details"
}
Observações
- O número de telefone do remetente deve pertencer ao usuário autenticado.
- O número de telefone do remetente deve ter capacidade para SMS.
- A assinatura do número de telefone deve estar ativa (não expirada).
- É necessário saldo suficiente na conta para cobrir os custos de SMS.
- Os números de telefone são automaticamente formatados para o formato E.164.
- Os custos de SMS variam de acordo com o país de destino e são cobrados por segmento.
- Mensagens longas podem ser divididas em vários segmentos, aumentando o custo.
- O número de telefone do destinatário deve ser válido de acordo com os padrões internacionais.
⌘I

