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, default 20. Max 200.

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.

Available options:
acontext,
openai,
anthropic
time_desc
string

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

Response

200 - application/json

OK

code
integer
error
string
msg
string
data
object