API
Enviar WhatsApp
POST
/
api
/
v1
/
message
/
whatsapp
Enviar WhatsApp
curl --request POST \
--url https://api.valid.com/api/v1/message/whatsapp \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://api.valid.com/api/v1/message/whatsapp"
payload = {
"to": "<string>",
"body": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://api.valid.com/api/v1/message/whatsapp', 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.valid.com/api/v1/message/whatsapp",
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([
'to' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.valid.com/api/v1/message/whatsapp"
payload := strings.NewReader("{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.valid.com/api/v1/message/whatsapp")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.valid.com/api/v1/message/whatsapp")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyA rota
Exemplo de sucesso (
POST /api/v1/message/whatsapp viabiliza o envio assíncrono e não-bloqueante de mensagens instantâneas diretamente para o canal do WhatsApp do destinatário. A requisição aceita o processamento e retorna imediatamente um código de rastreamento do envio.
Request Body
Número de telefone do destinatário configurado no formato internacional (contendo o símbolo
+, código do país, DDD e número do celular).Exemplo: +5511999999999Conteúdo em texto da mensagem de WhatsApp que será encaminhada ao cliente final.Exemplo:
Olá! Esta é uma mensagem de teste via WhatsApp.Response
Retorna síncronamente a confirmação de que a solicitação de processamento de WhatsApp foi aceita para envio.Exemplo de sucesso (202 Accepted)
{
"id": "12c54b67-e89d-4a12-b345-678901234567",
"status": "SENT"
}
⌘I
Enviar WhatsApp
curl --request POST \
--url https://api.valid.com/api/v1/message/whatsapp \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"to": "<string>",
"body": "<string>"
}
'import requests
url = "https://api.valid.com/api/v1/message/whatsapp"
payload = {
"to": "<string>",
"body": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({to: '<string>', body: JSON.stringify('<string>')})
};
fetch('https://api.valid.com/api/v1/message/whatsapp', 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.valid.com/api/v1/message/whatsapp",
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([
'to' => '<string>',
'body' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.valid.com/api/v1/message/whatsapp"
payload := strings.NewReader("{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.valid.com/api/v1/message/whatsapp")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.valid.com/api/v1/message/whatsapp")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"<string>\",\n \"body\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body