> 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` (true, required)
- `inputs` (map from string to V2WorkflowsWorkflowIdExecutePostRequestBodyContentApplicationJsonSchemaInputs, optional)

## Response

### 200

- Streaming response of `WorkflowRunStreamResponse`.
- WorkflowRunStarted: WorkflowRunStarted
- WorkflowRunCompleted: WorkflowRunCompleted
- WorkflowRunFailed: WorkflowRunFailed
- BlockRunStarted: BlockRunStarted
- BlockRunCompleted: BlockRunCompleted
- BlockRunFailed: BlockRunFailed
- BlockStateUpdated: BlockStateUpdated

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

### WorkflowRunStarted

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (WorkflowRunStartedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: workflow_run_started)
  - Allowed values: `workflow_run_started`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### WorkflowRunCompleted

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (WorkflowRunCompletedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: workflow_run_completed)
  - Allowed values: `workflow_run_completed`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### WorkflowRunFailed

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (WorkflowRunFailedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: workflow_run_failed)
  - Allowed values: `workflow_run_failed`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### BlockRunStarted

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (BlockRunStartedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: block_run_started)
  - Allowed values: `block_run_started`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### BlockRunCompleted

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (BlockRunCompletedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: block_run_completed)
  - Allowed values: `block_run_completed`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### BlockRunFailed

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (BlockRunFailedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: block_run_failed)
  - Allowed values: `block_run_failed`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### BlockStateUpdated

- `organization_id` (string, required)
- `environment` (enum, required)
  - Allowed values: `development`, `preview`, `production`, `test`
- `data` (BlockStateUpdatedData, required)
- `price` (string, required)
- `event_type` (string, required)
- `version` (string, required)
- `id` (string, optional) — The unique identifier of the event
- `correlation_id` (string, optional) — Identifies the root cause of the event. If not set, it defaults to the event id.
- `name` (enum, optional, default: block_state_updated)
  - Allowed values: `block_state_updated`
- `timestamp` (string, optional) — The timestamp of the event as UTC ISO 8601 string

### ValidationError

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

### WorkflowRunStartedData

- `workflow_id` (string, required)
- `inputs` (WorkflowRunStartedDataInputs, required)
- `price` (double, required)
- `actor` (WorkflowActor, optional, nullable)
- `workflow_run_id` (string, optional)
- `session_id` (string, optional)
- `state` (WorkflowRunStartedDataState, optional)
- `workflow_config` (WorkflowRunStartedDataWorkflowConfig, optional)

### WorkflowRunCompletedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `output` (WorkflowRunCompletedDataOutput, required)
- `session_id` (string, required)
- `workflow_config` (WorkflowRunCompletedDataWorkflowConfig, optional)

### WorkflowRunFailedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `message` (string, required)
- `session_id` (string, required)
- `workflow_config` (WorkflowRunFailedDataWorkflowConfig, optional)

### BlockRunStartedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `config` (BlockRunStartedDataConfig, required)
- `state` (BlockRunStartedDataState, required)
- `session_id` (string, required)
- `block_type` (string, required, nullable)
- `block_id` (string, optional, nullable)
- `metadata` (BlockRunStartedDataMetadata, optional)

### BlockRunCompletedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `config` (BlockRunCompletedDataConfig, required)
- `state` (BlockRunCompletedDataState, required)
- `session_id` (string, required)
- `price` (double, required)
- `block_type` (string, required, nullable)
- `block_id` (string, optional, nullable)
- `cost` (double, optional, default: 0)
- `metadata` (BlockRunCompletedDataMetadata, optional)

### BlockRunFailedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `config` (BlockRunFailedDataConfig, required)
- `message` (string, required) — The reason why the job failed
- `state` (BlockRunFailedDataState, required)
- `session_id` (string, required)
- `block_type` (string, required, nullable)
- `block_id` (string, optional, nullable)
- `cost` (double, optional, default: 0)
- `metadata` (BlockRunFailedDataMetadata, optional)
- `status_code` (integer, optional, nullable) — The status code of the error

### BlockStateUpdatedData

- `workflow_id` (string, required)
- `workflow_run_id` (string, required)
- `block_type` (string, required) — The block archetype ID
- `update_data` (BlockStateUpdatedDataUpdateData, required)
- `block_id` (string, optional, nullable)
- `update_type` (enum, optional, default: complete) — If `complete` represents a full replacement of state, versus `partial` that indicates data must be _merged_.
  - Allowed values: `complete`, `partial`

### ValidationErrorLocItems

- string
- integer

### WorkflowRunStartedDataInputs

### WorkflowActor

- `id` (string, required)
- `type` (enum, required)
  - Allowed values: `external`, `scoutos`

### WorkflowRunStartedDataState

### WorkflowRunStartedDataWorkflowConfig

### WorkflowRunCompletedDataOutput

### WorkflowRunCompletedDataWorkflowConfig

### WorkflowRunFailedDataWorkflowConfig

### BlockRunStartedDataConfig

### BlockRunStartedDataState

### BlockRunStartedDataMetadata

### BlockRunCompletedDataConfig

### BlockRunCompletedDataState

### BlockRunCompletedDataMetadata

### BlockRunFailedDataConfig

### BlockRunFailedDataState

### BlockRunFailedDataMetadata

### BlockStateUpdatedDataUpdateData

## Examples

**Request**

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

**SDK Code**

```python
import requests

url = "https://api.scoutos.com/v2/workflows/workflow_id/execute"

payload = {
    "streaming": True,
    "inputs": { "user_message": "Please generate a summary report for Q1 sales." }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```typescript
import { ScoutClient } from "scoutos";

const client = new ScoutClient({ apiKey: "YOUR_API_KEY" });
const response = await client.workflows.runStream("workflow_id", {
    environment: "environment",
    revision_id: "revision_id",
    session_id: "session_id"
});
for await (const item of response) {
    console.log(item);
}

```

```go
package main

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

func main() {

	url := "https://api.scoutos.com/v2/workflows/workflow_id/execute"

	payload := strings.NewReader("{\n  \"streaming\": true,\n  \"inputs\": {\n    \"user_message\": \"Please generate a summary report for Q1 sales.\"\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
require 'uri'
require 'net/http'

url = URI("https://api.scoutos.com/v2/workflows/workflow_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  \"streaming\": true,\n  \"inputs\": {\n    \"user_message\": \"Please generate a summary report for Q1 sales.\"\n  }\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.scoutos.com/v2/workflows/workflow_id/execute")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"streaming\": true,\n  \"inputs\": {\n    \"user_message\": \"Please generate a summary report for Q1 sales.\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.scoutos.com/v2/workflows/workflow_id/execute', [
  'body' => '{
  "streaming": true,
  "inputs": {
    "user_message": "Please generate a summary report for Q1 sales."
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "streaming": true,
  "inputs": ["user_message": "Please generate a summary report for Q1 sales."]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.scoutos.com/v2/workflows/workflow_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()
```