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

# Create tool

POST https://api.runtype.com/v1/tools
Content-Type: application/json

Create a new tool definition.

Reference: https://docs.runtype.com/api-reference/runtype-api/tools/create-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

### Body (application/json)

This endpoint expects an object.

- `config` (map from string to any, required)
- `description` (string, required)
- `name` (string, required)
- `parametersSchema` (map from string to any, required)
- `toolType` (enum, required)
  - Allowed values: `flow`, `custom`, `external`, `graphql`, `mcp`, `local`, `subagent`

## Response

### 200

Created tool

- `config` (map from string to any, required, nullable)
- `createdAt` (string, required)
- `description` (string, required, nullable)
- `id` (string, required)
- `isActive` (boolean, required)
- `name` (string, required)
- `organizationId` (string, required, nullable)
- `toolType` (string, required)
- `updatedAt` (string, required)
- `userId` (string, required, nullable)
- `lastModifiedSource` (string, optional, nullable)
- `parametersSchema` (map from string to any, optional)
- `validation` (V1ToolsPostResponsesContentApplicationJsonSchemaValidation, optional) — Non-blocking findings from a successful write. `warnings` also carries `SESSION_PREVIEW_URL` when `config.url` or `config.serverUrl` is a session sandbox preview URL, which stops working when that sandbox container stops.

## Errors

### 400 Bad Request Error

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

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

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

### V1ToolsPostResponsesContentApplicationJsonSchemaValidation

Non-blocking findings from a successful write. `warnings` also carries `SESSION_PREVIEW_URL` when `config.url` or `config.serverUrl` is a session sandbox preview URL, which stops working when that sandbox container stops.

- `warnings` (list of V1ToolsPostResponsesContentApplicationJsonSchemaValidationWarningsItems, required)
- `recommendations` (list of FlowValidationIssue, 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, …).

### V1ToolsPostResponsesContentApplicationJsonSchemaValidationWarningsItems

- `code` (string, required)
- `message` (string, required)
- `severity` (enum, required)
  - Allowed values: `error`, `warning`
- `column` (double, optional)
- `line` (double, optional)
- `suggestion` (string, optional)

### FlowValidationIssue

- `code` (string, required)
- `message` (string, required)
- `details` (any, optional)
- `path` (string, optional)
- `step` (FlowValidationIssueStep, optional)

### FlowValidationIssueStep

- `index` (integer, required)
- `name` (string, required)
- `type` (string, required)

## Examples

**Request**

```json
{
  "config": {
    "code": "const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }",
    "timeout": 5000
  },
  "description": "A simple calculator for basic math operations",
  "name": "Calculator Tool",
  "parametersSchema": {
    "properties": {
      "a": {
        "description": "First number",
        "type": "number"
      },
      "b": {
        "description": "Second number",
        "type": "number"
      },
      "operation": {
        "description": "The math operation to perform",
        "enum": [
          "add",
          "subtract",
          "multiply",
          "divide"
        ],
        "type": "string"
      }
    },
    "required": [
      "operation",
      "a",
      "b"
    ],
    "type": "object"
  },
  "toolType": "custom"
}
```

**Response**

```json
{
  "config": {},
  "createdAt": "string",
  "description": "string",
  "id": "string",
  "isActive": true,
  "name": "string",
  "organizationId": "string",
  "toolType": "string",
  "updatedAt": "string",
  "userId": "string",
  "lastModifiedSource": "string",
  "parametersSchema": {},
  "validation": {
    "warnings": [
      {
        "code": "string",
        "message": "string",
        "severity": "error",
        "column": 1.1,
        "line": 1.1,
        "suggestion": "string"
      }
    ],
    "recommendations": [
      {
        "code": "string",
        "message": "string",
        "path": "string",
        "step": {
          "index": 1,
          "name": "string",
          "type": "string"
        }
      }
    ]
  }
}
```

**SDK Code**

```python Create Tool
import requests

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

payload = {
    "config": {
        "code": "const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }",
        "timeout": 5000
    },
    "description": "A simple calculator for basic math operations",
    "name": "Calculator Tool",
    "parametersSchema": {
        "properties": {
            "a": {
                "description": "First number",
                "type": "number"
            },
            "b": {
                "description": "Second number",
                "type": "number"
            },
            "operation": {
                "description": "The math operation to perform",
                "enum": ["add", "subtract", "multiply", "divide"],
                "type": "string"
            }
        },
        "required": ["operation", "a", "b"],
        "type": "object"
    },
    "toolType": "custom"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create Tool
const url = 'https://api.runtype.com/v1/tools';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"config":{"code":"const { operation, a, b } = parameters; switch(operation) { case \'add\': return { result: a + b }; case \'subtract\': return { result: a - b }; case \'multiply\': return { result: a * b }; case \'divide\': return { result: a / b }; }","timeout":5000},"description":"A simple calculator for basic math operations","name":"Calculator Tool","parametersSchema":{"properties":{"a":{"description":"First number","type":"number"},"b":{"description":"Second number","type":"number"},"operation":{"description":"The math operation to perform","enum":["add","subtract","multiply","divide"],"type":"string"}},"required":["operation","a","b"],"type":"object"},"toolType":"custom"}'
};

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

```go Create Tool
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"config\": {\n    \"code\": \"const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }\",\n    \"timeout\": 5000\n  },\n  \"description\": \"A simple calculator for basic math operations\",\n  \"name\": \"Calculator Tool\",\n  \"parametersSchema\": {\n    \"properties\": {\n      \"a\": {\n        \"description\": \"First number\",\n        \"type\": \"number\"\n      },\n      \"b\": {\n        \"description\": \"Second number\",\n        \"type\": \"number\"\n      },\n      \"operation\": {\n        \"description\": \"The math operation to perform\",\n        \"enum\": [\n          \"add\",\n          \"subtract\",\n          \"multiply\",\n          \"divide\"\n        ],\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\n      \"operation\",\n      \"a\",\n      \"b\"\n    ],\n    \"type\": \"object\"\n  },\n  \"toolType\": \"custom\"\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 Create Tool
require 'uri'
require 'net/http'

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

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  \"config\": {\n    \"code\": \"const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }\",\n    \"timeout\": 5000\n  },\n  \"description\": \"A simple calculator for basic math operations\",\n  \"name\": \"Calculator Tool\",\n  \"parametersSchema\": {\n    \"properties\": {\n      \"a\": {\n        \"description\": \"First number\",\n        \"type\": \"number\"\n      },\n      \"b\": {\n        \"description\": \"Second number\",\n        \"type\": \"number\"\n      },\n      \"operation\": {\n        \"description\": \"The math operation to perform\",\n        \"enum\": [\n          \"add\",\n          \"subtract\",\n          \"multiply\",\n          \"divide\"\n        ],\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\n      \"operation\",\n      \"a\",\n      \"b\"\n    ],\n    \"type\": \"object\"\n  },\n  \"toolType\": \"custom\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/tools")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"config\": {\n    \"code\": \"const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }\",\n    \"timeout\": 5000\n  },\n  \"description\": \"A simple calculator for basic math operations\",\n  \"name\": \"Calculator Tool\",\n  \"parametersSchema\": {\n    \"properties\": {\n      \"a\": {\n        \"description\": \"First number\",\n        \"type\": \"number\"\n      },\n      \"b\": {\n        \"description\": \"Second number\",\n        \"type\": \"number\"\n      },\n      \"operation\": {\n        \"description\": \"The math operation to perform\",\n        \"enum\": [\n          \"add\",\n          \"subtract\",\n          \"multiply\",\n          \"divide\"\n        ],\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\n      \"operation\",\n      \"a\",\n      \"b\"\n    ],\n    \"type\": \"object\"\n  },\n  \"toolType\": \"custom\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/tools', [
  'body' => '{
  "config": {
    "code": "const { operation, a, b } = parameters; switch(operation) { case \'add\': return { result: a + b }; case \'subtract\': return { result: a - b }; case \'multiply\': return { result: a * b }; case \'divide\': return { result: a / b }; }",
    "timeout": 5000
  },
  "description": "A simple calculator for basic math operations",
  "name": "Calculator Tool",
  "parametersSchema": {
    "properties": {
      "a": {
        "description": "First number",
        "type": "number"
      },
      "b": {
        "description": "Second number",
        "type": "number"
      },
      "operation": {
        "description": "The math operation to perform",
        "enum": [
          "add",
          "subtract",
          "multiply",
          "divide"
        ],
        "type": "string"
      }
    },
    "required": [
      "operation",
      "a",
      "b"
    ],
    "type": "object"
  },
  "toolType": "custom"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Create Tool
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/tools");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"config\": {\n    \"code\": \"const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }\",\n    \"timeout\": 5000\n  },\n  \"description\": \"A simple calculator for basic math operations\",\n  \"name\": \"Calculator Tool\",\n  \"parametersSchema\": {\n    \"properties\": {\n      \"a\": {\n        \"description\": \"First number\",\n        \"type\": \"number\"\n      },\n      \"b\": {\n        \"description\": \"Second number\",\n        \"type\": \"number\"\n      },\n      \"operation\": {\n        \"description\": \"The math operation to perform\",\n        \"enum\": [\n          \"add\",\n          \"subtract\",\n          \"multiply\",\n          \"divide\"\n        ],\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\n      \"operation\",\n      \"a\",\n      \"b\"\n    ],\n    \"type\": \"object\"\n  },\n  \"toolType\": \"custom\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create Tool
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "config": [
    "code": "const { operation, a, b } = parameters; switch(operation) { case 'add': return { result: a + b }; case 'subtract': return { result: a - b }; case 'multiply': return { result: a * b }; case 'divide': return { result: a / b }; }",
    "timeout": 5000
  ],
  "description": "A simple calculator for basic math operations",
  "name": "Calculator Tool",
  "parametersSchema": [
    "properties": [
      "a": [
        "description": "First number",
        "type": "number"
      ],
      "b": [
        "description": "Second number",
        "type": "number"
      ],
      "operation": [
        "description": "The math operation to perform",
        "enum": ["add", "subtract", "multiply", "divide"],
        "type": "string"
      ]
    ],
    "required": ["operation", "a", "b"],
    "type": "object"
  ],
  "toolType": "custom"
] as [String : Any]

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

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