Skip to main content
A thread session object is an append-only stream of structured items. The envelope marks the object as a thread and holds optional metadata about it; items themselves live in a separate store with their own read/write commands.

Envelope

A first post creates the envelope, so uploading one is only for giving the thread a name or a description of its own. To upload one, use upload_session_object and set value.type to "thread":
The thread object inside value carries two optional sub-fields: The envelope is read back as-is via download_session_object. No items are included in that response — items are fetched exclusively through the thread item commands.

Thread Items

Each item posted to a thread has the following shape:

Source

An item records the source of the write that posted it, beside user_id and client: the same object the thread.item_posted event carries. The platform stamps it, and no request can set it. A worker’s items carry the worker’s client tag in client, like any other REST write.

Role

metadata.role is declared by whoever posts: request (someone should act on this), reply (an answer; nobody has to act), note (bookkeeping, such as a listener’s receipt), or any other role a flow names, kept as written. A flow selects what it reads by role (Selecting a History). result is reserved.

Content Blocks

Each entry in content is an object with a type discriminator. An item takes the seven blocks of a message (Data Types); the first three are below, and the checks for the rest are those of a message value: Block order is significant. A file block may sit between two text blocks, and that position is preserved end to end: a rendering surface shows the file where it appears in the message, and the BlobHub Worker delivers an image to a coding agent at that same point rather than after all the text. An item holds up to 262,144 bytes (256 KiB), measured on the whole item. A longer item is refused with thread_item_too_large; post_session_thread_item never splits an item. data.thread posts a message too long for one item as consecutive items, each marked metadata.part, and reads them back as one message. A listing or get_session_thread_item returns the stored items, so each part is its own item there. Items are immutable once posted. There is no per-item update or delete command. To remove all items, delete the envelope — this cascades and removes every item in the thread.

Operations

A post to an alias that holds nothing creates the thread, so no envelope is needed first; two first posts at once both land in one thread. An alias that holds another kind of object is still refused with invalid_thread_envelope, and a post never replaces an envelope. The two read commands require the alias of an existing thread envelope, and answer invalid_thread_envelope when it does not exist or its value.type is not "thread".

Events

After each post_session_thread_item call the server emits a thread.item_posted event. Beside the record’s source, it carries the thread and the item. A first post to an empty alias raises object.written for the new envelope before it:
An item posted with a client stores it: the item in a thread listing, in get_session_thread_item and in the event’s item block all carry the same value as source.client. The item block’s type and role come from the item’s metadata and are optional, as are parent_id and client. The item’s own source is the event’s, and the item block does not repeat it. To catch up on new items, pass created_since to List Session Thread Items, or fetch the posted item by item.id with Get Session Thread Item. To react to the event with no client connected, use a declared listener.

See also