Skip to main content
GET
/
session
/
{session_id}
/
messages
Python
from acontext import AcontextClient

client = AcontextClient(api_key='sk_project_token')

# Get messages from session
messages = client.sessions.get_messages(
    session_id='session-uuid',
    limit=50,
    format='acontext',
    time_desc=True
)
for message in messages.items:
    print(f"{message.role}: {message.parts}")
{
  "code": 123,
  "error": "<string>",
  "msg": "<string>",
  "data": {
    "has_more": true,
    "items": [
      {
        "created_at": "<string>",
        "id": "<string>",
        "meta": {},
        "parent_id": "<string>",
        "parts": [
          {}
        ],
        "role": "<string>",
        "session_id": "<string>",
        "session_task_process_status": "<string>",
        "task_id": "<string>",
        "updated_at": "<string>"
      }
    ],
    "next_cursor": "<string>",
    "public_urls": {}
  }
}

Authorizations

Authorization
string
header
required

Project Bearer token (e.g., "Bearer sk-ac-xxxx")

Path Parameters

session_id
string<uuid>
required

Session ID

Query Parameters

limit
integer

Limit of messages to return. Max 200. If limit is 0 or not provided, all messages will be returned.

WARNING! Use limit only for read-only/display purposes (pagination, viewing). Do NOT use limit to truncate messages before sending to LLM as it may cause tool-call and tool-result unpairing issues. Instead, use the token_limit edit strategy in edit_strategies parameter to safely manage message context size.

cursor
string

Cursor for pagination. Use the cursor from the previous response to get the next page.

with_asset_public_url
string

Whether to return asset public url, default is true

format
enum<string>

Format to convert messages to: acontext (original), openai (default), anthropic, gemini.

Available options:
acontext,
openai,
anthropic,
gemini
time_desc
string

Order by created_at descending if true, ascending if false (default false)

edit_strategies
string

JSON array of edit strategies to apply before format conversion

Response

200 - application/json

OK

code
integer
error
string
msg
string
data
object