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

# Execute a workflow.

POST https://api.scoutos.com/v2/workflows/{workflow_id}/execute
Content-Type: application/json

Reference: https://ref.scoutos.com/api-sdk/endpoints/workflows/run

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `workflow_id` (string, required)

### Query parameters

- `environment` (string, optional, nullable, default: production) — Specifies the execution environment for the workflow. The available environments include: - `production`: The production environment, where workflows are executed under live conditions. - `staging`: A staging environment used for testing prior to production deployment. - `development`: A development environment used for testing new changes. - `console`: The console environment, runs latest changes on a workflow.
- `revision_id` (string, optional, nullable)
- `session_id` (string, optional, nullable)

### Body (application/json)

This endpoint expects an object.

- `streaming` (false, required)
- `inputs` (map from string to V2WorkflowsWorkflowIdExecutePostRequestBodyContentApplicationJsonSchemaInputs, optional)

## Response

### 200

- `run` (WorkflowRun, required)
- `workflow_id` (string, required)
- `output_block_id` (string, optional, default: )

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### V2WorkflowsWorkflowIdExecutePostRequestBodyContentApplicationJsonSchemaInputs

- boolean
- map from string to any
- double
- integer
- list of any
- string

### WorkflowRun

- `stop_reason` (enum, required)
  - Allowed values: `workflow_run_completed`, `workflow_run_failed`
- `session_id` (string, required)
- `workflow_run_id` (string, required)
- `state` (map from string to WorkflowRunState, optional, nullable)
- `errors` (list of string, optional)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### WorkflowRunState

- list of any
- string
- integer
- double
- map from string to any

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "streaming": true,
  "inputs": {
    "user_message": "Please generate a summary report for Q1 sales."
  }
}
```

**SDK Code**

```typescript
// Import the Scout client library
import { ScoutClient } from "scoutos";

// Initialize the client with your API key
const client = new ScoutClient({ apiKey: "YOUR_API_KEY" });

// Execute the workflow and get the response
const response = await client.workflows.run("workflow_id", {
  inputs: {
    "user_message": "Hello there! I have a question..."
  },
});

// Handle the response
console.log(response);

```

```typescript
// Import the Scout client library
import { ScoutClient } from "scoutos";

// Initialize the client with your API key
const client = new ScoutClient({ apiKey: "YOUR_API_KEY" });

// Execute the workflow and get the response
const response = await client.workflows.run_stream("workflow_id", {
  inputs: {
    "user_message": "Hello there! I have a question..."
  },
});

// Handle the response
console.log(response);

```

```python
# Import the Scout client library
from scoutos import Scout

# Initialize the client with your API key
client = Scout(
  api_key="YOUR_API_KEY",
)

# Execute the workflow and get the response
response = client.workflows.run(
  workflow_id="workflow_id",
  inputs={
    "user_message": "Hello there! I have a question..."
  },
)

# Print the response
print(response)

```

```python
# Import the Scout client library
from scoutos import Scout

# Initialize the client with your API key
client = Scout(
  api_key="YOUR_API_KEY",
)

# Execute the workflow and get the response
response = client.workflows.run_stream(
  workflow_id="workflow_id",
  inputs={
    "user_message": "Hello there! I have a question..."
  },
)

# Print the response
print(response)

```

```c#
// Create a REST client for the workflow endpoint
var client = new RestClient("https://api.scoutos.com/v2/workflows/workflow_id/execute");
var request = new RestRequest(Method.POST);

// Add headers for authentication and content type
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");

// Add the request body with the user message
request.AddParameter("application/json", 
  "{\n" +
  "  \"inputs\": {\n" +
  "    \"user_message\": \"Hello there! I have a question...\"\n" +
  "  },\n" +
  "  \"streaming\": false\n" +
  "}", 
  ParameterType.RequestBody);

// Execute the request and get the response
IRestResponse response = client.Execute(request);

```

```c#
// Create a REST client for the workflow endpoint
var client = new RestClient("https://api.scoutos.com/v2/workflows/workflow_id/execute");
var request = new RestRequest(Method.POST);

// Add headers for authentication and content type
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");

// Add the request body with the user message
request.AddParameter("application/json", 
  "{\n" +
  "  \"inputs\": {\n" +
  "    \"user_message\": \"Hello there! I have a question...\"\n" +
  "  },\n" +
  "  \"streaming\": false\n" +
  "}", 
  ParameterType.RequestBody);

// Execute the request and get the response
IRestResponse response = client.Execute(request);

```

```go
package main

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

func main() {
  // Set the API endpoint URL
  url := "https://api.scoutos.com/v2/workflows/workflow_id/execute"
  
  // Create the request body with the user message
  payload := strings.NewReader(`{
    "inputs": {
      "user_message": "Hello there! I have a question..."
    },
    "streaming": false
  }`)
  
  // Set up the HTTP request
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <token>")
  req.Header.Add("Content-Type", "application/json")
  
  // Send the request and handle the response
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  
  // Print the response
  fmt.Println(res)
  fmt.Println(string(body))
}

```

```go
package main

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

func main() {
  // Set the API endpoint URL
  url := "https://api.scoutos.com/v2/workflows/workflow_id/execute"
  
  // Create the request body with the user message
  payload := strings.NewReader(`{
    "inputs": {
      "user_message": "Hello there! I have a question..."
    },
    "streaming": false
  }`)
  
  // Set up the HTTP request
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <token>")
  req.Header.Add("Content-Type", "application/json")
  
  // Send the request and handle the response
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  
  // Print the response
  fmt.Println(res)
  fmt.Println(string(body))
}

```

```java
// Execute the workflow and get the response using Unirest
HttpResponse<String> response = Unirest.post("https://api.scoutos.com/v2/workflows/workflow_id/execute")
  // Add headers for authentication and content type
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  // Add the request body with the user message
  .body("{\n" +
        "  \"inputs\": {\n" +
        "    \"user_message\": \"Hello there! I have a question...\"\n" +
        "  },\n" +
        "  \"streaming\": false\n" +
        "}")
  .asString();

```

```java
// Execute the workflow and get the response using Unirest
HttpResponse<String> response = Unirest.post("https://api.scoutos.com/v2/workflows/workflow_id/execute")
  // Add headers for authentication and content type
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  // Add the request body with the user message
  .body("{\n" +
        "  \"inputs\": {\n" +
        "    \"user_message\": \"Hello there! I have a question...\"\n" +
        "  },\n" +
        "  \"streaming\": false\n" +
        "}")
  .asString();

```

```ruby
require 'uri'
require 'net/http'

# Set up the request URL
url = URI("https://api.scoutos.com/v2/workflows/workflow_id/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

# Create a POST request
request = Net::HTTP::Post.new(url)

# Add headers for authentication and content type
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'

# Add the request body with the user message
request.body = '{
  "inputs": {
    "user_message": "Hello there! I have a question..."
  },
  "streaming": false
}'

# Send the request and get the response
response = http.request(request)
puts response.read_body

```

```ruby
require 'uri'
require 'net/http'

# Set up the request URL
url = URI("https://api.scoutos.com/v2/workflows/workflow_id/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

# Create a POST request
request = Net::HTTP::Post.new(url)

# Add headers for authentication and content type
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'

# Add the request body with the user message
request.body = '{
  "inputs": {
    "user_message": "Hello there! I have a question..."
  },
  "streaming": false
}'

# Send the request and get the response
response = http.request(request)
puts response.read_body

```

```swift
import Foundation

// Set up the request headers
let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

// Create the request parameters with the user message
let parameters = [
  "inputs": [
    "user_message": "Hello there! I have a question..."
  ],
  "streaming": false
] as [String: Any]

// Convert parameters to JSON data
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: [])

// Set up the request URL and configuration
let request = NSMutableURLRequest(
  url: NSURL(string: "https://api.scoutos.com/v2/workflows/workflow_id/execute")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0
)

// Configure the request
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

// Create and execute the HTTP request
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse as Any)
  }
}
dataTask.resume()

```

```swift
import Foundation

// Set up the request headers
let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

// Create the request parameters with the user message
let parameters = [
  "inputs": [
    "user_message": "Hello there! I have a question..."
  ],
  "streaming": false
] as [String: Any]

// Convert parameters to JSON data
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: [])

// Set up the request URL and configuration
let request = NSMutableURLRequest(
  url: NSURL(string: "https://api.scoutos.com/v2/workflows/workflow_id/execute")! as URL,
  cachePolicy: .useProtocolCachePolicy,
  timeoutInterval: 10.0
)

// Configure the request
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

// Create and execute the HTTP request
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse as Any)
  }
}
dataTask.resume()

```

```php
<?php
// Create a new Guzzle HTTP client
$client = new \GuzzleHttp\Client();

// Execute the workflow and get the response
$response = $client->request('POST', 'https://api.scoutos.com/v2/workflows/workflow_id/execute', [
  // Add the request body with the user message
  'body' => '{
    "inputs": {
      "user_message": "Hello there! I have a question..."
    },
    "streaming": false
  }',
  // Add headers for authentication and content type
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

// Output the response body
echo $response->getBody();

```

```php
<?php
// Create a new Guzzle HTTP client
$client = new \GuzzleHttp\Client();

// Execute the workflow and get the response
$response = $client->request('POST', 'https://api.scoutos.com/v2/workflows/workflow_id/execute', [
  // Add the request body with the user message
  'body' => '{
    "inputs": {
      "user_message": "Hello there! I have a question..."
    },
    "streaming": false
  }',
  // Add headers for authentication and content type
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

// Output the response body
echo $response->getBody();

```

```csharp
using RestSharp;

var client = new RestClient("https://api.scoutos.com/v2/workflows/workflow_id/execute");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"streaming\": true,\n  \"inputs\": {\n    \"user_message\": \"Please generate a summary report for Q1 sales.\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```