Heute zeigen wir dir den ultimativen Leitfaden zum Senden verschiedener WhatsApp-Nachrichtentypen mit C# (.NET)
Effektive Kommunikation ist entscheidend für Projektkoordination, Community-Engagement und reaktionsschnellen Kundensupport. Wassenger verbessert diesen Prozess, indem es nahtlose Verwaltungs- und Interaktionswerkzeuge innerhalb von WhatsApp-Nachrichten bereitstellt. Mit seiner intuitiven API und Automatisierungsfunktionen wird das Senden von Nachrichten, Videos, Bildern, Dokumenten und Sprachnachrichten einfach und effizient.
In diesem Artikel findest du:
- Send Image Message 🖼️
- Send Video Messages 📹
- Send Document Messages 📄
- Send Audio Voice Record 🎙️
- Send a Media Message with an Uploaded File 📤
- Send a GIF Message 🎞️
- Send a Poll Message 📊
- Send a Scheduled Date and Time Message 📅
- Send Dynamic Native Button Messages 🔘
- Send a List of Items to Select From 📝
- Send a Message with Text Formatting ✍️
- Send a Location Message with Coordinates 📍
- Send a Location Message with the Address 🗺️
- Send a Message with Variables 🔄
- Send Messages with Links 🔗
- Send Contact Card Messages 📇
- Reply to a Message 💬
- Forward a Message 🔁
- Send a Catalogue Message 📒
- Send a Message in Real-Time with No Enqueueing ⏱️
- Send a Message with Maximum Retries 🔄
- Send a Message with the Expiration Time ⏳
- Send a Message Within a Time and Day Range 🕰️
- Send a Message Reaction 😊
- Remove a Message Reaction 🚫
- Send a Message on Behalf of an Agent and Assign a Chat 👤
- Send a Message and Resolve the Chat ✅
- Send a Message and Add a Chat Label 🏷️
🤩 🤖 Wassenger ist eine komplette Kommunikationsplattform und API-Lösung für WhatsApp. Entdecke mehr als 100+ API-Anwendungsfälle und automatisiere alles auf WhatsApp indem du dich anmeldest für eine kostenlose Testversion und in wenigen Minuten loslegst!
Voraussetzungen
- Eine WhatsApp-Nummer, die bereits mit der Plattform verknüpft und online ist.
- Die Telefonnummer des Nachrichtenempfängers mit internationaler Vorwahl im E164-Format. Beispiel:
+12345678900. Validieren Sie das Telefonnummernformat hier.
API-Endpunkt
Wir verwenden den folgenden API-Endpunkt, um Nachrichten an eine Gruppe zu senden:
Anfrage vorbereiten
Ziel-API-URL mit der POST-Methode
https://api.wassenger.com/v1/messages
Erforderliche HTTPS-Header > Holen Sie hier Ihren API-Schlüssel
Content-Type: application/json
Token: $API_TOKEN
Verwende den Body im JSON-Format
{
"phone": "+1234567890",
"message": "Hello world, this is a sample message"
}
🖥️ Suchst du ein Codebeispiel? Gehe zum API Live Tester und erhalte gebrauchsfertige Codebeispiele in 15+ Programmiersprachen, darunter JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL und mehr.
Textnachrichten mit C# (.NET) senden
// 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 ist eine komplette API-Lösung für WhatsApp. Melde dich für eine 7-tägige kostenlose Testversion an und lege in Minuten los!
Weitere Beispiele für Gruppen-Nachrichten mit C# (.NET)
Für vollständige Beispiele besuche unseren API Live Tester
Send image message with 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);
Send video messages with 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);
Send document messages with 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
Send audio voice record with 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);
Send a media message with an uploaded file using C# (.NET)
*{{UPLOADED FILE ID}}*: Ersetze diesen Ausdruck durch den spezifischen Wert
- Du kannst die Datei hier hochladen
- Die Datei-ID sieht ungefähr so aus: 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);
Send a GIF message with 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);
Send a poll message with 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);
Send a scheduled date and time message with 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);
Send dynamic native button messages with C# (.NET)
WhatsApp akzeptiert native Button-Nachrichten nicht mehr. Button-Nachrichten werden automatisch in ihr reines Textequivalent konvertiert. Erfahre mehr hier
// 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);
Send a list of items to select from with C# (.NET)
WhatsApp akzeptiert Listennachrichten nicht mehr. Listennachrichten werden automatisch in ihr reines Textequivalent konvertiert. Erfahre mehr hier
// 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);
Send a message with text formatting using 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);
Send a message with location coordinates using C# (.NET)
Erfahre mehr darüber, wie du Standortnachrichten mit Koordinaten sendest in diesem 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);
Send location message with address using C# (.NET)
Erfahre mehr darüber, wie du Standortnachrichten mit Adressen sendest in diesem 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);
Send a message with variables using C# (.NET)
Erfahre mehr darüber, wie du Nachrichten mit Template-Variablen sendest in diesem 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);
Send a message with a URL using C# (.NET)
Erfahre mehr darüber, wie du Nachrichten mit URL-Links sendest in diesem 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);
Send contact card messages with C# (.NET)
Erfahre mehr darüber, wie du Kontaktkarten-Nachrichten sendest in diesem 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);
Reply to a message with C# (.NET)
{{MESSAGE ID}} : Ersetze dies durch die tatsächliche WhatsApp-Nachrichten-ID, auf die geantwortet werden soll (18, 20, 22 oder 32 hexadezimale Werte)
// 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);Forward a message with C# (.NET)
{{MESSAGE ID}} : Ersetze dies durch die tatsächliche WhatsApp-Nachrichten-ID, die weitergeleitet werden soll (18, 20, 22 oder 32 hexadezimale Werte)
// 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);
Send a catalogue message with C# (.NET)
{{PRODUCT CATALOG ID TO SEND}} : Ersetze diesen Ausdruck durch den spezifischen Wert
// 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);
Send a message in real-time with no enqueueing using 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);
Send a message with maximum retries using 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);
Send a message with the expiration time using 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 ist eine komplette API-Lösung für WhatsApp. Melde dich für eine 7-tägige kostenlose Testversion an und lege in Minuten los!
Send a message within a time and day range using 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);
Send a message reaction using C# (.NET)
{{WHATSAPP MESSAGE ID}} : Ersetze diesen Ausdruck durch den spezifischen Wert
// 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);
Remove message reaction:
{{WHATSAPP MESSAGE ID}} : Ersetze diesen Ausdruck durch den entsprechenden Wert
// 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);
Send a message on behalf of an agent and assign a chat using C# (.NET)
{{USER ID}} : Ersetze durch die tatsächliche Benutzer-ID (24 hexadezimale Werte)
{{ASSIGNED USER ID}} : Ersetze durch die tatsächliche Benutzer-ID, der der Chat zugewiesen werden soll (24 hexadezimale Werte)
// 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);
Send a message and resolve the chat with 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);
Send a message and add a chat label with 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 ist eine komplette API-Lösung für WhatsApp. Melde dich für eine 7-tägige kostenlose Testversion an und lege in Minuten los!
Live API-Test
Du kannst die API in wenigen Minuten live testen und direkt im Browser damit experimentieren.
Sobald du mit dem Testen fertig bist, kannst du das automatisch erzeugte Codebeispiel in deiner bevorzugten Programmiersprache herunterladen und bist startklar.
FAQ
Wie sende ich Nachrichten an mehrere Telefonnummern
Du musst mehrere API-Anfragen senden, jeweils eine pro Zieltelefonnummer.
Wenn du beispielsweise eine Nachricht an 10 Telefonnummern senden möchtest, solltest du 10 unabhängige HTTPS-Anfragen an die API senden.
Es gibt keine Option, mehrere Nachrichten in einer einzigen API-Anfrage zu senden.
Wie überprüfe ich, ob eine Telefonnummer WhatsApp-Nachrichten empfangen kann
Du kannst überprüfen, ob eine bestimmte Telefonnummer mit einem WhatsApp-Konto verknüpft ist und Nachrichten empfangen kann.
Die API stellt einen Endpunkt bereit, um zu validieren, ob eine bestimmte Telefonnummer auf WhatsApp existiert.
Voraussetzung ist, dass du mindestens eine WhatsApp-Nummer in deinem aktuellen Konto mit der Plattform verbunden hast.
Für weitere Details siehe bitte die API-Endpunktdokumentation hier.
Bevor du prüfst, ob eine Telefonnummer auf WhatsApp existiert, kannst du außerdem das Format einer Liste von Telefonnummern mit dem numbers validator API-Endpunkt validieren und normalisieren. Dieser Endpunkt validiert nur das korrekte E164-Format, prüft jedoch nicht, ob die Telefonnummer tatsächlich bei WhatsApp registriert ist.
Hinweis: Die Anzahl der WhatsApp-Überprüfungen ist pro Monat abhängig von deinem Abonnementplan begrenzt. Sieh dir bitte die Preisübersicht für weitere Details zu den Limits an.
Suchst du weitere Antworten? Sieh dir die erweiterten FAQs an.
Weiterführende nützliche Ressourcen
API-Dokumentation
Für weitere Details zum API-Endpunkt, siehe die Dokumentation, in der du alle Informationen über akzeptierte Anfrageparameter, mögliche Erfolgs- oder Fehlermeldungen und gebrauchsfertige Codebeispiele in mehreren Programmiersprachen findest:
https://app.wassenger.com/docs/#tag/Messages/operation/createMessage







