event.unbind
Отменить зарегистрированный обработчик события
Описание
Метод event.unbind выполняет отмену зарегистрированного обработчика события.
Метод работает только в контексте авторизации приложения. Может работать как при авторизации под пользователем с правами администрирования Битрикс24, так и под обычным пользователем. Метод для пользователя без прав администратора доступен с ограничениями:
- Офлайн-события недоступны
- Можно удалить только обработчики online-событий, зарегистрированные для текущего пользователя
Параметры
event
string
обязательный
Имя события
handler
string
обязательный
Ссылка на обработчик события
auth_type
integer
необязательный
Идентификатор пользователя, под которым авторизуется обработчик события.
Если требуется удалить обработчики события, установленные с пустым auth_type (с авторизацией от имени пользователя, вызвавшего событие), но оставить остальные обработчики, указывайте auth_type=0 или пустое значение параметра.
event_type
string
необязательный
Значения: ``online|offline`. По умолчанию event_type=online, и поведение метода не меняется. Если вызывается event_type=offline`, то метод работает с офлайн-событиями
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"event": "ONCRMLEADADD",
"handler": "https://www.my-domain.ru/handler/",
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/event.unbind
// 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 EventUnbindResult = {
count: number
}
try {
const response = await $b24.actions.v2.call.make<EventUnbindResult>({
method: 'event.unbind',
params: {
event: 'ONCRMLEADADD',
handler: 'https://www.my-domain.ru/handler/',
auth_type: 15,
},
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('Unbound handlers count:', result.count)
}
} 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 unbindEvent() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'event.unbind',
params: {
event: 'ONCRMLEADADD',
handler: 'https://www.my-domain.ru/handler/',
auth_type: 15,
},
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('Unbound handlers count:', result.count)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', unbindEvent)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.event.unbind(
event="ONCRMLEADADD",
handler="https://www.my-domain.com/handler/",
auth_type=15,
).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 {
$eventCode = 'your_event_code'; // Replace with your actual event code
$handlerUrl = 'https://your.handler.url'; // Replace with your actual handler URL
$userId = null; // Replace with your actual user ID or leave as null
$result = $serviceBuilder
->getMainScope()
->event()
->unbind($eventCode, $handlerUrl, $userId);
print($result->getUnbindedHandlersCount());
} catch (Throwable $e) {
print('Error: ' . $e->getMessage());
}
require_once('crest.php');
$result = CRest::call(
'event.unbind',
[
'EVENT' => 'ONCRMLEADADD',
'HANDLER' => 'https://www.my-domain.ru/handler/',
'AUTH_TYPE' => 15
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Ответ
HTTP-статус: 200
{
"result": {
"count": 1
},
"time": {
"start": 1721298360.468008,
"finish": 1721298360.553977,
"duration": 0.0859689712524414,
"processing": 0.0023431777954101562,
"date_start": "2024-07-18T12:26:00+02:00",
"date_finish": "2024-07-18T12:26:00+02:00",
"operating": 0
}
}
Возвращаемые данные
result
object
Корневой элемент ответа
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 403
{
"error": "ACCESS_DENIED",
"error_description": "Access denied! Offline events unbinding requires administrator access rights"
}
| Код | Описание | Значение |
|---|---|---|
403 |
ACCESS_DENIED |
Access denied! Offline events unbinding requires administrator access rights |
403 |
ACCESS_DENIED |
Access denied! Event unbinding with AUTH_TYPE requires administrator access rights |

