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

# Append and activate a workflow definition version

PUT https://studio.runautomat.com/api/v1/projects/{projectId}/workflows/{workflowId}
Content-Type: application/json

Reference: https://docs.runautomat.com/api-reference/programmatic-access/programmatic-access-api/workflows/put-definition

## Authentication

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

## Request

### Path parameters

- `projectId` (string, required)
- `workflowId` (string, required)

### Body (application/json)

This endpoint expects an object.

- `definition` (map from string to any, required)
- `expectedActiveVersionId` (string, optional)
- `versionName` (string, optional)

## Response

### 200

Declared primary response

- `workflow` (ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaWorkflow, required)
- `version` (ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaVersion, required)
- `executionIssues` (list of ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaExecutionIssuesItems, required)

## Types

### ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaWorkflow

- `id` (string, required)
- `name` (string, required)
- `description` (string, required, nullable)
- `status` (enum, required)
  - Allowed values: `development`, `preview`, `active`, `disabled`
- `apiEnabled` (boolean, required)
- `apiUrlSlug` (string, required, nullable)
- `activeVersionId` (string, required, nullable)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)

### ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaVersion

- `id` (string, required)
- `versionNumber` (integer, required)
- `deduped` (boolean, required)

### ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaExecutionIssuesItems

- `code` (enum, required)
  - Allowed values: `node_name_empty`, `duplicate_node_name`, `start_count`, `start_has_incoming`, `end_missing`, `end_has_outgoing`, `edge_unknown_source`, `edge_unknown_target`, `cycle_detected`, `unreachable_node`, `unsupported_node_type`, `outgoing_edge_count`, `unwired_handle`, `duplicate_handle`, `unexpected_handle`, `block_code_missing`, `block_execute_settings_missing`, `block_execute_instructions_missing`, `block_execute_surface_unavailable`, `block_execute_desktop_disabled`, `block_execute_desktop_host_ineligible`, `block_execute_browser_missing`, `block_terminal_failure`, `self_heal_invalid`, `self_heal_surface_unavailable`, `decision_definition_missing`, `decision_branch_id_empty`, `decision_branch_id_reserved`, `decision_branch_id_duplicate`, `decision_branch_expression_empty`, `document_extractor_missing`, `document_input_missing`, `document_mode_mismatch`, `reason_instructions_missing`, `reason_input_id_empty`, `reason_input_id_duplicate`, `reason_input_name_empty`, `reason_input_name_duplicate`, `reason_input_expression_missing`, `reason_collection_multiple`, `reason_output_schema_invalid`, `reason_credential_binding_missing`, `reason_credential_field_missing`, `hitl_actions_missing`, `hitl_action_id_empty`, `hitl_action_id_reserved`, `hitl_action_id_duplicate`, `credential_input_missing`, `credential_input_format_invalid`, `credential_legacy_coordinates_incomplete`, `credential_configuration_missing`, `invalid_definition`
- `type` (string, required)
- `severity` (enum, required)
  - Allowed values: `block`, `warning`
- `path` (list of ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaExecutionIssuesItemsPathItems, required)
- `message` (string, required)

### ApiV1ProjectsProjectIdWorkflowsWorkflowIdPutResponsesContentApplicationJsonSchemaExecutionIssuesItemsPathItems

- string
- double

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "workflow": {
    "id": "string",
    "name": "string",
    "description": "string",
    "status": "development",
    "apiEnabled": true,
    "apiUrlSlug": "string",
    "activeVersionId": "string",
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z"
  },
  "version": {
    "id": "string",
    "versionNumber": 1,
    "deduped": true
  },
  "executionIssues": [
    {
      "code": "node_name_empty",
      "type": "string",
      "severity": "block",
      "path": [
        "string"
      ],
      "message": "string"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go
package main

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

func main() {

	url := "https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PUT", 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://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.put("https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://studio.runautomat.com/api/v1/projects/projectId/workflows/workflowId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```