Create a new department
curl --request POST \
--url https://your-instance.example.com/api/departments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Sales",
"description": "Inbound + outbound sales reps",
"managerIds": [
"65b1f0a2c3d4e5f6a7b8c9e0"
],
"userIds": [
"65b1f0a2c3d4e5f6a7b8c9d0",
"65b1f0a2c3d4e5f6a7b8c9d1"
]
}
'import requests
url = "https://your-instance.example.com/api/departments"
payload = {
"name": "Sales",
"description": "Inbound + outbound sales reps",
"managerIds": ["65b1f0a2c3d4e5f6a7b8c9e0"],
"userIds": ["65b1f0a2c3d4e5f6a7b8c9d0", "65b1f0a2c3d4e5f6a7b8c9d1"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sales',
description: 'Inbound + outbound sales reps',
managerIds: ['65b1f0a2c3d4e5f6a7b8c9e0'],
userIds: ['65b1f0a2c3d4e5f6a7b8c9d0', '65b1f0a2c3d4e5f6a7b8c9d1']
})
};
fetch('https://your-instance.example.com/api/departments', 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://your-instance.example.com/api/departments",
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' => 'Sales',
'description' => 'Inbound + outbound sales reps',
'managerIds' => [
'65b1f0a2c3d4e5f6a7b8c9e0'
],
'userIds' => [
'65b1f0a2c3d4e5f6a7b8c9d0',
'65b1f0a2c3d4e5f6a7b8c9d1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://your-instance.example.com/api/departments"
payload := strings.NewReader("{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://your-instance.example.com/api/departments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/departments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"department": {
"_id": "65c1a0b0c0d0e0f0a0b0c0d1",
"name": "Sales",
"description": "Inbound + outbound sales reps",
"organizationId": "65a0e0e0e0e0e0e0e0e0e0e0",
"createdAt": "2026-01-12T09:00:00.000Z",
"updatedAt": "2026-04-04T12:30:00.000Z"
}
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}Departments
Create a new department
Create a department within the caller’s organization. Name must be unique per-org; provided managerIds/userIds are validated against the same org.
POST
/
api
/
departments
Create a new department
curl --request POST \
--url https://your-instance.example.com/api/departments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Sales",
"description": "Inbound + outbound sales reps",
"managerIds": [
"65b1f0a2c3d4e5f6a7b8c9e0"
],
"userIds": [
"65b1f0a2c3d4e5f6a7b8c9d0",
"65b1f0a2c3d4e5f6a7b8c9d1"
]
}
'import requests
url = "https://your-instance.example.com/api/departments"
payload = {
"name": "Sales",
"description": "Inbound + outbound sales reps",
"managerIds": ["65b1f0a2c3d4e5f6a7b8c9e0"],
"userIds": ["65b1f0a2c3d4e5f6a7b8c9d0", "65b1f0a2c3d4e5f6a7b8c9d1"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sales',
description: 'Inbound + outbound sales reps',
managerIds: ['65b1f0a2c3d4e5f6a7b8c9e0'],
userIds: ['65b1f0a2c3d4e5f6a7b8c9d0', '65b1f0a2c3d4e5f6a7b8c9d1']
})
};
fetch('https://your-instance.example.com/api/departments', 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://your-instance.example.com/api/departments",
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' => 'Sales',
'description' => 'Inbound + outbound sales reps',
'managerIds' => [
'65b1f0a2c3d4e5f6a7b8c9e0'
],
'userIds' => [
'65b1f0a2c3d4e5f6a7b8c9d0',
'65b1f0a2c3d4e5f6a7b8c9d1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://your-instance.example.com/api/departments"
payload := strings.NewReader("{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://your-instance.example.com/api/departments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/departments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sales\",\n \"description\": \"Inbound + outbound sales reps\",\n \"managerIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9e0\"\n ],\n \"userIds\": [\n \"65b1f0a2c3d4e5f6a7b8c9d0\",\n \"65b1f0a2c3d4e5f6a7b8c9d1\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"department": {
"_id": "65c1a0b0c0d0e0f0a0b0c0d1",
"name": "Sales",
"description": "Inbound + outbound sales reps",
"organizationId": "65a0e0e0e0e0e0e0e0e0e0e0",
"createdAt": "2026-01-12T09:00:00.000Z",
"updatedAt": "2026-04-04T12:30:00.000Z"
}
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}{
"error": "Department with this name already exists"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
Department created
Show child attributes
Show child attributes
Example:
{
"_id": "65c1a0b0c0d0e0f0a0b0c0d1",
"name": "Sales",
"description": "Inbound + outbound sales reps",
"organizationId": "65a0e0e0e0e0e0e0e0e0e0e0",
"managerIds": [
{
"_id": "65b1f0a2c3d4e5f6a7b8c9e0",
"fullName": "Brenda Lee",
"email": "brenda@example.com",
"accessRole": "ADMIN"
}
],
"userIds": [
{
"_id": "65b1f0a2c3d4e5f6a7b8c9d0",
"fullName": "Alice Rivera",
"email": "alice@example.com",
"accessRole": "AGENT"
}
],
"createdBy": {
"_id": "65b1f0a2c3d4e5f6a7b8c9e0",
"fullName": "Brenda Lee",
"email": "brenda@example.com"
},
"updatedBy": {
"_id": "65b1f0a2c3d4e5f6a7b8c9e0",
"fullName": "Brenda Lee",
"email": "brenda@example.com"
},
"createdAt": "2026-01-12T09:00:00.000Z",
"updatedAt": "2026-04-04T12:30:00.000Z"
}
⌘I