> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ref.scoutos.com/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 (stream)

POST https://api.scoutos.com/world/{agent_id}/_interact
Content-Type: application/json

Reference: https://ref.scoutos.com/api-sdk/endpoints/agents/interact

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, 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 a src__app_http__routes__world__interact__InteractionRequest.

- `messages` (list of IncomingMessage, required) — List of incoming user messages and drive file references.
- `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.
- `callback_url` (string, optional, nullable) — Optional callback URL. If provided, the interaction runs asynchronously and the response returns 202 with session_id + events_url.
- `revision_id` (string, optional, nullable)
- `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

### 200

Successful Response

- Streaming response of `any`.

## 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": {
        "text": "Hello, can you provide the current status of the mission?"
      }
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.scoutos.com/world/agent_id/_interact"

payload = { "messages": [{ "content": { "text": "Hello, can you provide the current status of the mission?" } }] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript
import { ScoutClient } from "scoutos";

const client = new ScoutClient({ apiKey: "YOUR_API_KEY" });
const response = await client.agents.interact("agent_id", {
    session_id: "session_id",
    body: {
        messages: [{
                content: "content"
            }]
    }
});
for await (const item of response) {
    console.log(item);
}

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.scoutos.com/world/agent_id/_interact"

	payload := strings.NewReader("{\n  \"messages\": [\n    {\n      \"content\": {\n        \"text\": \"Hello, can you provide the current status of the mission?\"\n      }\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"messages\": [\n    {\n      \"content\": {\n        \"text\": \"Hello, can you provide the current status of the mission?\"\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.scoutos.com/world/agent_id/_interact")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"messages\": [\n    {\n      \"content\": {\n        \"text\": \"Hello, can you provide the current status of the mission?\"\n      }\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.scoutos.com/world/agent_id/_interact', [
  'body' => '{
  "messages": [
    {
      "content": {
        "text": "Hello, can you provide the current status of the mission?"
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.scoutos.com/world/agent_id/_interact");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"messages\": [\n    {\n      \"content\": {\n        \"text\": \"Hello, can you provide the current status of the mission?\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["messages": [["content": ["text": "Hello, can you provide the current status of the mission?"]]]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.scoutos.com/world/agent_id/_interact")! 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()
```