mail.recipient.listemployees
Получить список сотрудников
Описание
Метод относится к REST 3.0. Особенности вызова и формат ответа новой версии API описаны в обзоре REST 3.0.
Метод mail.recipient.listemployees ищет сотрудников по имени или электронной почте.
Параметры
query
string
обязательный
Поисковая строка по имени или электронной почте сотрудника.
Необходимо указать хотя бы один символ
pagination
object
необязательный
Параметры постраничной навигации:
- page — номер страницы
- limit — количество записей на страницу, по умолчанию 50, максимум 200
- offset — смещение записей. Если переданы page и limit, смещение вычисляется автоматически
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"query":"Иван","pagination":{"page":1,"limit":20,"offset":0}}' \
https://**put_your_bitrix24_address**/rest/api/**put_your_user_id_here**/**put_your_webhook_here**/mail.recipient.listemployees
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"query":"Иван","pagination":{"page":1,"limit":20,"offset":0},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/api/mail.recipient.listemployees
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type ListEmployeesResult = {
items: {
id: number
email: string
name: string
}[]
}
try {
const response = await $b24.actions.v3.call.make<ListEmployeesResult>({
method: 'mail.recipient.listemployees',
params: {
query: 'Ivan',
pagination: {
page: 1,
limit: 20,
offset: 0,
},
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Employees found:', result.items.length, result.items)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function listEmployees() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v3.call.make({
method: 'mail.recipient.listemployees',
params: {
query: 'Ivan',
pagination: {
page: 1,
limit: 20,
offset: 0,
},
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Employees found:', result.items.length, result.items)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', listEmployees)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
pagination = {
"page": 1,
"limit": 20,
"offset": 0,
}
try:
bitrix_response = client.mail.recipient.listemployees(
query='Иван',
pagination=pagination,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'mail.recipient.listemployees',
[
'query' => 'Иван',
'pagination' => [
'page' => 1,
'limit' => 20,
'offset' => 0
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error: ' . $e->getMessage();
}
BX24.callMethod(
'mail.recipient.listemployees',
{
query: 'Иван',
pagination: {
page: 1,
limit: 20,
offset: 0
}
},
function(result){
console.info(result.data());
console.log(result);
}
);
require_once('crest.php');
$result = CRest::call(
'mail.recipient.listemployees',
[
'query' => 'Иван',
'pagination' => [
'page' => 1,
'limit' => 20,
'offset' => 0
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "mail.recipient.listemployees", b24.Params{
"query": "Иван",
"pagination": b24.Params{
"page": 1,
"limit": 20,
"offset": 0,
},
})
if err != nil {
return fmt.Errorf("mail.recipient.listemployees: %w", err)
}
// Метод заворачивает ответ в объект с ключом "items".
raw, ok := b24.Unwrap(res.Result, "items")
if !ok {
return fmt.Errorf("в ответе нет ключа items")
}
var items []struct {
ID b24.ID `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
}
if err := json.Unmarshal(raw, &items); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
for _, it := range items {
fmt.Println(it.ID)
}
Ответ
HTTP-статус: 200
{
"result": {
"items": [
{
"id": 7,
"email": "user@example.com",
"name": "Иван Петров"
}
]
},
"time": {
"start": 1779820087,
"finish": 1779820087.962438,
"duration": 0.9624381065368652,
"processing": 0,
"date_start": "2026-05-26T21:28:07+03:00",
"date_finish": "2026-05-26T21:28:07+03:00",
"operating_reset_at": 1779820687,
"operating": 0
}
}
Возвращаемые данные
result
object
Объект с данными ответа
items
array
Массив объектов сотрудников
items[]
object
Объект сотрудника
id
integer
Идентификатор сотрудника
email
string
Email сотрудника
name
string
Имя сотрудника
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error": {
"code": "BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION",
"message": "Ошибка при валидации объекта запроса",
"validation": [
{
"message": "Обязательное поле `query` не указано",
"field": "query"
}
]
}
}
| Код | Описание | Значение |
|---|---|---|
Поле |
Описание ошибки | Как исправить |
| — | Доступ запрещен | Проверьте права пользователя и scope mail |

