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

# Execute tool

POST https://api.runtype.com/v1/tools/{id}/execute
Content-Type: application/json

Execute a tool by ID with the provided parameters. Non-flow tools return the documented JSON result. Flow tools return a text/event-stream response whose frames use the ExecutionStreamEvent vocabulary; use a raw/streaming client helper for flow tools.

Reference: https://docs.runtype.com/api-reference/runtype-api/tools/execute-tool

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Path parameters

- `id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `parameters` (map from string to any, required)
- `context` (V1ToolsIdExecutePostRequestBodyContentApplicationJsonSchemaContext, optional)
- `toolConfig` (map from string to any, optional) — Built-in tools only: the instance config an agent's toolConfigs entry would carry, validated against the tool's configSchema. Rejected for a saved tool.
- `toolId` (string, optional)

## Response

### 200

Tool execution result: BuiltinToolExecuteResult for a builtin: or platform: id, ExecuteToolResult for a saved non-flow tool, an SSE stream for a flow tool

- `Tools_executeTool_Response_200`
  - BuiltinToolExecuteResult: BuiltinToolExecuteResult
  - ToolsExecuteToolResponse2001

## Errors

### 400 Bad Request Error

Invalid request, tool config, or judgment input

- `error` (string, required)
- `code` (string, optional) — Stable code for a caller-fixable failure, e.g. JUDGMENT_QUESTIONS_INVALID or QUESTION_SET_UNRESOLVED.
- `details` (map from string to any, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 403 Forbidden Error

Insufficient permissions

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 404 Not Found Error

Tool not found, or a judgment question set that does not resolve

- `error` (string, required)
- `code` (string, optional) — Stable code for a caller-fixable failure, e.g. JUDGMENT_QUESTIONS_INVALID or QUESTION_SET_UNRESOLVED.
- `details` (map from string to any, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 422 Unprocessable Entity Error

A judgment the gateway cannot serve: an unlisted model or no gateway credential

- `error` (string, required)
- `code` (string, optional) — Stable code for a caller-fixable failure, e.g. JUDGMENT_QUESTIONS_INVALID or QUESTION_SET_UNRESOLVED.
- `details` (map from string to any, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### V1ToolsIdExecutePostRequestBodyContentApplicationJsonSchemaContext

- `userId` (string, required)
- `flowExecutionId` (string, optional)
- `stepId` (string, optional)

### BuiltinToolExecuteResult

- `toolId` (string, required)
- `toolName` (string, required)
- `metadata` (map from string to any, optional) — Execution metadata for the caller, never part of a model-facing tool result. builtin:decision\_judge sets metadata.judgment: requestedModel, resolvedModelId (null when not reported), provider, route, calibrationId (null when absent), keySource, questionSetId and questionSetVersion (configured mode), usage \{ inputTokens, outputTokens, reported }, and estimatedCostUsd (provider rates, before margin).
- `result` (any, optional)

### ToolsExecuteToolResponse2001

- `executionId` (string, required)
- `executionTimeMs` (double, required)
- `status` (enum, required)
  - Allowed values: `pending`, `success`, `failed`, `waiting_for_local`
- `error` (string, optional)
- `result` (any, optional)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

## Examples

**Request**

```json
{
  "parameters": {
    "a": 15,
    "b": 25,
    "operation": "add"
  }
}
```

**Response**

```json
{
  "metadata": {},
  "toolId": "string",
  "toolName": "string"
}
```

**SDK Code**

```python Execute Tool
import requests

url = "https://api.runtype.com/v1/tools/id/execute"

payload = { "parameters": {
        "a": 15,
        "b": 25,
        "operation": "add"
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Execute Tool
const url = 'https://api.runtype.com/v1/tools/id/execute';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"parameters":{"a":15,"b":25,"operation":"add"}}'
};

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

```go Execute Tool
package main

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

func main() {

	url := "https://api.runtype.com/v1/tools/id/execute"

	payload := strings.NewReader("{\n  \"parameters\": {\n    \"a\": 15,\n    \"b\": 25,\n    \"operation\": \"add\"\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 Execute Tool
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/tools/id/execute")

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  \"parameters\": {\n    \"a\": 15,\n    \"b\": 25,\n    \"operation\": \"add\"\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/tools/id/execute")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"parameters\": {\n    \"a\": 15,\n    \"b\": 25,\n    \"operation\": \"add\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/tools/id/execute', [
  'body' => '{
  "parameters": {
    "a": 15,
    "b": 25,
    "operation": "add"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Execute Tool
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/tools/id/execute");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"parameters\": {\n    \"a\": 15,\n    \"b\": 25,\n    \"operation\": \"add\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Execute Tool
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["parameters": [
    "a": 15,
    "b": 25,
    "operation": "add"
  ]] as [String : Any]

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

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