List, filter, and poll messages on a session or a single thread.
Two endpoints share the same paginated response shape and query parameters. Use the first to list every message in a session; use the second to scope to a single thread (for example, to poll the latest follow-up’s reply).
GET /rest/v1/sessions/{session_id}/messagesGET /rest/v1/sessions/{session_id}/threads/{thread_id}/messages
Results are sorted by created_at (newest first by default). Soft-deleted messages are excluded.
// All messages on the session.const url = `https://api.blocks.team/rest/v1/sessions/${sessionId}/messages?type=final_message&role=assistant`;// Or scope to a specific thread:// const url = `https://api.blocks.team/rest/v1/sessions/${sessionId}/threads/${threadId}/messages?type=final_message&role=assistant`;const page = await fetch(url, { headers: { Authorization: `ApiKey ${process.env.BLOCKS_API_KEY}` },}).then((r) => r.json());
Cursor for incremental polling, in epoch seconds. Returns only messages whose ts is strictly greater than this value. Use _links.new_messages.href from the previous page to get a pre-built URL with this cursor already set.
Pre-built URL with ?gts=<cursor> appended. Poll this URL to receive only messages newer than the latest one in this page. Always present — when items is empty, the cursor is the server’s current epoch second, so the next poll returns anything created after now.