Criar um novo canal
curl --request POST \
--url https://{host}/api/{session}/channels \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "Channel Name",
"description": "Channel Description",
"picture": {
"mimetype": "image/jpeg",
"url": "https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg",
"filename": "filename.jpg"
}
}
'import requests
url = "https://{host}/api/{session}/channels"
payload = {
"name": "Channel Name",
"description": "Channel Description",
"picture": {
"mimetype": "image/jpeg",
"url": "https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg",
"filename": "filename.jpg"
}
}
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({
name: 'Channel Name',
description: 'Channel Description',
picture: {
mimetype: 'image/jpeg',
url: 'https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg',
filename: 'filename.jpg'
}
})
};
fetch('https://{host}/api/{session}/channels', 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/{session}/channels",
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([
'name' => 'Channel Name',
'description' => 'Channel Description',
'picture' => [
'mimetype' => 'image/jpeg',
'url' => 'https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg',
'filename' => 'filename.jpg'
]
]),
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/{session}/channels"
payload := strings.NewReader("{\n \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\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/{session}/channels")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/channels")
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 \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "Meu Canal",
"description": "Canal de notícias e atualizações",
"picture": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
{
"success": true,
"channel": {
"id": "123456789@newsletter",
"name": "Meu Canal",
"description": "Canal de notícias e atualizações"
}
}
Canais
Criar Novo Canal
Criar um novo canal (newsletter) no WhatsApp
POST
/
api
/
{session}
/
channels
Criar um novo canal
curl --request POST \
--url https://{host}/api/{session}/channels \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "Channel Name",
"description": "Channel Description",
"picture": {
"mimetype": "image/jpeg",
"url": "https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg",
"filename": "filename.jpg"
}
}
'import requests
url = "https://{host}/api/{session}/channels"
payload = {
"name": "Channel Name",
"description": "Channel Description",
"picture": {
"mimetype": "image/jpeg",
"url": "https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg",
"filename": "filename.jpg"
}
}
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({
name: 'Channel Name',
description: 'Channel Description',
picture: {
mimetype: 'image/jpeg',
url: 'https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg',
filename: 'filename.jpg'
}
})
};
fetch('https://{host}/api/{session}/channels', 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/{session}/channels",
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([
'name' => 'Channel Name',
'description' => 'Channel Description',
'picture' => [
'mimetype' => 'image/jpeg',
'url' => 'https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg',
'filename' => 'filename.jpg'
]
]),
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/{session}/channels"
payload := strings.NewReader("{\n \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\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/{session}/channels")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/channels")
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 \"name\": \"Channel Name\",\n \"description\": \"Channel Description\",\n \"picture\": {\n \"mimetype\": \"image/jpeg\",\n \"url\": \"https://github.com/stgcompany/wappfy/raw/core/examples/wappfy.jpg\",\n \"filename\": \"filename.jpg\"\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "Meu Canal",
"description": "Canal de notícias e atualizações",
"picture": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
{
"success": true,
"channel": {
"id": "123456789@newsletter",
"name": "Meu Canal",
"description": "Canal de notícias e atualizações"
}
}
Descrição
Este endpoint permite criar um novo canal no WhatsApp. Canais são recursos que permitem transmitir mensagens para um grande número de seguidores de forma unidirecional.Parâmetros de URL
Corpo da Requisição
Resposta
{
"name": "Meu Canal",
"description": "Canal de notícias e atualizações",
"picture": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
{
"success": true,
"channel": {
"id": "123456789@newsletter",
"name": "Meu Canal",
"description": "Canal de notícias e atualizações"
}
}
Códigos de Status
200- Canal criado com sucesso400- Parâmetros inválidos ou faltando401- Não autorizado500- Erro interno do servidor
Exemplo de Uso
curl -X POST https://api.wappfy.com.br/api/my-session/channels \
-H "Content-Type: application/json" \
-d '{
"name": "Meu Canal",
"description": "Canal de notícias e atualizações",
"picture": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}'
const session = 'my-session';
const response = await fetch(`https://api.wappfy.com.br/api/${session}/channels`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Meu Canal',
description: 'Canal de notícias e atualizações',
picture: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='
})
});
const data = await response.json();
console.log(data);
import requests
session = 'my-session'
response = requests.post(
f'https://api.wappfy.com.br/api/{session}/channels',
json={
'name': 'Meu Canal',
'description': 'Canal de notícias e atualizações',
'picture': 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='
}
)
data = response.json()
print(data)
Body
application/json
Response
201 - application/json
