> 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.

# Execute Agent Operating Procedure Asynchronously

POST https://api.athenaintel.com/api/v0/aop/execute-async
Content-Type: application/json

Start execution of an Agent Operating Procedure (AOP) asset asynchronously. Returns immediately with a thread_id for tracking execution progress without waiting for completion. Send an `Idempotency-Key` header to make the launch safe to retry: if the response is lost, repeating the identical request with the same key returns the original `thread_id` (with `deduplicated: true`) instead of starting a second run. Keys are private to your account; reusing a key with different parameters is rejected with 422, and a retry that races the first attempt gets 409.

Reference: https://docs.athenaintel.com/api-reference/aop/execute-async

## Authentication

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

## Request

### Headers

- `Idempotency-Key` (string, optional, nullable) — Optional caller-chosen key that makes this launch safe to retry. Repeating the identical request with the same key replays the original response instead of starting another run.

### Body (application/json)

This endpoint expects an AOPExecuteRequestIn.

- `asset_id` (string, required) — ID of the existing AOP asset to execute
- `dry_run` (boolean, optional, default: false) — Execute the AOP in dry-run mode: the agent runs with its real prompt, config, and read-only tools, but side-effectful tool calls (emails, external writes) are validated and captured instead of executed. The session remains visible and is marked with athena_metadata.is_dry_run for UI badging.
- `run_budget` (RunBudget, optional, nullable) — Optional spend cap for this execution: max_model_calls (top-level and sub-agent model calls) and/or max_cost_usd (provider cost at Athena's model pricing). When a limit is reached the run stops before the next model call, ends with athena_termination_reason=run_budget, and the AOP execution settles as not succeeded. Absent = no cap beyond the agent's step limit.
- `user_inputs` (map from string to string, optional, nullable) — Optional user inputs to append to the AOP's prompt as key-value pairs

## Response

### 200

AOP execution started successfully

- `aop_asset_id` (string, required) — ID of the AOP asset that was executed
- `aop_config` (map from string to any, required) — Full configuration of the AOP asset
- `aop_title` (string, required) — Title of the AOP asset
- `base_prompt` (string, required) — Base prompt of the AOP before user inputs were added
- `final_prompt` (string, required) — Final prompt used for execution including user inputs
- `message` (string, required) — Status message about the async execution
- `status` (string, required) — Status of the execution (always 'started' for async)
- `sync_server` (string, required) — Sync server URL used for execution
- `thread_id` (string, required) — Unique thread ID for tracking the execution
- `trigger_type` (string, required) — Type of trigger that initiated the execution
- `deduplicated` (boolean, optional, default: false) — True when this response replays an earlier launch with the same `Idempotency-Key`; no new run was started.

## Errors

### 400 Bad Request Error

Invalid AOP configuration or request

- `map from string to any`

### 401 Unauthorized Error

Unauthorized

- `message` (string, required)

### 404 Not Found Error

AOP asset not found or access denied

- `message` (string, required)

### 409 Conflict Error

The same Idempotency-Key is still being processed

- `map from string to any`

### 422 Unprocessable Entity Error

Idempotency-Key reused with different parameters

- `detail` (list of ValidationError, optional)

### 500 Internal Server Error

Internal server error during execution

- `map from string to any`

## Types

### RunBudget

The most one execution may spend before the runtime stops it. Both limits are optional individually; at least one must be set. A limit that is reached ends the run: the model call that would exceed ``max_model_calls`` is never made, and neither is the first call after accumulated provider cost reaches ``max_cost_usd`` — or the call projected to cross it (a cost cap can be overshot by at most one call's variance, since the provider bills after the fact).

- `max_cost_usd` (double, optional, nullable) — Maximum provider cost in USD this execution may accumulate, at Athena's in-house model pricing. The run stops before the model call that has reached, or is projected to cross, this amount; a single call can overshoot it by at most that call's cost.
- `max_model_calls` (integer, optional, nullable) — Maximum number of model calls (top-level and sub-agent) this execution may make. The run stops before the call that would exceed it.

### ValidationError

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

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "asset_id": "asset_9249292-d118-42d3-95b4-00eccfe0754f",
  "run_budget": {
    "max_cost_usd": 30,
    "max_model_calls": 80
  },
  "user_inputs": {
    "company": "Acme Corp",
    "quarter": "Q1 2024"
  }
}
```

**Response**

```json
{
  "aop_asset_id": "asset_9249292-d118-42d3-95b4-00eccfe0754f",
  "aop_config": {
    "agentId": "research_agent"
  },
  "aop_title": "Market Research Report Generator",
  "base_prompt": "Generate a comprehensive market research report",
  "final_prompt": "Generate a comprehensive market research report\n\n--- User Inputs ---\ncompany: Acme Corp\n",
  "message": "Task execution started successfully. Use the thread_id to track progress.",
  "status": "started",
  "sync_server": "https://iris.prd.athenaintel.com",
  "thread_id": "thread_12345-6789-abcd-efgh",
  "trigger_type": "api"
}
```

**SDK Code**

```python aop_execute_async_example
import requests

url = "https://api.athenaintel.com/api/v0/aop/execute-async"

payload = {
    "asset_id": "asset_9249292-d118-42d3-95b4-00eccfe0754f",
    "run_budget": {
        "max_cost_usd": 30,
        "max_model_calls": 80
    },
    "user_inputs": {
        "company": "Acme Corp",
        "quarter": "Q1 2024"
    }
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript aop_execute_async_example
const url = 'https://api.athenaintel.com/api/v0/aop/execute-async';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"asset_id":"asset_9249292-d118-42d3-95b4-00eccfe0754f","run_budget":{"max_cost_usd":30,"max_model_calls":80},"user_inputs":{"company":"Acme Corp","quarter":"Q1 2024"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go aop_execute_async_example
package main

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

func main() {

	url := "https://api.athenaintel.com/api/v0/aop/execute-async"

	payload := strings.NewReader("{\n  \"asset_id\": \"asset_9249292-d118-42d3-95b4-00eccfe0754f\",\n  \"run_budget\": {\n    \"max_cost_usd\": 30,\n    \"max_model_calls\": 80\n  },\n  \"user_inputs\": {\n    \"company\": \"Acme Corp\",\n    \"quarter\": \"Q1 2024\"\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 aop_execute_async_example
require 'uri'
require 'net/http'

url = URI("https://api.athenaintel.com/api/v0/aop/execute-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  \"asset_id\": \"asset_9249292-d118-42d3-95b4-00eccfe0754f\",\n  \"run_budget\": {\n    \"max_cost_usd\": 30,\n    \"max_model_calls\": 80\n  },\n  \"user_inputs\": {\n    \"company\": \"Acme Corp\",\n    \"quarter\": \"Q1 2024\"\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.athenaintel.com/api/v0/aop/execute-async")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"asset_id\": \"asset_9249292-d118-42d3-95b4-00eccfe0754f\",\n  \"run_budget\": {\n    \"max_cost_usd\": 30,\n    \"max_model_calls\": 80\n  },\n  \"user_inputs\": {\n    \"company\": \"Acme Corp\",\n    \"quarter\": \"Q1 2024\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.athenaintel.com/api/v0/aop/execute-async', [
  'body' => '{
  "asset_id": "asset_9249292-d118-42d3-95b4-00eccfe0754f",
  "run_budget": {
    "max_cost_usd": 30,
    "max_model_calls": 80
  },
  "user_inputs": {
    "company": "Acme Corp",
    "quarter": "Q1 2024"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

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

```csharp aop_execute_async_example
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/aop/execute-async");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"asset_id\": \"asset_9249292-d118-42d3-95b4-00eccfe0754f\",\n  \"run_budget\": {\n    \"max_cost_usd\": 30,\n    \"max_model_calls\": 80\n  },\n  \"user_inputs\": {\n    \"company\": \"Acme Corp\",\n    \"quarter\": \"Q1 2024\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift aop_execute_async_example
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "asset_id": "asset_9249292-d118-42d3-95b4-00eccfe0754f",
  "run_budget": [
    "max_cost_usd": 30,
    "max_model_calls": 80
  ],
  "user_inputs": [
    "company": "Acme Corp",
    "quarter": "Q1 2024"
  ]
] as [String : Any]

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

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