Skip to content
cloudhostDocs
API reference

Realtime

Live messages to browsers on channels, with presence. Publish from a function binding, the API, the CLI or MCP; a browser connects with a short-lived token signed with the project's key. Nothing is created first and no history is kept; every preview of a project shares one set of channels.

GET/v1/live

A sign-in for the live connection that pushes changes#

The dashboard keeps one live connection per browser tab and is told when something it shows changes (a build, a deployment, a run, a notification, a new minute of numbers), instead of asking again on a timer. This answers where it connects and a short-lived sign-in for it, sent as the connection's first message, never in its address: {"type": "auth", "token"}. A session's sign-in works only from the dashboard; a key's only outside a browser. It reaches the topics of the caller's team, or, for a member limited to some projects (or a project's Agent key), those projects' only; available: false when live connections are not served here.

Credential
An API key or a dashboard session
Roles
Any role

Response

200LiveConnection

  • availablebooleanrequired

    whether live connections are served here; when false nothing else is set

  • urlstring

    where the connection goes

  • tokenstring

    the sign-in, sent as the first message {"type":"auth","token":"<token>"}; renewed on the same connection before it ends ({"type":"token","token"})

  • expiresstring (date-time)

    when the sign-in ends

  • userstring

    who the connection is for (p:<person id> or k:<key id>); a person's own topics start me/<user>/

  • teamstring

    the team whose topics it reaches (t/<team>/...)

  • max_topicsinteger

    topics one connection may follow at once

  • max_connsinteger

    live connections one person (or key) may keep open at once

Errors

StatusDescription
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden (a build's key)
500internal: an unexpected failure

Example

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

Whether realtime is served, and where browsers connect#

available: whether channels are served here; socket_url, where a browser connects with ?token=; the limits; key_secret, the secret in every project's secrets that signs its browsers' tokens; token_format.

Credential
An API key or a dashboard session
Roles
Any role

Response

200RealtimeConfig

  • availableboolean

    whether channels are served here

  • socket_urlstring

    where a browser connects, with ?token=<token>

  • limitsRealtimeLimits
  • key_secretstring

    the secret in each environment of a project's secrets that signs its browsers' tokens

  • token_formatstring

    <payload>.<signature>, both base64url without padding; the payload is the JSON {"channel", "user", "exp", "kid": "<project id>:<production|preview|development>", "jti"?}, the signature HMAC-SHA256 with the key over the payload's bytes

Errors

StatusDescription
401unauthorized: missing, invalid, expired or revoked credential
500internal: an unexpected failure

Example

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

The team's realtime usage#

Messages written to browsers, connected minutes and the peak of connections per day (Tehran's), every project's or one project's with project, and this month so far.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • daysintegerquery

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

    1–90 · default 30

Response

200RealtimeUsage

  • daysobject[]
  • monthRealtimeMonth
  • fromstring (date-time)
  • tostring (date-time)

Errors

StatusDescription
400Bad request: bad_param
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

Example

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

A project's realtime settings#

Where its browsers connect, the secret that signs their tokens, the limits, this month's use and how many channels were used in the last hour (every environment).

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any

Response

200RealtimeSettings

  • projectobject
  • availableboolean
  • socket_urlstring
  • limitsRealtimeLimits
  • key_secretstring
  • token_formatstring
  • usageobject
  • channels_activeinteger

    channels with a connection or a message in the last hour, every environment

Errors

StatusDescription
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

Example

curl "https://api.ibel.ai/v1/projects/my-api/realtime" \
  -H "Authorization: Bearer $KEY"
GET/v1/realtime/channels

The team's channels of the last hour#

Every project's channels with a connection or a message in the last hour (the team view), each with its project, by project name then channel; one project's with project. environment: with project, one of its environments; without, production, development or preview (every preview shares one set of channels).

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • environmentstringquery

    only this environment's: production, development, preview or a preview's preview-<label> (every environment's without it)

  • prefixstringquery

    only channels whose name starts with this

  • any
  • any

Response

200object

  • channelsRealtimeChannel[]
    • namestring
    • environmentstring

      the environment's kind; every preview of the project shares one set of channels

      one of production, preview, development

    • connectionsinteger

      sockets open in the last minute counted

    • messages_1hinteger

      messages written to browsers in the last hour

    • last_message_atstring (date-time)
    • last_seen_atstring (date-time)
    • projectProjectRef
  • next_cursorstring

Errors

StatusDescription
400Bad request: bad_param, bad_cursor, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found (no such project)
500internal: an unexpected failure

Example

curl "https://api.ibel.ai/v1/realtime/channels" \
  -H "Authorization: Bearer $KEY"
GET/v1/realtime/table-changes

The team's table changes#

Every project's databases with table changes set (the team view), each with its project, by project name then database; one project's with project.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • any
  • any

Response

200object

  • readersRealtimeTableChangeReader[]
    • databasestring

      the database's name

    • enabledboolean
    • tablesobject[]
    • statestring

      running: sending changes; stopped: off, or not started yet; failed: see error

      one of running, stopped, failed

    • errorstring
    • positionstring

      opaque, grows with every change sent; null before the first

    • created_atstring (date-time)
    • updated_atstring (date-time)
    • projectProjectRef
  • next_cursorstring

Errors

StatusDescription
400Bad request: bad_param, bad_cursor
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found (no such project)
500internal: an unexpected failure

Example

curl "https://api.ibel.ai/v1/realtime/table-changes" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/realtime/channels

A project's channels of the last hour#

Channels with a connection or a message in the last hour, by name; every environment's, or one environment's with environment (every preview shares one set of channels).

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • environmentstringquery

    only this environment's: production, development, or a preview's preview-<label> (every environment's without it)

  • prefixstringquery

    only channels whose name starts with this

  • any
  • any

Response

200object

  • channelsRealtimeChannel[]
    • namestring
    • environmentstring

      the environment's kind; every preview of the project shares one set of channels

      one of production, preview, development

    • connectionsinteger

      sockets open in the last minute counted

    • messages_1hinteger

      messages written to browsers in the last hour

    • last_message_atstring (date-time)
    • last_seen_atstring (date-time)
  • next_cursorstring

Errors

StatusDescription
400Bad request: bad_param, bad_cursor, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

Example

curl "https://api.ibel.ai/v1/projects/my-api/realtime/channels" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/realtime/channels/{channel}

One channel#

A channel of the environment asked for, with its numbers of the last hour.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • any
  • anyrequired

Response

200RealtimeChannel

  • namestring
  • environmentstring

    the environment's kind; every preview of the project shares one set of channels

    one of production, preview, development

  • connectionsinteger

    sockets open in the last minute counted

  • messages_1hinteger

    messages written to browsers in the last hour

  • last_message_atstring (date-time)
  • last_seen_atstring (date-time)

Errors

StatusDescription
400Bad request: bad_channel, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found (no such project, or nothing on the channel in the last hour)
500internal: an unexpected failure

Example

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

Publish to a channel#

Sends one message, or up to batch in order, to every browser connected to the channel in the environment asked for. Nothing is kept: a browser that is not connected does not get it.

Credential
An API key or a dashboard session
Roles
owner, admin, developer

Parameters

  • any
  • any
  • anyrequired

Request bodyapplication/json

message or messages, not both

  • messageany

    any JSON value, at most message_bytes (65,536) as JSON

  • messagesany[]

    1 to batch messages, each any JSON value, published one after another

    1–100 items

Response

202object

  • publishedinteger

    how many messages were published

  • deliveredinteger

    the browser connections the messages were written to

Errors

StatusDescription
400Bad request: bad_channel, bad_message, 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
500internal: an unexpected failure
503Unavailable: realtime_unavailable (try again shortly)

Example

curl -X POST "https://api.ibel.ai/v1/projects/my-api/realtime/channels/channel/messages" \
  -H "Authorization: Bearer $KEY" \
  -d '{"message":null,"messages":[null]}'
GET/v1/projects/{project}/realtime/channels/{channel}/presence

Who is on a channel#

The user ids connected to the channel now, and the number of connections.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • any
  • anyrequired

Response

200RealtimePresence

  • channelstring
  • environmentstring

    one of production, preview, development

  • usersstring[]

    the user ids connected now, from their tokens

  • connectionsinteger

    the sockets open on the channel now

Errors

StatusDescription
400Bad request: bad_channel, bad_environment
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure
503Unavailable: realtime_unavailable (try again shortly)

Example

curl "https://api.ibel.ai/v1/projects/my-api/realtime/channels/channel/presence" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/realtime/table-changes

The databases' table changes#

The project's databases with table changes set: which tables go to which channels, and whether they are being sent.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • any
  • any

Response

200object

  • readersRealtimeTableChangeReader[]
    • databasestring

      the database's name

    • enabledboolean
    • tablesobject[]
    • statestring

      running: sending changes; stopped: off, or not started yet; failed: see error

      one of running, stopped, failed

    • errorstring
    • positionstring

      opaque, grows with every change sent; null before the first

    • created_atstring (date-time)
    • updated_atstring (date-time)
  • next_cursorstring

Errors

StatusDescription
400Bad request: bad_param, bad_cursor
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

Example

curl "https://api.ibel.ai/v1/projects/my-api/realtime/table-changes" \
  -H "Authorization: Bearer $KEY"
PUT/v1/projects/{project}/realtime/table-changes/{database}

Switch table changes on for a database#

Sends every committed insert, update and delete of the chosen tables to their channels (the project's production channels; the database's main branch), each change once, in commit order. Off by default. While it is on, the database stays awake (it no longer sleeps when unused) and is billed per hour as an always-on database (meter realtime_table_change_hours), so the body must say acknowledge_always_on: true. Switching it on restarts the database once; open connections reconnect. Called again, it changes the tables.

Credential
An API key or a dashboard session
Roles
owner, admin, developer

Parameters

  • any
  • databasestringpathrequired

    the database's name in the project (any case) or its id

Request bodyapplication/json

  • tablesobject[]required

    1–… items

    • namestringrequired

      schema.table, or a table of public; checked against the database

    • eventsstring[]

      which changes to send (default all three); updates and deletes need the table to have a primary key

    • channelstring

      the channel they go to (default the table's name; schema.table outside public)

  • acknowledge_always_onbooleanrequired

    must be true: the database stays awake and is billed per hour as an always-on database

Response

200RealtimeTableChangeReader

  • databasestring

    the database's name

  • enabledboolean
  • tablesobject[]
  • statestring

    running: sending changes; stopped: off, or not started yet; failed: see error

    one of running, stopped, failed

  • errorstring
  • positionstring

    opaque, grows with every change sent; null before the first

  • created_atstring (date-time)
  • updated_atstring (date-time)

Errors

StatusDescription
400Bad request: bad_table (no such table, or no primary key for updates and deletes), acknowledge_required, bad_channel, bad_json
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden
404Not found: not_found
500internal: an unexpected failure
503Unavailable: realtime_unavailable (try again shortly)

Example

curl -X PUT "https://api.ibel.ai/v1/projects/my-api/realtime/table-changes/shop" \
  -H "Authorization: Bearer $KEY" \
  -d '{"tables":[{"name":"my-api","events":["insert"],"channel":"…"}],"acknowledge_always_on":true}'
DELETE/v1/projects/{project}/realtime/table-changes/{database}

Switch table changes off for a database#

Browsers get no more of its changes, and the database sleeps again when unused.

Credential
An API key or a dashboard session
Roles
owner, admin, developer

Parameters

  • any
  • databasestringpathrequired

    the database's name in the project (any case) or its id

Response

200object

  • databasestring
  • enabledboolean

    one of false

Errors

StatusDescription
401unauthorized: missing, invalid, expired or revoked credential
403Not allowed: forbidden
404Not found: not_found
500internal: an unexpected failure

Example

curl -X DELETE "https://api.ibel.ai/v1/projects/my-api/realtime/table-changes/shop" \
  -H "Authorization: Bearer $KEY"
GET/v1/projects/{project}/realtime/usage

A project's realtime usage#

Messages written to browsers, connected minutes and the peak of connections per day (Tehran's), and this month so far with the hours its databases sent table changes.

Credential
An API key or a dashboard session
Roles
Any role

Parameters

  • any
  • daysintegerquery

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

    1–90 · default 30

Response

200RealtimeUsage

  • daysobject[]
  • monthRealtimeMonth
  • fromstring (date-time)
  • tostring (date-time)

Errors

StatusDescription
400Bad request: bad_param
401unauthorized: missing, invalid, expired or revoked credential
404Not found: not_found
500internal: an unexpected failure

Example

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