Sign Up
Loading...

Realtime commands

Use these commands in endpoints, server functions and events to connect authenticated customers and send live notifications. Start with Realtime channels to create a channel and choose its audience.

Authorize Realtime

Issue a one-use connection ticket for the signed-in customer. Call it from a customer-authenticated endpoint, or from a function called by that endpoint. A scheduled event and the editor's Test runner have no customer login and cannot issue a customer's ticket.

Choose channel and set Return as. The result contains ticket, expiresAt, channel and mode. Return it to that customer's app. The ticket expires after 60 seconds and must be sent in the first connection message. Get a new ticket for every new connection; keep it out of connection addresses, logs and shared data.

The Private to each user audience follows the authenticated customer's identity. Clients cannot select a different customer's identity.

Publish Realtime Message

Send a notification using channel, event and data. For a private channel, also provide recipient_id, the destination customer's ID. A shared channel does not accept a private recipient.

For example, after saving an order's new status, publish event order_ready with data containing the order ID and status. Send it to the order owner's customer ID when using a private channel.

The result is true after submission. It is not a delivery receipt. Disconnected apps do not receive past messages, so save important changes in the database and reload them when reconnecting.

Testing and limits

For a full connection check, sign in with a synthetic customer in your Dev workspace and call its authenticated API endpoint. The editor's Test runner cannot issue tickets. Publish commands from editor tests use a separate audience and cannot reach customers connected to real API calls. Messages must fit within 64 KiB including event details. A workspace allows up to 120 publish attempts per minute and a customer up to 20 ticket requests per minute.

These commands run in server workflows. They do not let an app publish directly through its receiving connection. Channel settings and the customer's current permissions are checked before access is granted.

Related Topics

Math

Twidget offers a variety of commands to manipulate numbers. Below are the math commands available, along with their descriptions, inputs, and outputs. Sum. Description: Adds together a list of numbers and returns the sum. - Inputs: - `numbers`: A list of numbers to be added together. - Output: A sin...

Local Storage

Twidget provides a set of local storage commands that enable interaction with the browser’s `localStorage` API through a no-code interface. These commands are useful for storing, retrieving, and managing key-value data persistently within the current domain context. Purpose. These commands abstract ...

Process PDF files

Inspect a PDF, combine documents, copy selected pages into a separate file, or read existing text. Find PDF information, Merge PDFs, Select PDF pages and Extract PDF text under File Manager when adding a command to a server workflow. Use a file containing its contents. Choose an uploaded file, an ea...

Date

Twidget offers a variety of commands to manipulate date objects. Below are the available commands along with their respective descriptions, inputs, and outputs. Current Date. Description: Returns the current date and time. Output: - Type: DATE Add Time. Description: Returns the date plus a specified...

Loops

In Twidget, loops allow you to execute commands multiple times, either based on a condition or through a set number of iterations. Loops can also be nested, meaning you can run loops within other loops, creating complex logic for your tasks. List Loop. The `List Loop` command enables you to loop thr...