enableExternalSessionSync on chat widgets that need to receive these
turns. While that option is enabled, the widget checks for persisted updates
only when the tab is visible and the interactive session is idle. The polling
interval defaults to five seconds and can be changed with
externalSessionSyncIntervalMs.
Endpoint
- The platform access token must belong to the session’s tenant.
caylex_api_keymust identify the session’s navigator instance.user_emailmust identify the end user who owns the widget session.
404 rather than revealing a session when any scope does not
match. Playground and background-task sessions cannot receive programmatic
chat turns.
Response
This is a synchronous endpoint: it waits for the agent turn to finish.409.
Retry after that turn finishes; do not submit concurrent turns to the same
session.
Capture the Session ID
The preferred approach is to save the ID emitted by the chat widget’sonSessionCreated callback and associate it with the corresponding user in
your application. If your application already has a mapped session, pass it
back through initialSessionId; otherwise, pass null to explicitly create a
new session:
savedCaylexSessionId should be the mapped session
ID or null when no mapping exists. Do not render the widget while the lookup
is still pending: null intentionally creates a new session.
See Session Management for restoration behavior,
session-change callbacks, and host-managed session examples.
If you did not capture the ID, list recent sessions from your backend:
navigator_instance_id, project_id, and timestamp filters to narrow the
results. Session summaries include session_id, session_name, created_at,
and last_message_at. For complete lookup and export examples, see
Get All Assistant Session Messages.
Example
- Python
- TypeScript
send_session_message.py