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

# Invoke an agent

POST https://api.cloudraker.com/v1/agents/{id}/invoke
Content-Type: application/json

Runs an agent on an instruction — the prompt-shaped door. Give it `input` in plain words and, optionally, `files`; the agent plans and executes from there. This is the same runtime as `POST /v1/agent-runs`, minus the requirement to lead with files.

**Sync by default.** `?wait=<seconds>` (default 60, max 120) holds the request; a run that outlives the window answers `202` with a `statusUrl` to poll. Steering, approvals, tasks, timeline and result all use the existing `/v1/agent-runs/{id}` surface.

**Learn more:** [Agents guide](https://docs.cloudraker.com/capabilities/agents)

Reference: https://docs.cloudraker.com/api/cloud-raker-api/agents/invoke-agent

## Authentication

- `Authorization` header (bearer token, required)

## Request

### Path parameters

- `id` (string, required)

### Query parameters

- `wait` (integer, optional, default: 60) — How many seconds to hold the request open. Releases early the moment the run finishes **or** blocks on a person. Maximum 120; `0` returns immediately.

### Body (application/json)

- `input` (string, required) — What you want done, in plain words. Frozen into the run — a later instruction is a steer, not a rewrite.
- `files` (list of object or object, optional) — Files the agent works on. Omit entirely for a prompt-only run.
  - object
    - `url` (string, required)
    - `name` (string, optional)
    - `processing` (enum, optional)
      - Allowed values: `auto`, `ocr`, `simple`, `transcribe`, `transcribe_diarize`
  - object
    - `id` (string, required)
- `metadata` (map from string to any, optional) — Arbitrary JSON you attach to the run and get back on every read of it. Use it to carry your own identifiers — an order number, a customer id — so a webhook or a polled run reconciles without a lookup table. Capped at 10 KB serialized.
- `webhook` (object or object, optional) — Where to deliver this run's events, given one of two ways. * `{ "url": "…" }` — a one-off https endpoint for this run only. * `{ "id": "whe_…" }` — a saved endpoint from `POST /v1/webhooks`. Runs hold the reference, so pausing or re-pointing that endpoint applies to this run too. Deliveries are at-least-once and signed — dedupe on `eventId` and verify against `GET /v1/webhooks/jwks.json`.
  - object
    - `url` (string, required)
  - object
    - `id` (string, required)

## Response

### 200

The run finished (or blocked on a person) inside the wait window.

- `object` ("agent_run", required)
- `id` (string, required)
- `agent` (object, required)
  - `id` (string, required)
  - `name` (string, required)
  - `version` (double, required)
- `input` (object, required)
  - `files` (list of object, required) — The immutable input file ids. Reuse these with `agent.id` to start a successor after a terminal run.
    - `id` (string, required)
- `status` (enum, required) — Where the agent run is in its life. | Status | Meaning | | --- | --- | | `queued` | Accepted; its files are still being prepared | | `processing` | The agent is working | | `waiting` | Blocked on a person — see `waiting`, `approvals` and `tasks[]` | | `paused` | Stopped short of finishing and resumable; not a failure | | `completed` | Finished; `result` and `output` are populated | | `failed` | Finished without producing a result | | `cancelled` | Stopped on request | | `expired` | Reached its `expiresAt` without finishing | `completed`, `failed`, `cancelled` and `expired` are terminal. A `completed` run that still had outstanding work also carries `incomplete: true`.
  - Allowed values: `queued`, `processing`, `waiting`, `paused`, `completed`, `failed`, `cancelled`, `expired`
- `progress` (object, required)
  - `tasks` (object, required)
    - `total` (double, required)
    - `completed` (double, required)
- `tasks` (list of object, required)
  - `id` (string, required)
  - `title` (string, required)
  - `executor` (enum, required) — Who performs the step: `agent` runs by itself, `human` waits for a person to complete it.
    - Allowed values: `agent`, `human`
  - `status` (enum, required) — Where this step stands. `pending` is blocked on its dependencies, `ready` is claimable, `skipped` satisfies anything waiting on it.
    - Allowed values: `pending`, `ready`, `in_progress`, `completed`, `skipped`
  - `summary` (string, required, nullable)
  - `completedAt` (string, required, nullable)
  - `note` (string, optional)
- `statusUrl` (string, required)
- `createdAt` (string, required)
- `expiresAt` (string, required, nullable) — The run’s deadline: about seven days after it starts, an unfinished run parks itself for good and its `status` becomes `expired`. `null` once the run is finished. Files and anything the run already filed are never taken back.
- `finishedAt` (string, required, nullable)
- `waiting` (object, optional) — What is blocking the run. Present while `status` is `waiting`.
  - `approvals` (double, required)
  - `tasks` (double, required)
  - `summary` (string, required)
- `paused` (object, optional) — Why the run parked. Present while `status` is `paused`. A paused run keeps everything it produced and can be started again.
  - `reason` (enum, required)
    - Allowed values: `model_error`, `system_error`
- `approvals` (list of object, optional) — Sign-offs the run is waiting on, oldest first.
  - `id` (string, required)
  - `kind` (enum, required)
    - Allowed values: `before`, `output`
  - `action` (string, required)
  - `requestedAt` (string, required)
  - `files` (list of object, required)
    - `id` (string, required)
    - `name` (string, required)
  - `rationale` (string, optional, nullable)
  - `params` (map from string to any, optional) — The inputs proposed for the step, for a `before` approval.
- `incomplete` (boolean, optional) — Present and `true` on a `completed` run that still had outstanding work — read `tasks[]` to see what.
- `result` (string, optional) — The agent's closing summary.
- `output` (object, optional) — Files attached to the run while its steps were completed, each with a signed download link valid for about an hour.
  - `files` (list of object, required)
    - `id` (string, required)
    - `name` (string, required)
    - `url` (string, optional)
- `error` (object, optional) — Why the run failed. Present whenever `status` is `failed`.
  - `code` (string, required)
  - `message` (string, required)
- `metadata` (map from string to any, optional)

### 202

Accepted — still working.

- `object` ("agent_run", required)
- `id` (string, required)
- `status` (enum, required) — Where the agent run is in its life. | Status | Meaning | | --- | --- | | `queued` | Accepted; its files are still being prepared | | `processing` | The agent is working | | `waiting` | Blocked on a person — see `waiting`, `approvals` and `tasks[]` | | `paused` | Stopped short of finishing and resumable; not a failure | | `completed` | Finished; `result` and `output` are populated | | `failed` | Finished without producing a result | | `cancelled` | Stopped on request | | `expired` | Reached its `expiresAt` without finishing | `completed`, `failed`, `cancelled` and `expired` are terminal. A `completed` run that still had outstanding work also carries `incomplete: true`.
  - Allowed values: `queued`, `processing`, `waiting`, `paused`, `completed`, `failed`, `cancelled`, `expired`
- `statusUrl` (string, required)

## Examples

### Example 1

**Request**

```json
{
  "input": "string"
}
```

**Response**

```json
{
  "object": "string",
  "id": "agr_01JQ8ZKMRT4V6WXYZ0ABCDEFGH",
  "agent": {
    "id": "string",
    "name": "string",
    "version": 1.1
  },
  "input": {
    "files": [
      {
        "id": "string"
      }
    ]
  },
  "status": "queued",
  "progress": {
    "tasks": {
      "total": 1.1,
      "completed": 1.1
    }
  },
  "tasks": [
    {
      "id": "string",
      "title": "string",
      "executor": "agent",
      "status": "pending",
      "summary": "string",
      "completedAt": "string",
      "note": "string"
    }
  ],
  "statusUrl": "string",
  "createdAt": "string",
  "expiresAt": "string",
  "finishedAt": "string",
  "waiting": {
    "approvals": 1.1,
    "tasks": 1.1,
    "summary": "string"
  },
  "paused": {
    "reason": "model_error"
  },
  "approvals": [
    {
      "id": "string",
      "kind": "before",
      "action": "string",
      "requestedAt": "string",
      "files": [
        {
          "id": "string",
          "name": "string"
        }
      ],
      "rationale": "string",
      "params": {}
    }
  ],
  "incomplete": true,
  "result": "string",
  "output": {
    "files": [
      {
        "id": "string",
        "name": "string",
        "url": "string"
      }
    ]
  },
  "error": {
    "code": "string",
    "message": "string"
  },
  "metadata": {}
}
```

**SDK Code**

```typescript
import { CloudRakerClient } from "@cloudraker/api";

async function main() {
    const client = new CloudRakerClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.agents.invokeAgent({
        id: "id",
        input: "string",
    });
}
main();

```

```python
from cloudraker import CloudRaker

client = CloudRaker(
    token="YOUR_TOKEN_HERE",
)

client.agents.invoke_agent(
    id="id",
    input="string",
)

```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/v1/agents/id/invoke"

	payload := strings.NewReader("{\n  \"input\": \"string\"\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.cloudraker.com/v1/agents/id/invoke")

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  \"input\": \"string\"\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.cloudraker.com/v1/agents/id/invoke")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/agents/id/invoke', [
  'body' => '{
  "input": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/agents/id/invoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["input": "string"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/agents/id/invoke")! 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()
```

### Example 2

**Request**

```json
{
  "input": "string"
}
```

**Response**

```json
{
  "object": "string",
  "id": "agr_01JQ8ZKMRT4V6WXYZ0ABCDEFGH",
  "agent": {
    "id": "string",
    "name": "string",
    "version": 1.1
  },
  "input": {
    "files": [
      {
        "id": "string"
      }
    ]
  },
  "status": "queued",
  "progress": {
    "tasks": {
      "total": 1.1,
      "completed": 1.1
    }
  },
  "tasks": [
    {
      "id": "string",
      "title": "string",
      "executor": "agent",
      "status": "pending",
      "summary": "string",
      "completedAt": "string",
      "note": "string"
    }
  ],
  "statusUrl": "string",
  "createdAt": "string",
  "expiresAt": "string",
  "finishedAt": "string",
  "waiting": {
    "approvals": 1.1,
    "tasks": 1.1,
    "summary": "string"
  },
  "paused": {
    "reason": "model_error"
  },
  "approvals": [
    {
      "id": "string",
      "kind": "before",
      "action": "string",
      "requestedAt": "string",
      "files": [
        {
          "id": "string",
          "name": "string"
        }
      ],
      "rationale": "string",
      "params": {}
    }
  ],
  "incomplete": true,
  "result": "string",
  "output": {
    "files": [
      {
        "id": "string",
        "name": "string",
        "url": "string"
      }
    ]
  },
  "error": {
    "code": "string",
    "message": "string"
  },
  "metadata": {}
}
```

**SDK Code**

```typescript
import { CloudRakerClient } from "@cloudraker/api";

async function main() {
    const client = new CloudRakerClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.agents.invokeAgent({
        id: "id",
        input: "string",
    });
}
main();

```

```python
from cloudraker import CloudRaker

client = CloudRaker(
    token="YOUR_TOKEN_HERE",
)

client.agents.invoke_agent(
    id="id",
    input="string",
)

```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/v1/agents/id/invoke"

	payload := strings.NewReader("{\n  \"input\": \"string\"\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.cloudraker.com/v1/agents/id/invoke")

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  \"input\": \"string\"\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.cloudraker.com/v1/agents/id/invoke")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/agents/id/invoke', [
  'body' => '{
  "input": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/agents/id/invoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["input": "string"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/agents/id/invoke")! 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()
```