REST API
API позволяет добавлять и управлять мониторами, получать статусы, инциденты и uptime. Ключ создаётся в кабинете: Настройки → API-ключи. Ограничение — 60 запросов в минуту на ключ.
Авторизация
curl -H "Authorization: Bearer nfk_ваш_ключ" https://notifar.io/api/v1/me
Мониторы
| Метод | Путь | Описание |
|---|---|---|
| GET | /api/v1/monitors | Список (фильтры: status, type, q, tag) |
| POST | /api/v1/monitors | Создать (поля как в форме, см. ниже) |
| GET | /api/v1/monitors/:id | Монитор с настройками и статусом по точкам |
| PATCH | /api/v1/monitors/:id | Частичное обновление |
| DELETE | /api/v1/monitors/:id | Удалить |
| POST | /api/v1/monitors/:id/pause · /resume · /check | Пауза, возобновление, проверить сейчас |
| GET | /api/v1/monitors/:id/status · /results · /uptime?days=30 · /incidents | Текущее состояние, сырые результаты, uptime по дням, инциденты |
| GET | /api/v1/incidents?open=1 | Инциденты аккаунта |
| GET | /api/v1/locations · /contacts · /balance · /types | Справочники и баланс |
Пример: создать HTTP-монитор
curl -X POST https://notifar.io/api/v1/monitors \
-H "Authorization: Bearer nfk_ваш_ключ" -H "Content-Type: application/json" \
-d '{
"type": "http", "name": "Магазин", "url": "https://example.ru/",
"interval_sec": 300, "expected_status": "200-299", "keyword_present": "Корзина",
"location_ids": [1, 2], "confirm_locations": 2, "contact_ids": [5]
}'
Ответ: { "ok": true, "monitor": { "id": 42, "state": "pending", ... } }. Ошибки возвращаются как { "ok": false, "error": "validation", "fields": {...} } с кодом 422.
Поля по типам
Полный список полей каждого типа отдаёт GET /api/v1/types. Общие поля: name, interval_sec, timeout_ms, location_ids[], confirm_locations, fail_threshold, recover_threshold, notify_repeat_min, notify_repeat_max, notify_recovery, tags, contact_ids[], contact_delay{id: минуты}.
Сайт (HTTP/HTTPS) (http)
url*, method, expected_status, max_response_ms, keyword_present, keyword_absent, size_min, size_max, number_regex, number_min, number_max, follow_redirects, expected_final_url, user_agent, referer, headers, body, content_type, auth.user, auth.pass, ignore_tls_errors, ip_familyСодержимое страницы (content)
url*, ignore_regex, user_agent, auth.user, auth.passPING (ICMP) (ping)
host*, count, max_loss_pct, max_avg_ms, ip_familyTCP-порт (tcp)
host*, port*, tls, ip_family, send, banner_regexDNS-записи (dns)
dns_name*, rrtype, nameserver, expected, matchSSL-сертификат (ssl)
host*, port, days_warn, check_chain, check_hostname, alert_on_changeСрок регистрации домена (domain)
domain*, days_warnSMTP-сервер (smtp)
host*, port, tls, user, pass, banner_regexPOP3-сервер (pop3)
host*, port, tls, user, passIMAP-сервер (imap)
host*, port, tls, user, passFTP-сервер (ftp)
host*, port, tls, user, passMySQL / MariaDB (mysql)
host*, port, tls, user*, pass, database, query, expect_rows_minPostgreSQL (postgres)
host*, port, tls, user*, pass, database, query, expect_rows_minРесурсы сервера (CPU/RAM/HDD) (resources)
url*, secret, cpu_max, ram_max, disk_max, load_max, ignore_tls_errorsHeartbeat (cron-задачи, бэкапы) (heartbeat)
grace_secЧёрные списки и Роскомнадзор (blacklist)
target*, rkn, gsb, listsWebhook-уведомления
Контакт типа Webhook получает POST с JSON { event, monitor, incident, ... } и заголовками X-Notifar-Event, X-Notifar-Signature: sha256=HMAC(secret, body). События: down, up, repeat, ssl_expiring, ssl_changed, domain_expiring, domain_expired, content_changed, blacklisted, test.
Heartbeat
# в конце cron-задачи curl -fsS -m 10 https://notifar.io/hb/ВАШ_ТОКЕН > /dev/null