Upload de Mídia
curl --request POST \
--url https://apis.vectalk.com.br/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "<string>",
"messaging_product": "<string>"
}
'import requests
url = "https://apis.vectalk.com.br/media"
payload = {
"type": "<string>",
"messaging_product": "<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({type: '<string>', messaging_product: '<string>'})
};
fetch('https://apis.vectalk.com.br/media', 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://apis.vectalk.com.br/media",
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([
'type' => '<string>',
'messaging_product' => '<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://apis.vectalk.com.br/media"
payload := strings.NewReader("{\n \"type\": \"<string>\",\n \"messaging_product\": \"<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://apis.vectalk.com.br/media")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"<string>\",\n \"messaging_product\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apis.vectalk.com.br/media")
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 \"type\": \"<string>\",\n \"messaging_product\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyMídia
Upload de Mídia
Envie um arquivo e obtenha um media_id para usar em mensagens
POST
/
media
Upload de Mídia
curl --request POST \
--url https://apis.vectalk.com.br/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "<string>",
"messaging_product": "<string>"
}
'import requests
url = "https://apis.vectalk.com.br/media"
payload = {
"type": "<string>",
"messaging_product": "<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({type: '<string>', messaging_product: '<string>'})
};
fetch('https://apis.vectalk.com.br/media', 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://apis.vectalk.com.br/media",
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([
'type' => '<string>',
'messaging_product' => '<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://apis.vectalk.com.br/media"
payload := strings.NewReader("{\n \"type\": \"<string>\",\n \"messaging_product\": \"<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://apis.vectalk.com.br/media")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"<string>\",\n \"messaging_product\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apis.vectalk.com.br/media")
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 \"type\": \"<string>\",\n \"messaging_product\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyRequer token de instância.
id retornado no campo id (em vez de link) ao enviar mensagens de imagem, documento, áudio ou vídeo.
Limites por tipo
| Tipo | MIME types | Tamanho máximo |
|---|---|---|
| Imagem | image/jpeg, image/png, image/webp | 5 MB |
| Áudio | audio/aac, audio/mp4, audio/mpeg, audio/ogg | 16 MB |
| Vídeo | video/mp4, video/3gp | 16 MB |
| Documento | application/pdf, text/plain, Office | 100 MB |
| Sticker | image/webp (animado ou estático) | 100 KB |
Parâmetros
Body (multipart/form-data)
file
required
Arquivo a ser enviado.
string
required
MIME type do arquivo. Ex:
image/jpeg.string
required
Sempre
"whatsapp".Exemplo
curl -X POST https://apis.vectalk.com.br/api/media \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@/caminho/para/imagem.jpg" \
-F "type=image/jpeg" \
-F "messaging_product=whatsapp"
Resposta
{
"id": "1234567890"
}
id em uma mensagem de imagem:
{
"messaging_product": "whatsapp",
"to": "5511999999999",
"type": "image",
"image": {
"id": "1234567890",
"caption": "Confira!"
}
}
⌘I