Enviar SMS
curl --request POST \
--url https://api.example.com/user/sms \
--header 'Content-Type: application/json' \
--data '
{
"from": 123,
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://api.example.com/user/sms"
payload = {
"from": 123,
"to": "<string>",
"body": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({from: 123, to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://api.example.com/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://api.example.com/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 => [
"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://api.example.com/user/sms"
payload := strings.NewReader("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/user/sms")
.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://api.example.com/user/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
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 enviado com sucesso",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Olá! Esta é uma mensagem de teste da OmniTech. Como podemos te ajudar hoje?",
"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": "Número de origem não encontrado"
}
{
"message": "Número de destino inválido"
}
{
"message": "Saldo insuficiente"
}
{
"message": "Número de origem não possui capacidade de SMS"
}
{
"message": "Falha ao enviar SMS",
"error": "Detalhes do erro da API da Twilio"
}
SMS
Enviar SMS
Envia uma mensagem SMS via API usando um número de telefone da sua conta OmniTech com suporte a SMS, ideal para confirmações e follow-ups.
POST
/
user
/
sms
Enviar SMS
curl --request POST \
--url https://api.example.com/user/sms \
--header 'Content-Type: application/json' \
--data '
{
"from": 123,
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://api.example.com/user/sms"
payload = {
"from": 123,
"to": "<string>",
"body": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({from: 123, to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://api.example.com/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://api.example.com/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 => [
"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://api.example.com/user/sms"
payload := strings.NewReader("{\n \"from\": 123,\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/user/sms")
.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://api.example.com/user/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
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 enviado com sucesso",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Olá! Esta é uma mensagem de teste da OmniTech. Como podemos te ajudar hoje?",
"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": "Número de origem não encontrado"
}
{
"message": "Número de destino inválido"
}
{
"message": "Saldo insuficiente"
}
{
"message": "Número de origem não possui capacidade de SMS"
}
{
"message": "Falha ao enviar SMS",
"error": "Detalhes do erro da API da Twilio"
}
Este endpoint permite enviar mensagens SMS utilizando seus números de telefone adquiridos. O SMS será enviado via Twilio e os custos serão automaticamente descontados do saldo da sua conta.
Observações
O número remetente deve pertencer ao usuário autenticado
O número remetente deve ter capacidade de SMS
A assinatura do número 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 padrão E.164
Os custos de SMS variam por país de destino e são cobrados por segmento
Mensagens longas podem ser divididas em múltiplos segmentos, aumentando o custo
O número do destinatário deve ser válido conforme padrões internacionais
Corpo da Requisição
integer
required
ID do seu número de telefone que enviará o SMS (deve ter capacidade de SMS)
string
required
Número do destinatário em formato internacional (ex.: “+1234567890”)
string
required
Conteúdo da mensagem SMS (máx. 300 caracteres)
Resposta
string
Mensagem de sucesso confirmando que o SMS foi enviado
object
Show propriedades
Show propriedades
integer
Identificador único do registro de SMS
integer
ID do número de telefone usado para enviar o SMS
string
Número do destinatário no formato E.164
string
Conteúdo da mensagem SMS
integer
ID do usuário que enviou o SMS
integer
Quantidade de segmentos de SMS (para fins de cobrança)
number
Custo por segmento de SMS
number
Custo total do SMS (segment_price * segments)
string
Status atual do SMS
string
SMS SID da Twilio para rastreamento
string
Data e hora em que o SMS foi criado
string
Data e hora da última atualização do SMS
Respostas de Erro
Show Resposta de Erro
Show Resposta de Erro
string
Mensagem de erro descrevendo o problema (número inválido, saldo insuficiente, etc.)
{
"message": "SMS enviado com sucesso",
"data": {
"id": 456,
"phone_number_id": 78,
"to": "+1234567890",
"body": "Olá! Esta é uma mensagem de teste da OmniTech. Como podemos te ajudar hoje?",
"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": "Número de origem não encontrado"
}
{
"message": "Número de destino inválido"
}
{
"message": "Saldo insuficiente"
}
{
"message": "Número de origem não possui capacidade de SMS"
}
{
"message": "Falha ao enviar SMS",
"error": "Detalhes do erro da API da Twilio"
}
⌘I