Перейти к содержанию

Публичное уведомление

Отправка уведомления всем пользователям в Liner.

Примечание

Уведомление с типом urgent автоматически открывается у пользователя в Liner, если он онлайн.


Адрес и метод

POST /v1/notification/public/


Параметры (Body)

title string
Заголовок уведомления (строка).

text string
Текст уведомления (строка).

type enum
Тип уведомления. Возможные значения: default, urgent (urgent открывается автоматически).

level enum
Уровень/стиль уведомления. Возможные значения: default, success, warning, danger.


Пример запроса

curl -X POST "https://YOUR_LINER_API_HOST/v1/notification/public/" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_API_TOKEN" \
  -d '{
    "title": "{{title}}",
    "text": "{{text}}",
    "type": "{{notification_type}}",
    "level": "{{notification_level}}"
  }'
<?php

$host = 'https://YOUR_LINER_API_HOST';
$token = 'YOUR_API_TOKEN';

$payload = [
    'title' => $title,
    'text' => $text,
    'type' => $notification_type,   // default | urgent
    'level' => $notification_level, // default | success | warning | danger
];

$ch = curl_init($host . '/v1/notification/public/');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-Api-Key: ' . $token,
    ],
    CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
    CURLOPT_TIMEOUT => 15,
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    throw new RuntimeException('cURL error: ' . curl_error($ch));
}

curl_close($ch);

echo "HTTP {$httpCode}\n";
echo $response;
const host = "https://YOUR_LINER_API_HOST";
const token = "YOUR_API_TOKEN";

const payload = {
  title: title,
  text: text,
  type: notification_type,   // default | urgent
  level: notification_level  // default | success | warning | danger
};

const res = await fetch(`${host}/v1/notification/public/`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": token
  },
  body: JSON.stringify(payload)
});

const data = await res.json();
console.log("HTTP", res.status, data);

Пример ответа

{
  "success": true,
  "message": "",
  "data": []
}