b24_departments_list
Retrieve a list of departments from your Bitrix24 organizational structure, including hierarchy and responsible managers.
Instructions
Lista departamentos de la estructura organizativa con jerarquía y responsables.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filtros. Ejemplo: { "PARENT": 5 } para subdepartamentos. { "NAME": "Ventas" } para buscar por nombre | |
| webhook_url | No |
Implementation Reference
- index.js:200-202 (registration)Registration of 'b24_departments_list' tool via server.tool() with departmentsListSchema and departmentsList handler.
server.tool('b24_departments_list', 'Lista departamentos de la estructura organizativa con jerarquía y responsables.', departmentsListSchema.shape, wrap(departmentsList)); - src/tools/users-departments.js:40-44 (handler)Handler function departmentsList that accepts filter and webhook_url, calls department.get via Bitrix24Client with pagination.
export async function departmentsList({ filter = {}, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const departments = await fetchAllPages(client, 'department.get', filter); return { portal: client.portal, total: departments.length, departments }; } - src/tools/users-departments.js:33-38 (schema)Zod schema departmentsListSchema defining input parameters: filter (optional, defaults to {}) and webhook_url (optional URL).
export const departmentsListSchema = z.object({ filter: z.record(z.any()).optional().default({}).describe( 'Filtros. Ejemplo: { "PARENT": 5 } para subdepartamentos. { "NAME": "Ventas" } para buscar por nombre' ), webhook_url: z.string().url().optional(), }); - src/tools/users-departments.js:4-4 (helper)Import of resolveWebhook helper used to resolve webhook_url for the Bitrix24 client.
import { resolveWebhook } from '../utils/resolve-webhook.js'; - src/tools/users-departments.js:3-3 (helper)Import of fetchAllPages helper used to paginate through department.get results.
import { fetchAllPages } from '../utils/pagination.js';