How To Manage Team Departments On WhatsApp Using Python

March 14, 2025

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 Python and Wassenger API to:

  1. Get team departments
  2. Create a new department
  3. Update a department
  4. Delete a department
  5. 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

  1. By using the API, query the available departments in your device for this endpoint.

1. GET Departments with Python

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

Get Departments with Python

# Examples requires to have installed requests Python package. # Install it by running: pip install requests

import requests

url = "https://api.wassenger.com/v1/devices/%7B%7Bdevice.id%7D%7D/departments"

headers = {"Token": "ENTER API KEY HERE"}

response = requests.get(url, headers=headers)

print(response.json())

2. CREATE a New Department with Python

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

Create Departments with Python

# Examples requires to have installed requests Python package. # Install it by running: pip install requests

import requests

url = "https://api.wassenger.com/v1/devices/device.id/departments"

payload = { "name": "Sales", "color": "orange", "description": "Department for the Sales team", "agents": ["{{AGENT_ID}}"] } headers = { "Content-Type": "application/json", "Token": "ENTER API KEY HERE" }

response = requests.post(url, json=payload, headers=headers)

print(response.json())

🤩 🤖 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 Python

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

Update Departments with Python

# Examples requires to have installed requests Python package. # Install it by running: pip install requests

import requests

url = "https://api.wassenger.com/v1/team"

payload = { "department": "{{DEPARTMENT_ID}}", "name": "Marketing", "color": "purple", "description": "Department for the Marketing team", "agents": ["{{AGENT_ID}}"] } headers = { "Content-Type": "application/json", "Token": "ENTER API KEY HERE" }

response = requests.patch(url, json=payload, headers=headers)

print(response.json())

4. DELETE Department with Python

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

Delete Departments with PHP (Guzzle)

# Examples requires to have installed requests Python package.
# Install it by running: pip install requests
import requests
url = "https://api.wassenger.com/v1/devices/device.id/departments"
payload = { "department": "{{DEPARTMENT_ID}}" }
headers = {
"Content-Type": "application/json", 
"Token": "ENTER API KEY HERE"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.json())

🤩 🤖 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

Try our API-Live tester now!

Managing departments with Wassenger API in Python 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!

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free