Send a user message to the agent in a session
curl --request POST \
--url https://api.agenhq.com/api/v1/sessions/{sessionId}/messages \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"message": "<string>",
"client_id": "<string>"
}
'import requests
url = "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages"
payload = {
"message": "<string>",
"client_id": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', client_id: '<string>'})
};
fetch('https://api.agenhq.com/api/v1/sessions/{sessionId}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'client_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agenhq.com/api/v1/sessions/{sessionId}/messages")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agenhq.com/api/v1/sessions/{sessionId}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"session_id": "<string>",
"type": "user_message",
"payload": {
"type": "user_message",
"message": "<string>"
},
"status": "completed",
"client_id": "<string>",
"session_goal_id": "<string>",
"session_task_id": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}{
"statusCode": 123,
"code": "<string>",
"error": "<string>",
"message": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Sessions
Send a user message to the agent in a session
Sends a new message from the user to the coding agent working in the session. The message is stored as a session event with the user_message type, then the agent either starts processing it immediately or the message is queued if the agent is already busy.
Required API key scopes: any of sessions:write, sessions:all, all:write, all:all.
POST
/
api
/
v1
/
sessions
/
{sessionId}
/
messages
Send a user message to the agent in a session
curl --request POST \
--url https://api.agenhq.com/api/v1/sessions/{sessionId}/messages \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"message": "<string>",
"client_id": "<string>"
}
'import requests
url = "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages"
payload = {
"message": "<string>",
"client_id": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', client_id: '<string>'})
};
fetch('https://api.agenhq.com/api/v1/sessions/{sessionId}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'client_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agenhq.com/api/v1/sessions/{sessionId}/messages"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agenhq.com/api/v1/sessions/{sessionId}/messages")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agenhq.com/api/v1/sessions/{sessionId}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"client_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"session_id": "<string>",
"type": "user_message",
"payload": {
"type": "user_message",
"message": "<string>"
},
"status": "completed",
"client_id": "<string>",
"session_goal_id": "<string>",
"session_task_id": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}{
"statusCode": 123,
"code": "<string>",
"error": "<string>",
"message": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Path Parameters
Minimum string length:
1Response
Default Response
Available options:
user_message, agent_message, system_message, session_finished, session_closed, merge_request_merged, merge_request_closed, agent_file_tree_browse, agent_file_read, agent_file_edit, agent_file_create, agent_file_remove, agent_file_move, agent_file_copy, agent_file_read_range, agent_read_around_match, agent_search_files, agent_search_files_v2, agent_plan_execution_update, agent_ask_user, user_ask_user_response, agent_branch_diff, agent_uncommitted_changes, agent_conflict_state, agent_check_target_branch_mergeability, agent_merge_remote_branch, agent_pull_from_remote, agent_push_to_remote, agent_abort_conflict_resolution, agent_rollback_uncommitted_changes, agent_http_request, agent_web_browse, agent_run_repository_command, agent_alert_created A message sent by the user to the agent within a session. This is the payload created by the send message endpoint.
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
- Option 14
- Option 15
- Option 16
- Option 17
- Option 18
- Option 19
- Option 20
- Option 21
- Option 22
- Option 23
- Option 24
- Option 25
- Option 26
- Option 27
- Option 28
- Option 29
- Option 30
- Option 31
- Option 32
- Option 33
- Option 34
Show child attributes
Show child attributes
Available options:
completed, queued, processing, canceled