Envie Mensagens Automatizadas pelo WhatsApp Usando C NET O Guia Definitivo

25 de agosto de 2025

Hoje, vamos mostrar o guia definitivo para enviar diferentes tipos de mensagens do WhatsApp usando C# (.NET)

A comunicação eficaz é vital para coordenação de projetos, engajamento de comunidade e suporte ao cliente responsivo. Wassenger aprimora esse processo ao fornecer ferramentas de gerenciamento e interação integradas dentro das mensagens do WhatsApp. Com sua API intuitiva e recursos de automação, enviar mensagens, vídeos, imagens, documentos e memos de voz torna-se simples e eficiente.

Neste artigo, você encontrará:

  • Enviar Mensagem de Imagem 🖼️
  • Enviar Mensagens de Vídeo 📹
  • Enviar Mensagens de Documento 📄
  • Enviar Gravação de Áudio 🎙️
  • Enviar uma Mensagem de Mídia com um Arquivo Carregado 📤
  • Enviar uma Mensagem GIF 🎞️
  • Enviar uma Enquete 📊
  • Enviar uma Mensagem Agendada (Data e Hora) 📅
  • Enviar Mensagens com Botões Nativos Dinâmicos 🔘
  • Enviar uma Lista de Itens para Seleção 📝
  • Enviar uma Mensagem com Formatação de Texto ✍️
  • Enviar uma Mensagem de Localização com Coordenadas 📍
  • Enviar uma Mensagem de Localização com Endereço 🗺️
  • Enviar uma Mensagem com Variáveis 🔄
  • Enviar Mensagens com Links 🔗
  • Enviar Cartões de Contato 📇
  • Responder a uma Mensagem 💬
  • Encaminhar uma Mensagem 🔁
  • Enviar uma Mensagem de Catálogo 📒
  • Enviar uma Mensagem em Tempo Real sem Enfileiramento ⏱️
  • Enviar uma Mensagem com Repetições Máximas 🔄
  • Enviar uma Mensagem com Tempo de Expiração ⏳
  • Enviar uma Mensagem Dentro de um Intervalo de Dia e Hora 🕰️
  • Enviar uma Reação a uma Mensagem 😊
  • Remover uma Reação de Mensagem 🚫
  • Enviar uma Mensagem em Nome de um Agente e Atribuir um Chat 👤
  • Enviar uma Mensagem e Marcar o Chat como Resolvido ✅
  • Enviar uma Mensagem e Adicionar um Rótulo ao Chat 🏷️

🤩 🤖 Wassenger é uma plataforma completa de comunicação e solução de API para WhatsApp. Explore mais de 100+ casos de uso da API e automatize qualquer coisa no WhatsApp inscrevendo-se para um teste gratuito e começando em minutos!

Requisitos

  • Ter um número do WhatsApp já vinculado à plataforma e online.
  • Número de telefone do destinatário com prefixo internacional no formato E164. Exemplo: +12345678900. Valide o formato do número de telefone aqui.

Endpoint da API

Usaremos o seguinte endpoint da API para enviar mensagens a um grupo:

Preparar a solicitação

URL alvo da API usando o método POST

https://api.wassenger.com/v1/messages

Cabeçalhos HTTPS obrigatórios > Obtenha sua chave de API aqui

Content-Type: application/json
Token: $API_TOKEN

Use o corpo em formato JSON

{
  "phone": "+1234567890",
  "message": "Hello world, this is a sample message"
}

🖥️ Procurando um exemplo de código? Acesse o testador de API ao vivo e obtenha exemplos de código prontos para uso em mais de 15 linguagens de programação, incluindo JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL e mais.

Enviar mensagens de texto com C# (.NET)

// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "ENTER API KEY HERE");
request.AddParameter("application/json", "{\"phone\":\"+1234567890\", \"message\":\"Hello world, this is a sample message\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

🤩 🤖 Wassenger é uma solução completa de API para WhatsApp. Inscreva-se para um teste gratuito de 7 dias e comece em minutos!

Mais exemplos para mensagens de grupo com C# (.NET)

Para exemplos completos, visite nosso API Live Tester

Enviar mensagem de imagem com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a text message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Hello world, this is a sample message" // Message content }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar mensagens de vídeo com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a video message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a caption for a video message", // Add a caption for the video media = new { url = "https://download.samplelib.com/mp4/sample-5s.mp4", // URL of the video file expiration = "7d" // Set expiration time (e.g., 7 days) } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar mensagens de documento com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a PDF with expiration var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number media = new { url = "https://www.africau.edu/images/default/sample.pdf", // URL of the PDF file expiration = "30d" // Set expiration time (e.g., 30 days) } };

// Add the request

Enviar gravação de áudio com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending an audio message (PTT) var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number media = new { url = "https://download.samplelib.com/mp3/sample-9s.mp3", // URL of the audio file format = "ptt" // Format type for audio message (PTT - Push to Talk) } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem de mídia com um arquivo carregado usando C# (.NET)

*{{UPLOADED FILE ID}}* : Substitua esta expressão pelo valor específico

  • Você pode fazer upload do arquivo aqui
  • O ID do arquivo terá uma aparência semelhante a esta: 57443b8773c036f2bae0cd96

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending an image message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a caption for an image message", // Caption for the image media = new { file = "{{UPLOADED FILE ID}}" // Replace with the actual uploaded file ID } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem GIF com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a GIF message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a sample caption for a GIF message", // Caption for the GIF media = new { url = "https://i.giphy.com/vKHKDIdvxvN7vTAEOM.mp4", // URL of the GIF in MP4 format format = "gif" // Specify the media format } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma enquete com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add necessary headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for the poll var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number poll = new { name = "Vote for your favorite color", // Title of the poll options = new[] { "Red", "Green", "Blue", "Yellow", "Grey", "Black", "Orange", "Purple", "White" // Poll options } } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem agendada (data e hora) com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with method type POST var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a scheduled message to be sent to a phone number in 10 minutes", deliverAt = "2024-12-02T13:52:32.396Z" // Replace with your desired delivery time (ISO 8601 format) }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response (optional) Console.WriteLine(response.Content);

Enviar mensagens com botões nativos dinâmicos usando C# (.NET)

O WhatsApp não aceita mais mensagens de botões nativos. Mensagens com botões serão automaticamente convertidas em mensagens equivalentes em texto simples. Saiba mais aqui

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a message with dynamic reply buttons var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a message with dynamic reply buttons", // Message content header = "Optional message header", // Optional header footer = "Optional message footer", // Optional footer buttons = new[] { new { id = "id1", text = "Say hello" }, new { id = "id2", text = "Say goodbye" }, new { id = "id3", text = "Get help" } } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma lista de itens para selecionar com C# (.NET)

O WhatsApp não aceita mais mensagens do tipo lista. Mensagens de lista serão automaticamente convertidas em mensagens equivalentes em texto simples. Saiba mais aqui

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a list message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number list = new { button = "Select one option", // Button text description = "Select which type of vehicle you are interested in", // Description of the list title = "Motor Business", // Title of the list footer = "Since 1990", // Footer text sections = new[] { new { title = "Select a car type", rows = new[] { new { title = "Coupe", id = "a1", description = "This a description for coupe cars" }, new { title = "Sports", id = "a2", description = "This a description for sports cars" }, new { title = "SUV", id = "a3", description = "This a description for SUV cars" }, new { title = "Minivan", id = "a4", description = "This a description for minivan cars" }, new { title = "Crossover", id = "a5", description = "This a description for crossover cars" }, new { title = "Wagon", id = "a6", description = "This a description for wagon cars" } } }, new { title = "Select a motorbike type", rows = new[] { new { title = "Touring", id = "b1", description = "Designed to excel at covering long distances" }, new { title = "Cruiser", id = "b2", description = "Harley-Davidsons largely define the cruiser category" }, new { title = "Standard", id = "b3", description = "Motorcycle intended for use on streets and commuting" } } } } } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem com formatação de texto usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint

var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method

var request = new RestRequest(Method.POST); // Add headers for content type and authentication

request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a formatted text message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This message is formatted using _italic format_, *bold format*, strikethrough format and ```monospace format```" };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem com coordenadas de localização usando C# (.NET)

Saiba mais sobre como enviar mensagens de localização com coordenadas neste tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a location message with coordinates var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number location = new { coordinates = new[] { 40.7583748, -73.9891184 } // Latitude and longitude }, message = "This is a location message using coordinates" // Optional message }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar mensagem de localização com endereço usando C# (.NET)

Saiba mais sobre como enviar mensagens de localização com endereços neste tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a location message with an address var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number location = new { address = "Santa Claus Main Post Office, Tähtikuja 1, 96930 Arctic Circle, Finland" // Address }, message = "This is a location message using an address" // Optional message }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem com variáveis usando C# (.NET)

Saiba mais sobre como enviar mensagens com variáveis de template neste tutorial.

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a personalized message template var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = @"Dear {{ contact.name | customer }}, Thanks for contacting us! We will answer your query shortly. Your message was received on {{ date.humanize.full }}" // Template with placeholders }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar uma mensagem com URL usando C# (.NET)

Saiba mais sobre como enviar mensagens com links de URL neste tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a message with a link var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Check out this cool link: https://www.youtube.com" // Message with link }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Enviar cartões de contato com C# (.NET)

Saiba mais sobre como enviar cartões de contato neste tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending contact information var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number contacts = new[] { new { phone = "+1234567890", name = "John Doe" } // Contact details } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Responder a uma mensagem com C# (.NET)

{{MESSAGE ID}} : Substitua pelo ID real da mensagem do WhatsApp para responder (valor hexadecimal de 18, 20, 22 ou 32)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a reply message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number quote = "{{MESSAGE ID}}", // Replace with the actual message ID message = "This message is a reply to another message within the same chat" // Reply message content }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Encaminhar uma mensagem com C# (.NET)

{{MESSAGE ID}} : Substitua pelo ID real da mensagem do WhatsApp para encaminhar (valor hexadecimal de 18, 20, 22 ou 32)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number forward = new { message = "{{MESSAGE ID}}", // Replace with the message ID to forward chat = "+1234567890" // Replace with the chat ID to forward to }, message = "The given message by ID will be forwarded to another chat" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem de catálogo com C# (.NET)

{{PRODUCT CATALOG ID TO SEND}} : Substitua esta expressão pelo valor específico

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number product = "{{PRODUCT CATALOG ID TO SEND}}" // Replace with the product catalog ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem em tempo real sem enfileiramento usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { live = true, phone = "+1234567890", message = "This message will be delivered in real-time if the session is online, otherwise the API will return an error" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem com número máximo de tentativas usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { retries = 2, phone = "+1234567890", message = "This message will be retried only twice. If the delivery fails twice, it will be flagged as deleted and removed from the queue" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem com tempo de expiração usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { expiration = new { seconds = 90 }, phone = "+1234567890", message = "This message will be deleted if it cannot be delivered within 90 seconds after being queued. This is useful for time-sensitive messages." }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

🤩 🤖 Wassenger é uma solução completa de API para WhatsApp. Inscreva-se para um teste gratuito de 7 dias e comece em minutos!

Enviar uma mensagem dentro de um intervalo de dia e hora usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", message = "Restricted message example that will only be delivered between 9 am to 5 pm from Monday to Friday.", restrict = new { start = 9, end = 17, timezone = "CEST", weekdays = new[] { 1, 2, 3, 4, 5 } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma reação a uma mensagem usando C# (.NET)

{{WHATSAPP MESSAGE ID}} : Substitua esta expressão pelo valor específico

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", reaction = "👍", reactionMessage = "{{WHATSAPP MESSAGE ID}}" // Replace with the message ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Remover reação de mensagem:

{{WHATSAPP MESSAGE ID}} : Substitua esta expressão pelo valor correspondente

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", reaction = "-", // Use "-" to remove a reaction reactionMessage = "{{MESSAGE WHATSAPP ID}}" // Replace with the message ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem em nome de um agente e atribuir um chat usando C# (.NET)

{{USER ID}} : Substitua pelo ID real do usuário (valor hexadecimal de 24)

{{ASSIGNED USER ID}} : Substitua pelo ID real do usuário para atribuir o chat (valor hexadecimal de 24)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number agent = "{{USER ID}}", // Replace with the agent's user ID message = "This message is sent via API on behalf of an agent." }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem e marcar o chat como resolvido com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Once this message is delivered, the chat will be reported as resolved in the web chat interface.", actions = new[] { new { action = "chat:resolve" } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Enviar uma mensagem e adicionar um rótulo ao chat com C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Once this message is delivered, the given labels will be added to the chat automatically.", actions = new[] { new { action = "labels:add", params = new { labels = new[] { "new", "sales" } // Labels to be added } } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

🤩 🤖 Wassenger é uma solução completa de API para WhatsApp. Inscreva-se para um teste gratuito de 7 dias e comece em minutos!

Teste da API ao vivo

Você pode testar ao vivo e brincar com a API diretamente do seu navegador em minutos.

Quando terminar os testes, você pode obter o exemplo de código gerado automaticamente na sua linguagem de programação preferida e estará pronto para começar.

FAQ

Como enviar mensagens para vários números de telefone

Você precisa enviar várias solicitações de API, uma por número de telefone destino.

Por exemplo, para enviar uma mensagem para 10 números de telefone, você deve enviar 10 solicitações HTTPS independentes para a API.

Não existe opção para enviar múltiplas mensagens em uma única solicitação de API.

Como validar se um número de telefone pode receber mensagens do WhatsApp

Você pode validar se um determinado número de telefone está vinculado a uma conta do WhatsApp e pode receber mensagens.

A API fornece um endpoint para validar se um determinado número de telefone existe no WhatsApp.

O único requisito é ter pelo menos um número do WhatsApp conectado à plataforma na sua conta atual.

Para mais detalhes, consulte a documentação do endpoint da API aqui.

Antes de verificar se um número de telefone existe no WhatsApp, você também pode validar e normalizar o formato de uma lista de números de telefone usando o endpoint de validação de números. Esse endpoint apenas valida o formato correto E164 mas não verifica se o número está efetivamente no WhatsApp.

Observação: O número de validações de verificação do WhatsApp é limitado por mês com base no seu plano de assinatura. Por favor, verifique a tabela de preços para mais detalhes sobre os limites.

Procurando mais respostas? Consulte as FAQs estendidas.

Recursos adicionais úteis

Documentação da API

Para mais detalhes sobre o endpoint da API, consulte a documentação, onde você encontrará todos os detalhes sobre os parâmetros de solicitação aceitos, possíveis respostas de sucesso ou erro e exemplos de código prontos para uso em múltiplas linguagens de programação:

https://app.wassenger.com/docs/#tag/Messages/operation/createMessage

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free