Skip to main content
GET
/
lucca-api
/
departments
List departments
curl --request GET \
  --url https://{host}/lucca-api/departments \
  --header 'Api-Version: <api-version>' \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://{host}/lucca-api/departments"

headers = {
"Api-Version": "<api-version>",
"Authorization": "Bearer <token>"
}

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

print(response.text)
const options = {
method: 'GET',
headers: {'Api-Version': '<api-version>', Authorization: 'Bearer <token>'}
};

fetch('https://{host}/lucca-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://{host}/lucca-api/departments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Api-Version: <api-version>",
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://{host}/lucca-api/departments"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Api-Version", "<api-version>")
req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://{host}/lucca-api/departments")
.header("Api-Version", "<api-version>")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{host}/lucca-api/departments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Api-Version"] = '<api-version>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "type": "departments",
  "url": "https://example.ilucca.net/lucca-api/departments?limit=25",
  "totalCount": 11,
  "items": [
    {
      "id": "32",
      "type": "department",
      "url": "https://example.ilucca.net/lucca-api/departments/32",
      "name": "Finances",
      "description": null,
      "remoteId": "FIN",
      "isArchived": false,
      "parent": null,
      "level": 1,
      "sortOrder": 2,
      "manager": {
        "id": "416",
        "type": "employee",
        "url": "https://example.ilucca.net/lucca-api/employees/416"
      },
      "owningApplication": null,
      "links": {}
    }
  ],
  "links": {
    "prev": null,
    "next": {
      "href": "https://example.ilucca.net/lucca-api/departments?page=!sdk87Sdh&limit=25"
    }
  },
  "embedded": {}
}
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"instance": "https://example.ilucca.net/lucca-api/leaves/1573",
"errors": {
"endsOn": [
"Invalid period: StartsOn should be before EndsOn."
],
"employeeId": [
"The employeeId query parameter is required."
]
},
"extensions": {
"traceId": "|78777424-49cc27e04281bbfc."
}
}
{
"type": "https://datatracker.ietf.org/doc/html/rfc7235#section-3.1",
"title": "Unauthorized",
"status": 401,
"instance": "https://example.ilucca.net/lucca-api/employees/1573"
}
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",
"title": "Internal Server Error",
"status": 500,
"instance": "https://example.ilucca.net/lucca-api/employees/1573"
}
OAuth 2.0 scopes
 departments.readonly
or
 departments.readwrite

Authorizations

Authorization
string
header
required

The Lucca API implements the oAuth 2 protocol with the client-credentials-flow. Refer to RFC8725.

Headers

Api-Version
enum<string>
required

Set the API version.

Available options:
2024-11-01
Allowed value: "2024-11-01"
Maximum string length: 10
Example:

"2024-11-01"

If-None-Match
string

Only execute the request if current cached version of the resource does not match the one given here.

Example:

"W/q5sd4w2x1c1gfdg"

If-Match
string

Only execute the request if current cached version of the resource matches the one given here. Useful to avoid concurrency conflicts.

Example:

"W/q5sd4w2x1c1gfdg"

Accept-Encoding
string

List of compression algorithms you support.

Query Parameters

Filter departments by their name and/or remoteId. The search is case insensitive and looks for partial matches.

Minimum string length: 1
sort
enum<string>
default:id

Sort departments. Can be chained. Default is id, i.e. "id ascending".

Available options:
id,
+id,
-id,
name,
+name,
-name
isArchived
boolean

When omitted: return both archived and non-archived resources. When true: only return archived resources. When false: only return non-archived resources.

page
string

Cursor of the page to retrieve. Read more about pagination.

limit
integer
default:25

Number of items per page. Defaults to 25. Maximum is 100. Read more about pagination.

Required range: 0 <= x <= 100
include
enum<string>[]

Include metadata:

  • embedded: the partial or complete representations of related resources (e.g. the employee the resource belongs to).
  • links: links to related resources or actions (e.g. approving a leave-request). May be null when you do not have access to the resource (or action).
  • totalCount: only applicable on collections (i.e. lists of resources), gives the total number of items across all pages.

Read more about expanding responses.

Available options:
embedded,
links,
totalCount

Response

OK

A collection of department resources.

type
string
required
Allowed value: "departments"
url
string<uri>
required
items
department · object[]
required
Maximum array length: 100
totalCount
integer<int64> | null

Total number of department resources across all pages that satisfy query parameters.

Required range: x >= 0

Links to related resources

embedded
object | null

No embedded resources on a department(s) response. Expect an empty object if embedded are requested.