Efficient communication is key for any business, and with Wassenger’s Departments feature, you can organize your team members by speciality, ensuring chats are assigned to the right people effortlessly. 🚀
In this guide, we’ll show you how to use C# and Wassenger API to:
- Get team departments
- Create a new department
- Update a department
- Delete a department
- Assign chats to departments
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Why Use Departments in Wassenger? 🤔
With Departments, you can:
✅ Organize Your Team — Group team members by function or expertise. ✅ Improve Chat Routing — Automatically assign incoming chats to the right department or user. ✅ Enhance Efficiency — Reduce response time by sending chats directly to those best suited to handle them. ✅ Seamlessly Integrate with Team Roles — Works alongside administrator, supervisor, and agent roles without changing their default permissions.
🔗 Want to learn more about Departments? Check out the full guide here
Requirements
- Having a WhatsApp number already linked to the platform and online.
- By using the API, query the available departments in your device for this endpoint.
1. GET Departments with C# (.NET)
Target API URL using the GET method
http://api.wassenger.com/v1/devices/{device_id}/departments
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Get departments
- C# (RestClient)
// 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/devices/%7Bdevice_id%7D/departments");
var request = new RestRequest(Method.GET);
request.AddHeader("Token", "API TOKEN GOES HERE");
IRestResponse response = client.Execute(request);
- C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.wassenger.com/v1/devices/%7Bdevice_id%7D/departments"),
Headers =
{
{ "Token", "API TOKEN GOES HERE" },
},
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
2. CREATE a New Department with C# (.NET)
Target API URL using the POST method
http://api.wassenger.com/v1/devices/{device_id}/departments
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Create Department
{{AGENT_ID}} : Replace this expression with the specific value
- C# (RestClient)
// 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/devices/{device_id}/departments");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"name\":\"Sales\", \"color\":\"orange\", \"description\":\"Department for the Sales team\", \"agents\":[\"{{AGENT_ID}}\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"),
Headers =
{
{ "Token", "API TOKEN GOES HERE" },
},
Content = new StringContent("{\"name\":\"Sales\", \"color\":\"orange\", \"description\":\"Department for the Sales team\", \"agents\":[\"{{AGENT_ID}}\"]}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
3. UPDATE Department with C# (.NET)
Target API URL using the PATCH method
http://api.wassenger.com/v1/devices/{device_id}/departments
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Update Department
{{DEPARTMENT_ID}} : Replace this expression with the specific value
{{AGENT_ID}} : Replace this expression with the specific value
- C# (RestClient)
// 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/devices/{device_id}/departments");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"department\":\"{{DEPARTMENT_ID}}\", \"name\":\"Marketing\", \"color\":\"purple\", \"description\":\"Department for the Marketing team\", \"agents\":[\"{{AGENT_ID}}\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Patch,
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"),
Headers =
{
{ "Token", "API TOKEN GOES HERE" },
},
Content = new StringContent("{\"department\":\"{{DEPARTMENT_ID}}\", \"name\":\"Marketing\", \"color\":\"purple\", \"description\":\"Department for the Marketing team\", \"agents\":[\"{{AGENT_ID}}\"]}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
4. DELETE Department with C# (.NET)
Target API URL using the DELETE method
http://api.wassenger.com/v1/devices/{device_id}/departments
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Delete Department
{{DEPARTMENT_ID}} : Replace this expression with the specific value
- C# (RestClient)
// 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/devices/{device_id}/departments");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"department\":\"{{DEPARTMENT_ID}}\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"),
Headers =
{
{ "Token", "API TOKEN GOES HERE" },
},
Content = new StringContent("{\"department\":\"{{DEPARTMENT_ID}}\"}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes!
Live testing to send a message to a group via API
Managing departments with Wassenger API in C# allows businesses to streamline chat assignments, improve efficiency, and keep conversations organized without hassle.
📌 Stop juggling chat assignments manually! Automate, optimize, and scale your business effortlessly with Wassenger. Start your free trial now!







