> 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

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

DEPRECATED: This endpoint is deprecated. Please use /aop/execute-async instead for better performance and reliability. Execute an existing Agent Operating Procedure (AOP) asset with optional user inputs. AOPs are pre-configured AI workflows that can perform complex tasks like research, analysis, and content generation.

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

## Authentication

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

## Request

### 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
- `status` (string, required) — Status of the execution (e.g., 'submitted')
- `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
- `conversation` (ConversationResult, optional, nullable) — The conversation result from the AOP execution
- `error` (string, optional, nullable) — Error message if execution failed

## 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)

### 422 Unprocessable Entity Error

Validation Error

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

### ConversationResult

Model representing the conversation result from task/AOP execution.

- `messages_source` (string, required) — Source of the messages (e.g., 'checkpoints')
- `num_messages` (integer, required) — Total number of messages in the conversation
- `conversation_id` (string, optional, nullable) — ID of the conversation asset
- `created_at` (string, optional, nullable) — ISO timestamp when conversation was created
- `last_assistant_message` (ConversationMessage, optional, nullable) — The last message from the assistant
- `messages` (list of ConversationMessage, optional) — Complete list of messages in the conversation
- `metadata` (map from string to any, optional, nullable) — Additional conversation metadata
- `title` (string, optional, nullable) — Title of the conversation
- `updated_at` (string, optional, nullable) — ISO timestamp when conversation was last updated

### ValidationError

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

### ConversationMessage

Model representing a single conversation message.

- `content` (ConversationMessageContent, required) — Message content as text or structured content blocks
- `id` (string, required) — Unique identifier for the message
- `role` (string, required) — Role of the message sender (user, assistant, system)
- `additional_kwargs` (map from string to any, optional) — Additional message metadata
- `name` (string, optional, nullable) — Tool name for tool messages

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

### ConversationMessageContent

Message content as text or structured content blocks

- string
- list of map from string to any

## 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",
  "status": "completed",
  "sync_server": "https://iris.prd.athenaintel.com",
  "thread_id": "thread_12345-6789-abcd-efgh",
  "trigger_type": "api",
  "conversation": {
    "messages_source": "checkpoints",
    "num_messages": 3,
    "conversation_id": "asset_conversation_12345",
    "created_at": "2024-01-15T10:30:00Z",
    "last_assistant_message": {
      "content": [
        {
          "text": "I've completed the market research report for Acme Corp. Here are the key findings...",
          "type": "text"
        }
      ],
      "id": "msg_assistant_3",
      "role": "assistant",
      "additional_kwargs": {}
    },
    "messages": [
      {
        "content": [
          {
            "text": "Generate a comprehensive market research report\n\n--- User Inputs ---\ncompany: Acme Corp\n",
            "type": "text"
          }
        ],
        "id": "msg_user_1",
        "role": "user",
        "additional_kwargs": {}
      },
      {
        "content": "I'll help you create a comprehensive market research report for Acme Corp...",
        "id": "msg_assistant_2",
        "role": "assistant",
        "additional_kwargs": {}
      },
      {
        "content": "I've completed the market research report for Acme Corp. Here are the key findings...",
        "id": "msg_assistant_3",
        "role": "assistant",
        "additional_kwargs": {}
      }
    ],
    "title": "AOP Execution Conversation",
    "updated_at": "2024-01-15T10:45:00Z"
  }
}
```

**SDK Code**

```python aop_execute_example
import requests

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

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_example
const url = 'https://api.athenaintel.com/api/v0/aop/execute';
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_example
package main

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

func main() {

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

	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_example
require 'uri'
require 'net/http'

url = URI("https://api.athenaintel.com/api/v0/aop/execute")

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_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")
  .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_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.athenaintel.com/api/v0/aop/execute', [
  '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_example
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/aop/execute");
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_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")! 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()
```