> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://ref.scoutos.com/api-sdk/endpoints/agents/interact-async/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://ref.scoutos.com/_mcp/server. # Interact with an agent (async) POST https://api.scoutos.com/world/{agent_id}/_interact_async Content-Type: application/json Dedicated handler for async agent interactions exposed via the SDK. Requires callback_url and always returns 202 with session_id + events_url. Reference: https://ref.scoutos.com/api-sdk/endpoints/agents/interact-async ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `agent_id` (string, required) ### Query parameters - `session_id` (string, optional, nullable) ### Body (application/json) This endpoint expects an AsyncInteractionRequest. - `messages` (list of IncomingMessage, required) — List of incoming user messages and drive file references. - `callback_url` (string, required) — Callback URL that Scout will POST to when the interaction completes. The request is signed with HMAC-SHA256 using the organization's secret key. - `metadata` (map from string to any, optional) — Optional metadata (e.g., salesforce_session) - `variables` (map from string to any, optional) — Optional interaction-local variables for tool input interpolation. Keys are variable names; values may be any JSON. - `tags` (list of string, optional, nullable) — Optional tags for categorizing this interaction in observability history. Max 20 tags, each up to 32 lowercase alphanumeric characters plus ':', '_', '-'. ## Response ### 202 Successful Response - `session_id` (string, required) — The session ID for the interaction. - `events_url` (string, required) — URL to replay the interaction's event stream. ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### IncomingMessage - `content` (IncomingMessageContent, required) — The content of the incoming message. May be plain text, a single 'drive_file' reference, or a list mixing the two. ### ValidationError - `loc` (list of ValidationErrorLocItems, required) - `msg` (string, required) - `type` (string, required) ### IncomingMessageContent The content of the incoming message. May be plain text, a single 'drive_file' reference, or a list mixing the two. ### ValidationErrorLocItems ### DriveFileMessage - `type` ("drive_file", required) — The type of entity: 'drive_file' - `path` (string, required) — Drive file path for 'drive_file' entities (e.g., '/Reports/Q1.pdf') ## Examples **Request** ```json { "messages": [ { "content": "Hello, can you provide the latest update on the project status?" } ], "callback_url": "https://clientapp.example.com/api/callbacks/agent_response" } ``` **Response** ```json { "session_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890", "events_url": "https://api.example.com/world/agent_id/events/a1b2c3d4-e5f6-7890-ab12-cd34ef567890" } ``` **SDK Code** ```python import requests url = "https://api.scoutos.com/world/agent_id/_interact_async" payload = { "messages": [{ "content": "Hello, can you provide the latest update on the project status?" }], "callback_url": "https://clientapp.example.com/api/callbacks/agent_response" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.scoutos.com/world/agent_id/_interact_async'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"messages":[{"content":"Hello, can you provide the latest update on the project status?"}],"callback_url":"https://clientapp.example.com/api/callbacks/agent_response"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.scoutos.com/world/agent_id/_interact_async" payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"Hello, can you provide the latest update on the project status?\"\n }\n ],\n \"callback_url\": \"https://clientapp.example.com/api/callbacks/agent_response\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.scoutos.com/world/agent_id/_interact_async") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"messages\": [\n {\n \"content\": \"Hello, can you provide the latest update on the project status?\"\n }\n ],\n \"callback_url\": \"https://clientapp.example.com/api/callbacks/agent_response\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.scoutos.com/world/agent_id/_interact_async") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"messages\": [\n {\n \"content\": \"Hello, can you provide the latest update on the project status?\"\n }\n ],\n \"callback_url\": \"https://clientapp.example.com/api/callbacks/agent_response\"\n}") .asString(); ``` ```php request('POST', 'https://api.scoutos.com/world/agent_id/_interact_async', [ 'body' => '{ "messages": [ { "content": "Hello, can you provide the latest update on the project status?" } ], "callback_url": "https://clientapp.example.com/api/callbacks/agent_response" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.scoutos.com/world/agent_id/_interact_async"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"messages\": [\n {\n \"content\": \"Hello, can you provide the latest update on the project status?\"\n }\n ],\n \"callback_url\": \"https://clientapp.example.com/api/callbacks/agent_response\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "messages": [["content": "Hello, can you provide the latest update on the project status?"]], "callback_url": "https://clientapp.example.com/api/callbacks/agent_response" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.scoutos.com/world/agent_id/_interact_async")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```