Enviar um arquivo
curl --request POST \
--url https://{host}/api/sendFile \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"session": "session",
"chatId": "5511999999999@c.us",
"url": "https://example.com/file.pdf",
"filename": "document.pdf"
}
'import requests
url = "https://{host}/api/sendFile"
payload = {
"session": "session",
"chatId": "5511999999999@c.us",
"url": "https://example.com/file.pdf",
"filename": "document.pdf"
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
session: 'session',
chatId: '5511999999999@c.us',
url: 'https://example.com/file.pdf',
filename: 'document.pdf'
})
};
fetch('https://{host}/api/sendFile', 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://{host}/api/sendFile",
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([
'session' => 'session',
'chatId' => '5511999999999@c.us',
'url' => 'https://example.com/file.pdf',
'filename' => 'document.pdf'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <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://{host}/api/sendFile"
payload := strings.NewReader("{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<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://{host}/api/sendFile")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/sendFile")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"messageId": "3EB0XXXXXX"
}
Mensagens
Enviar Arquivo
Enviar arquivo (documento) para um contato ou grupo
POST
/
api
/
sendFile
Enviar um arquivo
curl --request POST \
--url https://{host}/api/sendFile \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"session": "session",
"chatId": "5511999999999@c.us",
"url": "https://example.com/file.pdf",
"filename": "document.pdf"
}
'import requests
url = "https://{host}/api/sendFile"
payload = {
"session": "session",
"chatId": "5511999999999@c.us",
"url": "https://example.com/file.pdf",
"filename": "document.pdf"
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
session: 'session',
chatId: '5511999999999@c.us',
url: 'https://example.com/file.pdf',
filename: 'document.pdf'
})
};
fetch('https://{host}/api/sendFile', 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://{host}/api/sendFile",
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([
'session' => 'session',
'chatId' => '5511999999999@c.us',
'url' => 'https://example.com/file.pdf',
'filename' => 'document.pdf'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <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://{host}/api/sendFile"
payload := strings.NewReader("{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<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://{host}/api/sendFile")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/sendFile")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session\": \"session\",\n \"chatId\": \"5511999999999@c.us\",\n \"url\": \"https://example.com/file.pdf\",\n \"filename\": \"document.pdf\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"messageId": "3EB0XXXXXX"
}
Descrição
Este endpoint permite enviar arquivos de qualquer tipo (documentos, PDFs, planilhas, etc.) para contatos individuais ou grupos no WhatsApp. O arquivo deve ser enviado em formato base64 com mimetype e nome do arquivo especificados.Body
{
"sessionId": "my-session",
"jid": "5511999999999@s.whatsapp.net",
"file": {
"content": "iVBORw0KGgoAAAANSUhEUgAAAA...",
"mimetype": "image/png",
"filename": "Meu Grupo"
}
}
Parâmetros do Body
| Propriedade | Tipo | Obrigatório | Descrição |
|---|---|---|---|
sessionId | string | ✅ Sim | ID da sessão autenticada que enviará o arquivo |
jid | string | ✅ Sim | Identificador do destinatário (JID do WhatsApp). Formato: 5511999999999@s.whatsapp.net para contatos ou 120363XXXXX@g.us para grupos |
file | object | ✅ Sim | Objeto contendo as informações do arquivo |
file.content | string | ✅ Sim | Conteúdo do arquivo codificado em base64 |
file.mimetype | string | ✅ Sim | Tipo MIME do arquivo (exemplo: application/pdf, application/vnd.ms-excel, application/zip) |
file.filename | string | ✅ Sim | Nome do arquivo com extensão (exemplo: documento.pdf, planilha.xlsx) |
{
"success": true,
"messageId": "3EB0XXXXXX"
}
Códigos de Status
200- Arquivo enviado com sucesso400- Parâmetros inválidos401- Sessão não autorizada404- Sessão não encontrada
Exemplo de Uso
curl -X POST https://api.wappfy.com.br/api/sendFile \
-H "Content-Type: application/json" \
-d '{
"sessionId": "my-session",
"jid": "5511999999999@s.whatsapp.net",
"file": {
"content": "JVBERi0xLjQKJeLjz9MKMy...",
"mimetype": "application/pdf",
"filename": "relatorio.pdf"
}
}'
const response = await fetch('https://api.wappfy.com.br/api/sendFile', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
sessionId: 'my-session',
jid: '5511999999999@s.whatsapp.net',
file: {
content: 'JVBERi0xLjQKJeLjz9MKMy...', // base64
mimetype: 'application/pdf',
filename: 'relatorio.pdf'
}
})
});
const data = await response.json();
console.log(data);
import requests
import base64
# Ler arquivo e converter para base64
with open('relatorio.pdf', 'rb') as f:
file_content = base64.b64encode(f.read()).decode('utf-8')
response = requests.post(
'https://api.wappfy.com.br/api/sendFile',
json={
'sessionId': 'my-session',
'jid': '5511999999999@s.whatsapp.net',
'file': {
'content': file_content,
'mimetype': 'application/pdf',
'filename': 'relatorio.pdf'
}
}
)
data = response.json()
print(data)
Authorizations
Sua chave de API do Wappfy (obtenha em dash.wappfy.com.br)
Body
application/json
Identificador do chat (JID do WhatsApp)
Example:
"5511999999999@c.us"
Arquivo (URL remota ou dados base64)
- Option 1
- Option 2
Show child attributes
Show child attributes
Nome da sessão (instanceName)
Example:
"my-session"
ID da mensagem à qual você deseja responder
Example:
null
Legenda/texto que acompanha o arquivo
Response
201 - application/json
The response is of type object.
⌘I
