Skip to content
Letta Platform Letta Platform Letta Docs
Sign up

Send Message to Environment

client.environments.sendMessage(stringconnectionID, EnvironmentSendMessageParams { messages, agentId, conversationId } body, RequestOptionsoptions?): EnvironmentSendMessageResponse { message, success }
post/v1/environments/{connectionId}/messages

Send a message to a specific environment connection

ParametersExpand Collapse
connectionID: string
body: EnvironmentSendMessageParams { messages, agentId, conversationId }
messages: Array<UnionMember0 { client_message_id, content, role, otid } | UnionMember1 { approvals, type } >
Accepts one of the following:
UnionMember0 { client_message_id, content, role, otid }
client_message_id: string
content: string | Array<UnionMember1>
Accepts one of the following:
string
Array<UnionMember1>
text: string
type: "text"
role: "user"
otid?: string
UnionMember1 { approvals, type }
approvals: Array<UnionMember0 { status, tool_call_id, tool_return, 3 more } | UnionMember1 { approve, tool_call_id, reason, 2 more } >
Accepts one of the following:
UnionMember0 { status, tool_call_id, tool_return, 3 more }
status: "success" | "error"
Accepts one of the following:
"success"
"error"
tool_call_id: string
tool_return: string | Array<UnionMember1>
Accepts one of the following:
string
Array<UnionMember1>
text: string
type: "text"
stderr?: Array<string> | null
stdout?: Array<string> | null
type?: "tool"
UnionMember1 { approve, tool_call_id, reason, 2 more }
approve: boolean
tool_call_id: string
reason?: string | null
type?: "approval"
updated_input?: Record<string, unknown> | null
type: "approval"
agentId?: string
conversationId?: string | null
ReturnsExpand Collapse
EnvironmentSendMessageResponse { message, success }
message: string
success: boolean
Send Message to Environment
import Letta from '@letta-ai/letta-client';

const client = new Letta({
  apiKey: process.env['LETTA_API_KEY'], // This is the default and can be omitted
});

const response = await client.environments.sendMessage('connectionId', {
  messages: [{ client_message_id: 'client_message_id', content: 'string', role: 'user' }],
});

console.log(response.message);
{
  "message": "message",
  "success": true
}
Returns Examples
{
  "message": "message",
  "success": true
}