💼

departments

Organizational unit within a company representing a functional division such as Sales, Engineering, Marketing, or HR. Contains department structure, staffing, budget allocation, and management information.

🎯 Request Builder

https://api.mockly.codes/departments?page=1&limit=10&count=10
📡

Configure your request and click Send Request to see the response here.

Endpoints

GET/departments

Get a collection of departments

Alternative: /business/departments
GET/departments/:id

Get a single department by ID

Alternative: /business/departments/:id
GET/departments/meta

Get resource metadata and schema

Alternative: /business/departments/meta
🔍

How to Use Search

The search feature allows you to filter results by searching for text across all or specific fields. Choose between ?q= or ?search= parameter names.

1. Basic Search

Search across all text fields:

Basic Search
GET https://api.mockly.codes/departments?q=laptop

2. Search Specific Fields

Field-Specific Search
GET https://api.mockly.codes/departments?q=laptop&search_fields=name,description

💡 Pro Tips

  • Search is case-insensitive and performs partial matching
  • Without search_fields, all text fields are searched
  • Combine with pagination to handle large result sets efficiently

Code Examples

JavaScript

Fetch Collection
// Get 10 departments
fetch('https://api.mockly.codes/departments?count=10')
  .then(res => res.json())
  .then(data => console.log(data));

Python

Fetch with Requests
import requests

response = requests.get(
    'https://api.mockly.codes/departments?count=10'
)
data = response.json()

cURL

Command Line
curl "https://api.mockly.codes/departments?count=10"

Bypass Cache

Get Fresh Data
fetch('https://api.mockly.codes/departments?nocache=true')

Schema Properties

idinteger

Unique identifier for the department record

Gen:random_int
namestring

Official name of the department (e.g., Engineering, Sales, Human Resources)

Gen:department
codestring

Short alphanumeric code used internally to identify the department

Gen:word
manager_idinteger

Employee ID of the department manager or head

Gen:random_int
employee_countinteger

Total number of employees currently assigned to this department

Gen:random_int
budgetnumber

Annual budget allocation for the department in the company's primary currency

Gen:random_int
locationstring

City or office location where the department is primarily based

Gen:city
descriptionstring

Detailed description of the department's responsibilities, functions, and objectives

Gen:paragraph
establishedstring

Date when the department was created or established within the organization

Gen:past_datedate

Query Parameters

countinteger

Number of items to return (default: 10, max: 100)

seedinteger

Seed for reproducible data generation

nocacheboolean

Bypass cache and generate fresh data on every request