رفتن به محتوا
cloudhostمستندات
مرجع API

تاپیک‌های اعلان

اعلان به گوشی و دسکتاپ کاربران خودتان، با عضویت در تاپیک.

توضیح هر مسیر به انگلیسی است، همان متنی که مرجع از کد ساخته می‌شود. مسیرها، نام فیلدها و کدها همان‌اند که در درخواست می‌نویسید.
GET/v1/notifications/config

Whether notifications are served, and for which app#

available: whether topics can be published to here; phone_channel: whether each person can get the notification centre's events on their phone; server and app (the notifications app a receiver installs, and its stores); the plan's limits; key_secret, the secret in every project's secrets that signs its devices' tokens.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پاسخ

200object

  • availableboolean
  • phone_channelboolean
  • serverstring
  • appobject
  • limitsNotificationLimits
  • key_secretstring

خطاها

وضعیتتوضیح
401unauthorized: missing, invalid, expired or revoked credential
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/notifications/config" \
  -H "Authorization: Bearer $KEY"
GET/v1/notifications/topics

The team's topics#

Every project's topics by name, or one project's with project, each with its numbers; the plan's limits with topics_used.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • any
  • any

پاسخ

200object

  • topicsNotificationTopic[]
  • next_cursorstring
  • limitsNotificationLimits
  • availableboolean

خطاها

وضعیتتوضیح
400Bad request: bad_param, bad_cursor
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/notifications/topics" \
  -H "Authorization: Bearer $KEY"
GET/v1/notifications/usage

The team's notifications usage#

Messages published and deliveries to devices per day (Tehran's), every project's or one project's with project, and their cost at list price once the meters have a price (priced).

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • daysintegerکوئری

    how many days back: 1 to 90 (default 30)

پاسخ

200NotificationUsage

  • daysinteger
  • fromstring (date-time)
  • tostring (date-time)
  • publishedinteger
  • deliveredinteger
  • per_dayobject[]
  • metersobject[]
  • list_rialsinteger
  • pricedboolean

    false until the owner sets the meters' prices

خطاها

وضعیتتوضیح
400Bad request: bad_param
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/notifications/usage" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/notifications/topics

A project's topics#

The project's topics by name, each with its numbers in production.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • any
  • any

پاسخ

200object

  • topicsNotificationTopic[]
    • idstringالزامی

      nt_ and 16 hex

    • namestringالزامی
    • descriptionstring
    • projectobjectالزامی
    • environmentstring

      the environment the numbers are for (one topic's answer)

    • created_atstring (date-time)الزامی
    • subscribersinteger

      devices subscribed, the edges' last count (null before the first)

    • published_24hinteger
    • delivered_24hinteger
  • next_cursorstring

خطاها

وضعیتتوضیح
400Bad request: bad_param, bad_cursor
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/topics" \
  -H "Authorization: Bearer $KEY"
POST/v1/projects/{project}/notifications/topics

Create a topic#

A topic: a name in the project; a message published to it reaches every device subscribed to it. A preview and development get their own when they first use it.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده

پارامترها

  • any

بدنهٔ درخواستapplication/json

  • namestringالزامی

    letters, digits, - and _, 1 to 64 characters; unique in the project whatever its case

  • descriptionstring

    at most 300 characters

پاسخ

201NotificationTopic

  • idstringالزامی

    nt_ and 16 hex

  • namestringالزامی
  • descriptionstring
  • projectobjectالزامی
  • environmentstring

    the environment the numbers are for (one topic's answer)

  • created_atstring (date-time)الزامی
  • subscribersinteger

    devices subscribed, the edges' last count (null before the first)

  • published_24hinteger
  • delivered_24hinteger

خطاها

وضعیتتوضیح
400Bad request: bad_name, bad_setting, bad_json
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden, limit
404Not found: not_found
409Conflict: name_taken
500internal: an unexpected failure

نمونه

curl -X POST "https://api.ibel.ai/v1/projects/my-api/notifications/topics" \
  -H "Authorization: Bearer $KEY" \
  -d '{"name":"my-api"}'
GET/v1/projects/{project}/notifications/topics/{topic}

A topic#

The topic with its numbers in the environment asked for: subscribers (devices subscribed, the edges' last count; null before the first), messages published and delivered in the last 24 hours.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • anyالزامی

پاسخ

200NotificationTopic

  • idstringالزامی

    nt_ and 16 hex

  • namestringالزامی
  • descriptionstring
  • projectobjectالزامی
  • environmentstring

    the environment the numbers are for (one topic's answer)

  • created_atstring (date-time)الزامی
  • subscribersinteger

    devices subscribed, the edges' last count (null before the first)

  • published_24hinteger
  • delivered_24hinteger

خطاها

وضعیتتوضیح
400Bad request: bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic" \
  -H "Authorization: Bearer $KEY"
DELETE/v1/projects/{project}/notifications/topics/{topic}

Delete a topic#

Deletes the topic with its environments' own: nothing more is published to it; devices keep what they received. A session needs a step-up.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده
تایید دوم
با نشست داشبورد، عامل دوم در ۱۰ دقیقهٔ اخیر لازم است؛ کلید API نیازی ندارد.

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

پاسخ

200object

  • idstring
  • namestring
  • deletedboolean

خطاها

وضعیتتوضیح
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden, step_up_required
404Not found: not_found
500internal: an unexpected failure

نمونه

curl -X DELETE "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic" \
  -H "Authorization: Bearer $KEY"
PATCH/v1/projects/{project}/notifications/topics/{topic}

Change a topic#

Its description.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

بدنهٔ درخواستapplication/json

  • descriptionstring

    at most 300 characters

پاسخ

200NotificationTopic

  • idstringالزامی

    nt_ and 16 hex

  • namestringالزامی
  • descriptionstring
  • projectobjectالزامی
  • environmentstring

    the environment the numbers are for (one topic's answer)

  • created_atstring (date-time)الزامی
  • subscribersinteger

    devices subscribed, the edges' last count (null before the first)

  • published_24hinteger
  • delivered_24hinteger

خطاها

وضعیتتوضیح
400Bad request: bad_setting, nothing, bad_json
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden
404Not found: not_found
500internal: an unexpected failure

نمونه

curl -X PATCH "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic" \
  -H "Authorization: Bearer $KEY" \
  -d '{"description":"…"}'
GET/v1/projects/{project}/notifications/topics/{topic}/messages

The kept messages#

What the topic keeps now for devices that were offline, newest first (50 a page, at most the plan's recent).

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • anyالزامی
  • any
  • any

پاسخ

200object

  • topicstring
  • environmentstring
  • messagesNotificationMessage[]
  • next_cursorstring
  • keep_hoursinteger

خطاها

وضعیتتوضیح
400Bad request: bad_param, bad_cursor, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure
503Unavailable: notifications_unavailable

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/messages" \
  -H "Authorization: Bearer $KEY"
POST/v1/projects/{project}/notifications/topics/{topic}/messages

Publish a message#

Sends a message to every device subscribed to the topic in the environment asked for, now or at at. A device that is offline gets it when it reconnects, within the plan's keep_hours.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • anyالزامی

بدنهٔ درخواستapplication/json

  • textstringالزامی

    the message, at most the plan's message_bytes (4096 at the start)

  • titlestring

    one line, at most title_chars

  • priorityinteger

    1 (lowest) to 5 (urgent); 3 is the default

    1–5

  • tagsstring[]

    at most tags words of letters, digits, _, + and -

  • clickstring

    an https address the notification opens when tapped

  • actionsNotificationAction[]

    0–3 items

  • atstring (date-time)

    deliver at this time instead of now (10 seconds to 72 hours ahead)

  • delay_sinteger

    or deliver this many seconds from now

پاسخ

202object

  • idstring
  • topicstring
  • environmentstring
  • atstring (date-time)
  • scheduledboolean
  • acceptedboolean

    the edge that holds the topic took it; not a promise that a device received it

خطاها

وضعیتتوضیح
400Bad request: bad_message, bad_delay, bad_environment, bad_json
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden
404Not found: not_found
413Too large: message_too_large, too_large
429Too many: rate_limited
500internal: an unexpected failure
503Unavailable: notifications_unavailable

نمونه

curl -X POST "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/messages" \
  -H "Authorization: Bearer $KEY" \
  -d '{"text":"…"}'
GET/v1/projects/{project}/notifications/topics/{topic}/tokens

The topic's subscribe tokens#

The tokens made for the topic (by this API, the dashboard, the CLI or the tools) and not expired, newest first, revoked ones marked. Tokens a function signs itself with NOTIFICATIONS_KEY are not here; rotating that secret ends them.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • environmentstringکوئری

    one environment's tokens only: production, development or preview-<branch>; left out, every environment's

  • any
  • any

پاسخ

200object

  • topicstring
  • tokensNotificationToken[]
  • next_cursorstring

خطاها

وضعیتتوضیح
400Bad request: bad_param, bad_cursor, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/tokens" \
  -H "Authorization: Bearer $KEY"
POST/v1/projects/{project}/notifications/topics/{topic}/tokens

A subscribe token#

A device's right to subscribe to the topic in the environment asked for, until expires_at: the token, the server and the device's topic to enter in the notifications app, and link, which a QR code carries. Signed with the project's NOTIFICATIONS_KEY (in its secrets, one value per environment), so a function can make the same tokens itself; rotating that secret ends every token signed before. jti names this token to revoke it (DELETE …/tokens/{jti}).

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • anyالزامی

بدنهٔ درخواستapplication/json

  • ttl_sinteger

    how long the token works, 60 seconds to the plan's token_max_s (default token_default_s, an hour)

پاسخ

201NotificationSubscribe

  • serverstringالزامی
  • device_topicstringالزامی

    the topic's name for devices (never its name in the project)

  • tokenstringالزامی

    <payload>.<signature>, base64url: the payload is the JSON {topics, exp, kid, jti} (the device topics, when it ends in Unix seconds, the key it is signed with, its own id); the signature is HMAC-SHA256 with the key over the payload's bytes

  • expires_atstring (date-time)الزامی
  • linkstringالزامی

    what the QR code carries; the app adds the topic from it

  • jtistring

    the token's id, to revoke it

  • topicstring
  • environmentstring
  • key_secretstring

خطاها

وضعیتتوضیح
400Bad request: bad_ttl, bad_environment, bad_json
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden
404Not found: not_found
500internal: an unexpected failure
503Unavailable: unavailable

نمونه

curl -X POST "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/tokens" \
  -H "Authorization: Bearer $KEY" \
  -d '{"ttl_s":1}'
DELETE/v1/projects/{project}/notifications/topics/{topic}/tokens

Revoke every token of the topic#

Revokes every token of the topic that is not expired (every environment's, or one environment's with environment): devices on them are refused from the next minute and their open connections end; a device subscribes again with a new token. A session needs a step-up.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده
تایید دوم
با نشست داشبورد، عامل دوم در ۱۰ دقیقهٔ اخیر لازم است؛ کلید API نیازی ندارد.

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • environmentstringکوئری

    one environment's tokens only: production, development or preview-<branch>; left out, every environment's

پاسخ

200object

  • topicstring
  • environmentstring

    the environment asked for; null for every environment

  • revokedinteger

    how many tokens were revoked now

خطاها

وضعیتتوضیح
400Bad request: bad_environment
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden, step_up_required
404Not found: not_found
500internal: an unexpected failure

نمونه

curl -X DELETE "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/tokens" \
  -H "Authorization: Bearer $KEY"
DELETE/v1/projects/{project}/notifications/topics/{topic}/tokens/{jti}

Revoke a subscribe token#

Revokes one token of the topic, by its jti: devices on it are refused from the next minute, until it would have expired, and their open connections end. Revoking it again gives the same answer. A session needs a step-up.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
مالک، ادمین، توسعه‌دهنده
تایید دوم
با نشست داشبورد، عامل دوم در ۱۰ دقیقهٔ اخیر لازم است؛ کلید API نیازی ندارد.

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • jtistringمسیرالزامی

    the token's id (16 hex digits), as jti in its payload and in the answer that made it

پاسخ

200object

  • topicstring
  • jtistring
  • revokedboolean

خطاها

وضعیتتوضیح
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden, step_up_required
404Not found: not_found (no such token, or it has expired)
500internal: an unexpected failure

نمونه

curl -X DELETE "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/tokens/jti" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/notifications/topics/{topic}/usage

A topic's usage#

Messages published and deliveries per day, the topic's and its environments' own.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • topicstringمسیرالزامی

    the topic's name (any case) or id (nt_…)

  • daysintegerکوئری

    how many days back: 1 to 90 (default 30)

پاسخ

200NotificationUsage

  • daysinteger
  • fromstring (date-time)
  • tostring (date-time)
  • publishedinteger
  • deliveredinteger
  • per_dayobject[]
  • metersobject[]
  • list_rialsinteger
  • pricedboolean

    false until the owner sets the meters' prices

خطاها

وضعیتتوضیح
400Bad request: bad_param
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/topics/topic/usage" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/notifications/usage

A project's notifications usage#

Messages published and deliveries per day, every topic of the project.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any
  • daysintegerکوئری

    how many days back: 1 to 90 (default 30)

پاسخ

200NotificationUsage

  • daysinteger
  • fromstring (date-time)
  • tostring (date-time)
  • publishedinteger
  • deliveredinteger
  • per_dayobject[]
  • metersobject[]
  • list_rialsinteger
  • pricedboolean

    false until the owner sets the meters' prices

خطاها

وضعیتتوضیح
400Bad request: bad_param
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/usage" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/notifications/settings

A project's notifications settings#

The secret that signs its devices' tokens (key.secret, in each environment of the project's secrets), how many topics it has, the server and the plan's limits.

دسترسی
کلید API یا نشست داشبورد
نقش‌ها
همهٔ نقش‌ها

پارامترها

  • any

پاسخ

200object

  • projectobject
  • availableboolean
  • serverstring
  • topicsinteger
  • keyobject
  • limitsNotificationLimits

خطاها

وضعیتتوضیح
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

نمونه

curl "https://api.ibel.ai/v1/projects/my-api/notifications/settings" \
  -H "Authorization: Bearer $KEY"