> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.athenaintel.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.athenaintel.com/_mcp/server.

# Invoke General Agent Asynchronously

POST https://api.athenaintel.com/api/v0/agents/general/invoke-async
Content-Type: application/json

Start a general-agent run and return immediately with a `thread_id`. Use this instead of `/agents/general/invoke` for any call that may take more than a few seconds (tool use, multi-step work), so the HTTP connection is never held open past client or proxy timeouts. Poll `GET /threads/{thread_id}/status` until `status` is `completed` or `failed`; pass `include_messages=true` to read the agent's reply. Supply the `thread_id` of a general-agent thread you can access to continue it; 404/403 when it is unknown/not yours, 409 while a run is still in progress on it or while it is archived (restore it to continue it).

Reference: https://docs.athenaintel.com/api-reference/agents/general/invoke-async

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects a GeneralAgentRequest.

- `config` (GeneralAgentConfig, required) — Configurable fields for the agent.
- `messages` (list of InputMessage, required) — The messages to send to the agent. Each message should be a string (for text inputs) or a list of multimodal content parts.
- `channel` (string, optional, default: api) — The channel through which the request is being made.
- `thread_id` (string, optional, nullable) — Optional thread ID for conversation persistence. If not provided, a new thread will be created.

## Response

### 202

Successful Response

- `message` (string, required) — Human-readable status message
- `status` (string, required) — Status of the invocation (always 'started' for async)
- `thread_id` (string, required) — Thread ID of the run. Poll `GET /threads/{thread_id}/status` (`client.threads.get_status`) until `status` is 'completed' or 'failed'; pass `include_messages=true` to read the agent's reply.

## Errors

### 403 Forbidden Error

Forbidden

- `map from string to any`

### 404 Not Found Error

Not Found

- `map from string to any`

### 409 Conflict Error

Conflict

- `map from string to any`

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### GeneralAgentConfig

Configurable fields for the agent.

- `enabled_tools` (list of GeneralAgentConfigEnabledToolsItems, optional, default: [])
- `knowledge_base_asset_ids` (list of string, optional, default: [])
- `model` (string, optional, nullable)
- `structured_output` (map from string to any, optional, nullable) — A JSON Schema (type: object) the agent's final answer must conform to. When set, the response carries the validated payload in `structured_output` and the request fails with a 500 rather than returning prose that does not match the schema.
- `system_prompt` (string, optional, default: You are Athena, a helpful AI agent.  Answer the user's request (if applicable, using the tools and knowledge at your disposal).)

### InputMessage

A message to be sent to the agent.

- `content` (InputMessageContent, required)
- `additional_kwargs` (map from string to any, optional, nullable)
- `id` (string, optional, nullable)
- `name` (string, optional, nullable)
- `role` (string, optional, nullable)
- `type` (string, optional, nullable)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### GeneralAgentConfigEnabledToolsItems

- enum
  - Allowed values: `search`, `tavily_search`, `browse`
- string

### InputMessageContent

- string
- list of InputMessageContentOneOf1Items

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

### InputMessageContentOneOf1Items

- MessageTextContent: MessageTextContent
- MessageImageUrlContent: MessageImageUrlContent
- ToolUseContent: ToolUseContent
- ToolResultContent: ToolResultContent
- ThinkingContent: ThinkingContent
- RedactedThinkingContent: RedactedThinkingContent

### MessageTextContent

A text content item in a multimodal message content.

- `text` (string, required)
- `type` ("text", required)

### MessageImageUrlContent

An image content item.

- `image_url` (map from string to string, required)
- `type` ("image_url", required)

### ToolUseContent

A tool use content item (when the model calls a tool).

- `id` (string, required)
- `input` (map from string to any, required)
- `name` (string, required)
- `type` ("tool_use", required)

### ToolResultContent

A tool result content item (response from a tool call).

- `content` (ToolResultContentContent, required)
- `is_error` (boolean, required)
- `tool_use_id` (string, required)
- `type` ("tool_result", required)

### ThinkingContent

A thinking content item (Claude's extended thinking).

- `signature` (string, required)
- `thinking` (string, required)
- `type` ("thinking", required)

### RedactedThinkingContent

A redacted thinking content item (when Claude's thinking is redacted for safety).

- `data` (string, required)
- `type` ("redacted_thinking", required)

### ToolResultContentContent

- string
- list of map from string to any

## Examples

**Request**

```json
{
  "config": {
    "enabled_tools": [
      "search"
    ]
  },
  "messages": [
    {
      "content": "Please call the search tool for AAPL news.",
      "role": "user"
    }
  ]
}
```

**Response**

```json
{
  "message": "Agent run started. Poll GET /threads/{thread_id}/status to track progress.",
  "status": "started",
  "thread_id": "thread_12345-6789-abcd-efgh"
}
```

**SDK Code**

```python
import requests

url = "https://api.athenaintel.com/api/v0/agents/general/invoke-async"

payload = {
    "config": { "enabled_tools": ["search"] },
    "messages": [
        {
            "content": "Please call the search tool for AAPL news.",
            "role": "user"
        }
    ]
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.athenaintel.com/api/v0/agents/general/invoke-async';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"config":{"enabled_tools":["search"]},"messages":[{"content":"Please call the search tool for AAPL news.","role":"user"}]}'
};

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.athenaintel.com/api/v0/agents/general/invoke-async"

	payload := strings.NewReader("{\n  \"config\": {\n    \"enabled_tools\": [\n      \"search\"\n    ]\n  },\n  \"messages\": [\n    {\n      \"content\": \"Please call the search tool for AAPL news.\",\n      \"role\": \"user\"\n    }\n  ]\n}")

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

	req.Header.Add("X-API-KEY", "<apiKey>")
	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.athenaintel.com/api/v0/agents/general/invoke-async")

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

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"config\": {\n    \"enabled_tools\": [\n      \"search\"\n    ]\n  },\n  \"messages\": [\n    {\n      \"content\": \"Please call the search tool for AAPL news.\",\n      \"role\": \"user\"\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.athenaintel.com/api/v0/agents/general/invoke-async")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"config\": {\n    \"enabled_tools\": [\n      \"search\"\n    ]\n  },\n  \"messages\": [\n    {\n      \"content\": \"Please call the search tool for AAPL news.\",\n      \"role\": \"user\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.athenaintel.com/api/v0/agents/general/invoke-async', [
  'body' => '{
  "config": {
    "enabled_tools": [
      "search"
    ]
  },
  "messages": [
    {
      "content": "Please call the search tool for AAPL news.",
      "role": "user"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/agents/general/invoke-async");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"config\": {\n    \"enabled_tools\": [\n      \"search\"\n    ]\n  },\n  \"messages\": [\n    {\n      \"content\": \"Please call the search tool for AAPL news.\",\n      \"role\": \"user\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "config": ["enabled_tools": ["search"]],
  "messages": [
    [
      "content": "Please call the search tool for AAPL news.",
      "role": "user"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.athenaintel.com/api/v0/agents/general/invoke-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()
```