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

# Convert flow to tool

POST https://api.runtype.com/v1/tools/flows/{flowId}/convert-to-tool
Content-Type: application/json

Create a flow-type tool from an existing flow, generating its parameters schema from the flow steps.

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

- `flowId` (string, required)

### Body (application/json)

This endpoint expects a map from string to any.

- `map from string to any`

## 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` (V1ToolsFlowsFlowIdConvertToToolPostResponsesContentApplicationJsonSchemaValidation, 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.

### 404 Not Found Error

Flow not found

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

### V1ToolsFlowsFlowIdConvertToToolPostResponsesContentApplicationJsonSchemaValidation

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 V1ToolsFlowsFlowIdConvertToToolPostResponsesContentApplicationJsonSchemaValidationWarningsItems, 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, …).

### V1ToolsFlowsFlowIdConvertToToolPostResponsesContentApplicationJsonSchemaValidationWarningsItems

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

### Convert Flow to Tool

**Request**

```json
{
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputMapping": "steps.final_analysis.result",
  "parameterMapping": {
    "customerEmail": "record.metadata.email",
    "customerName": "record.metadata.name"
  }
}
```

**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 Convert Flow to Tool
import requests

url = "https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool"

payload = {
    "description": "Analyze customer data using the Customer Analysis flow",
    "name": "Customer Analysis Tool",
    "outputMapping": "steps.final_analysis.result",
    "parameterMapping": {
        "customerEmail": "record.metadata.email",
        "customerName": "record.metadata.name"
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Convert Flow to Tool
const url = 'https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"description":"Analyze customer data using the Customer Analysis flow","name":"Customer Analysis Tool","outputMapping":"steps.final_analysis.result","parameterMapping":{"customerEmail":"record.metadata.email","customerName":"record.metadata.name"}}'
};

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

```go Convert Flow to Tool
package main

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

func main() {

	url := "https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool"

	payload := strings.NewReader("{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputMapping\": \"steps.final_analysis.result\",\n  \"parameterMapping\": {\n    \"customerEmail\": \"record.metadata.email\",\n    \"customerName\": \"record.metadata.name\"\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 Convert Flow to Tool
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool")

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  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputMapping\": \"steps.final_analysis.result\",\n  \"parameterMapping\": {\n    \"customerEmail\": \"record.metadata.email\",\n    \"customerName\": \"record.metadata.name\"\n  }\n}"

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

```java Convert Flow to Tool
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputMapping\": \"steps.final_analysis.result\",\n  \"parameterMapping\": {\n    \"customerEmail\": \"record.metadata.email\",\n    \"customerName\": \"record.metadata.name\"\n  }\n}")
  .asString();
```

```php Convert Flow to Tool
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool', [
  'body' => '{
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputMapping": "steps.final_analysis.result",
  "parameterMapping": {
    "customerEmail": "record.metadata.email",
    "customerName": "record.metadata.name"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Convert Flow to Tool
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputMapping\": \"steps.final_analysis.result\",\n  \"parameterMapping\": {\n    \"customerEmail\": \"record.metadata.email\",\n    \"customerName\": \"record.metadata.name\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Convert Flow to Tool
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputMapping": "steps.final_analysis.result",
  "parameterMapping": [
    "customerEmail": "record.metadata.email",
    "customerName": "record.metadata.name"
  ]
] as [String : Any]

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

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

### Convert Flow to Tool (named output variable)

**Request**

```json
{
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputVariable": "analysisSummary",
  "parameterMapping": {
    "customerName": "record.metadata.name"
  }
}
```

**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 Convert Flow to Tool (named output variable)
import requests

url = "https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool"

payload = {
    "description": "Analyze customer data using the Customer Analysis flow",
    "name": "Customer Analysis Tool",
    "outputVariable": "analysisSummary",
    "parameterMapping": { "customerName": "record.metadata.name" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Convert Flow to Tool (named output variable)
const url = 'https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"description":"Analyze customer data using the Customer Analysis flow","name":"Customer Analysis Tool","outputVariable":"analysisSummary","parameterMapping":{"customerName":"record.metadata.name"}}'
};

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

```go Convert Flow to Tool (named output variable)
package main

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

func main() {

	url := "https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool"

	payload := strings.NewReader("{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputVariable\": \"analysisSummary\",\n  \"parameterMapping\": {\n    \"customerName\": \"record.metadata.name\"\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 Convert Flow to Tool (named output variable)
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool")

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  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputVariable\": \"analysisSummary\",\n  \"parameterMapping\": {\n    \"customerName\": \"record.metadata.name\"\n  }\n}"

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

```java Convert Flow to Tool (named output variable)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputVariable\": \"analysisSummary\",\n  \"parameterMapping\": {\n    \"customerName\": \"record.metadata.name\"\n  }\n}")
  .asString();
```

```php Convert Flow to Tool (named output variable)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool', [
  'body' => '{
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputVariable": "analysisSummary",
  "parameterMapping": {
    "customerName": "record.metadata.name"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Convert Flow to Tool (named output variable)
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/tools/flows/flowId/convert-to-tool");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"Analyze customer data using the Customer Analysis flow\",\n  \"name\": \"Customer Analysis Tool\",\n  \"outputVariable\": \"analysisSummary\",\n  \"parameterMapping\": {\n    \"customerName\": \"record.metadata.name\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Convert Flow to Tool (named output variable)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "description": "Analyze customer data using the Customer Analysis flow",
  "name": "Customer Analysis Tool",
  "outputVariable": "analysisSummary",
  "parameterMapping": ["customerName": "record.metadata.name"]
] as [String : Any]

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

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