List departments
GET/v1/departmentsScope read
Active departments of the organization, to set contact.departmentId when you open a request.
Response
Section titled “Response”200 OK · data[]
| Field | Type | Description |
|---|---|---|
code |
string |
Stable code. Compare against it in your code. |
id |
integer |
Unique ID. |
name |
string |
Name in the language of Accept-Language. |
parentId |
integer |
Parent department, if any. |
path |
string |
Full path from the top of the hierarchy. |
{ "data": [ { "id": 4, "name": "Sales", "code": "SLS", "parentId": 1, "path": "Commercial / Sales" } ]}Errors
Section titled “Errors”Errors share one shape; see Errors for every key.
Code examples
Section titled “Code examples”curl 'https://api.client.service-desk.goldmaster.io/v1/departments' \ -H "Authorization: Bearer $DUTY_API_KEY"const response = await fetch('https://api.client.service-desk.goldmaster.io/v1/departments', { method: 'GET', headers: { Authorization: `Bearer ${process.env.DUTY_API_KEY}`, },});const body = await response.json();if (!response.ok) throw new Error(`${body.error}: ${body.message}`);console.log(body.data);import os
import requests
response = requests.request( "GET", "https://api.client.service-desk.goldmaster.io/v1/departments", headers={"Authorization": f"Bearer {os.environ['DUTY_API_KEY']}"}, timeout=30,)response.raise_for_status()print(response.json()["data"])package main
import ( "fmt" "io" "net/http" "os")
func main() { req, _ := http.NewRequest("GET", "https://api.client.service-desk.goldmaster.io/v1/departments", nil) req.Header.Set("Authorization", "Bearer "+os.Getenv("DUTY_API_KEY")) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, _ := io.ReadAll(res.Body) fmt.Println(res.Status, string(data))}<?php$ch = curl_init('https://api.client.service-desk.goldmaster.io/v1/departments');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . getenv('DUTY_API_KEY'), ],]);$response = curl_exec($ch);$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);echo $status, PHP_EOL, $response;using System.Net.Http.Headers;
using var client = new HttpClient();using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.client.service-desk.goldmaster.io/v1/departments");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("DUTY_API_KEY"));using var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");import java.net.URI;import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.client.service-desk.goldmaster.io/v1/departments")) .header("Authorization", "Bearer " + System.getenv("DUTY_API_KEY")) .method("GET", HttpRequest.BodyPublishers.noBody()) .build();var response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode() + " " + response.body());