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

# Create a Task Run

POST https://nico-rest-api.nico.svc.cluster.local/v2/org/{org}/nico/task/run
Content-Type: application/json

Create a Task Run: a phased, policy-gated execution of one operation across
many Racks. The configuration is validated server-side by Flow; on
validation failure no state changes.

A Task Run executes exactly one operation over a candidate set of Racks,
narrowed by an optional `selector` and divided into phases by an
optional `options.phasePolicy`. The response echoes the assigned `id`;
the Task Run always starts in the `Pending` state. Poll
`GET /task/run/{id}` for progress.

Org must have an Infrastructure Provider entity. User must have
authorization role with `PROVIDER_ADMIN` suffix.

Reference: https://docs.nvidia.com/infra-controller/rest-api-reference/api-reference/task-run/create-task-run

## Authentication

- `Authorization` header (bearer token, required) — ``` export JWT_BEARER_TOKEN="<jwt-bearer-token>" # Example org name: "acme-inc export ORG_NAME=<org-name> # Use the JWT bearer token in your API request auth header: curl -v -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWT_BEARER_TOKEN" https://nico-rest-api.nico.svc.cluster.local/v2/org/$ORG_NAME/nico/user/current ```

## Request

### Path parameters

- `org` (string, required) — Name of the Org

### Body (application/json)

- `siteId` (string, required) — ID of the Site to create the Task Run on.
- `name` (string, required) — Human-readable name of the Task Run.
- `options` (object, required) — Execution policy for the Task Run.
  - `maxConcurrentTargets` (integer, required) — Caps how many targets may have active child Tasks at once. Must be greater than zero.
  - `safetyPolicy` (object, optional) — A set of gates that pause the Task Run when any one of them trips (OR composition).
    - `gates` (list of object, optional) — Safety gates evaluated after each target outcome.
      - `failureRate` (object, optional) — Pauses when the failed/planned ratio reaches `thresholdPercent` for the scope.
        - `thresholdPercent` (integer, required) — Failure-rate percentage at which the gate trips.
        - `scope` (enum, optional, default: currentPhase) — Whether the ratio is evaluated over the current phase or the cumulative run.
          - Allowed values: `currentPhase`, `cumulativeRun`
      - `failureCount` (object, optional) — Pauses when the number of failed targets reaches `thresholdCount` for the scope.
        - `thresholdCount` (integer, required) — Number of failed targets at which the gate trips.
        - `scope` (enum, optional, default: currentPhase) — Whether the count is evaluated over the current phase or the cumulative run.
          - Allowed values: `currentPhase`, `cumulativeRun`
  - `conflictPolicy` (object, optional) — Configures how blocked targets are retried. Retry is the only supported strategy today.
    - `retry` (object, optional) — Retry backoff for blocked targets. Durations are Go duration strings (e.g. `30m`, `10s`); an empty value means "use the operation default".
      - `retryTimeout` (string, optional) — Total time to keep retrying a blocked target before giving up, as a Go duration string (e.g. `30m`, `2h`).
      - `initialRetryDelay` (string, optional) — Delay before the first retry, as a Go duration string (e.g. `10s`, `1m`).
      - `maxRetryDelay` (string, optional) — Cap on the exponentially growing retry delay, as a Go duration string (e.g. `5m`).
  - `orderingPolicy` (object, optional) — Controls the order in which targets are processed. Random is the only supported ordering today.
    - `random` (object, optional) — Orders targets randomly. `seed` is optional; Flow generates and stores one when omitted.
      - `seed` (string, optional) — Optional seed for the deterministic random ordering.
  - `phasePolicy` (object, optional) — Divides the selected targets into phases. Set at most one of `equal`, `percentage`, or `count`; omit the whole policy for a single phase covering all targets.
    - `equal` (object, optional) — Splits targets into `phaseCount` roughly equal phases. The request is rejected when `phaseCount` exceeds the number of selected targets, because every configured phase must contain at least one target.
      - `phaseCount` (integer, required) — Number of equally sized phases.
    - `percentage` (object, optional) — Splits targets by percentage. Values must sum to 100. A configured phase must resolve to at least one selected target after rounding or the request is rejected.
      - `phases` (list of integer, required) — Per-phase percentages, in phase order; must sum to 100.
    - `count` (object, optional) — Splits targets by explicit counts. A generated final phase covers any remaining targets.
      - `phases` (list of integer, required) — Per-phase target counts, in phase order.
    - `autoAdvance` (boolean, optional, default: false) — When true, phases advance automatically as long as safety gates are not tripped. When false (default) each completed phase pauses at a phase gate until advanced explicitly.
- `operation` (object, required) — The operation the Task Run executes. Firmware is the only supported operation.
  - `firmware` (object, required) — Configures a firmware rollout.
    - `version` (string, required) — Target firmware version to roll out.
    - `ruleId` (string, optional, nullable) — Operation Rule to pin for each target's firmware Task. Null to let Flow's default rule resolution pick one.
    - `overrideReadinessCheck` (boolean, optional, default: false) — Skip the pre-flight readiness check when true.
    - `subTargets` (list of string, optional) — Optional subset of firmware sub-parts to update within each targeted tray, using the same lowercase names as the Tray firmware endpoint's `targets` (e.g. `bmc`, `bios`). Omitted or empty means update everything in the bundle. Unknown names are rejected.
  - `excludeRunIds` (list of string, optional) — Excludes Racks materialized by prior Task Runs from this Task Run's candidate scope.
- `description` (string, optional) — Optional free-form description.
- `selector` (object, optional) — Narrows the candidate Racks. Omit to target the full candidate scope (100%).
  - `percentage` (object, optional) — Selects a percentage of the candidate Racks. `seed` is optional; when omitted Flow generates and stores one so the cohort is deterministic and auditable.
    - `percent` (integer, required) — Percentage of candidate Racks to select.
    - `seed` (string, optional) — Optional seed for the deterministic selection.

## Response

### 201

Task Run was created.

- `id` (string, required) — Unique identifier of the Task Run.
- `name` (string, required) — Human-readable name of the Task Run.
- `operationType` (enum, required) — Type of operation this Task Run executes. Currently always `FirmwareControl`.
  - Allowed values: `PowerControl`, `FirmwareControl`
- `status` (enum, required) — Current lifecycle state of the Task Run.
  - Allowed values: `Unknown`, `Pending`, `Running`, `Paused`, `Completed`, `Cancelled`, `Failed`, `CompletedWithFailures`
- `statusReason` (enum, required) — Why the Task Run is paused or terminal (e.g. `PhaseGate`, `SafetyGate`). `None` when there is no qualifying reason.
  - Allowed values: `Unknown`, `None`, `OperatorPaused`, `PhaseGate`, `SafetyGate`, `ConflictRetryTimeout`
- `totalPhases` (integer, required) — Total number of phases the selected targets were divided into.
- `created` (datetime, required) — Timestamp when the Task Run was created.
- `updated` (datetime, required) — Timestamp when the Task Run was last updated.
- `description` (string, optional) — Optional free-form description.
- `operationCode` (string, optional) — Operation code within the operation type (e.g. `upgrade`).
- `statusMessage` (string, optional) — Optional human-readable detail for the current status.
- `started` (datetime, optional, nullable) — Timestamp when the Task Run started execution. Null before it starts.
- `finished` (datetime, optional, nullable) — Timestamp when the Task Run reached a terminal state. Null while active.
- `stats` (object, optional) — Derived per-phase outcome stats. Present only on the single-Task-Run `GET` when `includeStats=true`; omitted otherwise.
  - `currentPhase` (object, required) — Summarizes target outcomes for one phase scope.
    - `phaseIndex` (integer, required) — Zero-based index of the phase this scope refers to.
    - `selectedTargets` (integer, required) — Number of targets selected within the scope.
    - `outcomeCounts` (object, required) — Counts terminal target outcomes within a phase scope.
      - `completed` (integer, required) — Targets that completed successfully.
      - `failed` (integer, required) — Targets that failed.
      - `terminated` (integer, required) — Targets that were terminated (e.g. by cancellation).
      - `skipped` (integer, required) — Targets that were skipped.
  - `cumulativePhase` (object, required) — Summarizes target outcomes for one phase scope.
    - `phaseIndex` (integer, required) — Zero-based index of the phase this scope refers to.
    - `selectedTargets` (integer, required) — Number of targets selected within the scope.
    - `outcomeCounts` (object, required) — Counts terminal target outcomes within a phase scope.
      - `completed` (integer, required) — Targets that completed successfully.
      - `failed` (integer, required) — Targets that failed.
      - `terminated` (integer, required) — Targets that were terminated (e.g. by cancellation).
      - `skipped` (integer, required) — Targets that were skipped.

## Examples

### Gated firmware rollout over a 10% cohort

**Request**

```json
{
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - 10% cohort",
  "options": {
    "maxConcurrentTargets": 4,
    "safetyPolicy": {
      "gates": [
        {
          "failureRate": {
            "thresholdPercent": 10,
            "scope": "currentPhase"
          }
        },
        {
          "failureCount": {
            "thresholdCount": 5,
            "scope": "cumulativeRun"
          }
        }
      ]
    },
    "conflictPolicy": {
      "retry": {
        "retryTimeout": "30m",
        "initialRetryDelay": "10s",
        "maxRetryDelay": "5m"
      }
    },
    "orderingPolicy": {
      "random": {
        "seed": "fw-25-03-canary"
      }
    },
    "phasePolicy": {
      "equal": {
        "phaseCount": 2
      },
      "autoAdvance": false
    }
  },
  "operation": {
    "firmware": {
      "version": "25.03.1",
      "subTargets": [
        "bmc",
        "bios"
      ]
    }
  },
  "description": "Canary cohort ahead of the fleet-wide rollout.",
  "selector": {
    "percentage": {
      "percent": 10,
      "seed": "fw-25-03-canary"
    }
  }
}
```

**Response**

```json
{
  "id": "string",
  "name": "string",
  "operationType": "PowerControl",
  "status": "Unknown",
  "statusReason": "Unknown",
  "totalPhases": 1,
  "created": "2024-01-15T09:30:00Z",
  "updated": "2024-01-15T09:30:00Z",
  "description": "string",
  "operationCode": "string",
  "statusMessage": "string",
  "started": "2024-01-15T09:30:00Z",
  "finished": "2024-01-15T09:30:00Z",
  "stats": {
    "currentPhase": {
      "phaseIndex": 1,
      "selectedTargets": 1,
      "outcomeCounts": {
        "completed": 1,
        "failed": 1,
        "terminated": 1,
        "skipped": 1
      }
    },
    "cumulativePhase": {
      "phaseIndex": 1,
      "selectedTargets": 1,
      "outcomeCounts": {
        "completed": 1,
        "failed": 1,
        "terminated": 1,
        "skipped": 1
      }
    }
  }
}
```

**SDK Code**

```python Gated firmware rollout over a 10% cohort
import requests

url = "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run"

payload = {
    "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
    "name": "Compute firmware 25.03 - 10% cohort",
    "options": {
        "maxConcurrentTargets": 4,
        "safetyPolicy": { "gates": [{ "failureRate": {
                        "thresholdPercent": 10,
                        "scope": "currentPhase"
                    } }, { "failureCount": {
                        "thresholdCount": 5,
                        "scope": "cumulativeRun"
                    } }] },
        "conflictPolicy": { "retry": {
                "retryTimeout": "30m",
                "initialRetryDelay": "10s",
                "maxRetryDelay": "5m"
            } },
        "orderingPolicy": { "random": { "seed": "fw-25-03-canary" } },
        "phasePolicy": {
            "equal": { "phaseCount": 2 },
            "autoAdvance": False
        }
    },
    "operation": { "firmware": {
            "version": "25.03.1",
            "subTargets": ["bmc", "bios"]
        } },
    "description": "Canary cohort ahead of the fleet-wide rollout.",
    "selector": { "percentage": {
            "percent": 10,
            "seed": "fw-25-03-canary"
        } }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Gated firmware rollout over a 10% cohort
const url = 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"siteId":"60189e9c-7d12-438c-b9ca-6998d9c364b1","name":"Compute firmware 25.03 - 10% cohort","options":{"maxConcurrentTargets":4,"safetyPolicy":{"gates":[{"failureRate":{"thresholdPercent":10,"scope":"currentPhase"}},{"failureCount":{"thresholdCount":5,"scope":"cumulativeRun"}}]},"conflictPolicy":{"retry":{"retryTimeout":"30m","initialRetryDelay":"10s","maxRetryDelay":"5m"}},"orderingPolicy":{"random":{"seed":"fw-25-03-canary"}},"phasePolicy":{"equal":{"phaseCount":2},"autoAdvance":false}},"operation":{"firmware":{"version":"25.03.1","subTargets":["bmc","bios"]}},"description":"Canary cohort ahead of the fleet-wide rollout.","selector":{"percentage":{"percent":10,"seed":"fw-25-03-canary"}}}'
};

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

```go Gated firmware rollout over a 10% cohort
package main

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

func main() {

	url := "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run"

	payload := strings.NewReader("{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - 10% cohort\",\n  \"options\": {\n    \"maxConcurrentTargets\": 4,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 10,\n            \"scope\": \"currentPhase\"\n          }\n        },\n        {\n          \"failureCount\": {\n            \"thresholdCount\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"conflictPolicy\": {\n      \"retry\": {\n        \"retryTimeout\": \"30m\",\n        \"initialRetryDelay\": \"10s\",\n        \"maxRetryDelay\": \"5m\"\n      }\n    },\n    \"orderingPolicy\": {\n      \"random\": {\n        \"seed\": \"fw-25-03-canary\"\n      }\n    },\n    \"phasePolicy\": {\n      \"equal\": {\n        \"phaseCount\": 2\n      },\n      \"autoAdvance\": false\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"subTargets\": [\n        \"bmc\",\n        \"bios\"\n      ]\n    }\n  },\n  \"description\": \"Canary cohort ahead of the fleet-wide rollout.\",\n  \"selector\": {\n    \"percentage\": {\n      \"percent\": 10,\n      \"seed\": \"fw-25-03-canary\"\n    }\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 Gated firmware rollout over a 10% cohort
require 'uri'
require 'net/http'

url = URI("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")

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  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - 10% cohort\",\n  \"options\": {\n    \"maxConcurrentTargets\": 4,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 10,\n            \"scope\": \"currentPhase\"\n          }\n        },\n        {\n          \"failureCount\": {\n            \"thresholdCount\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"conflictPolicy\": {\n      \"retry\": {\n        \"retryTimeout\": \"30m\",\n        \"initialRetryDelay\": \"10s\",\n        \"maxRetryDelay\": \"5m\"\n      }\n    },\n    \"orderingPolicy\": {\n      \"random\": {\n        \"seed\": \"fw-25-03-canary\"\n      }\n    },\n    \"phasePolicy\": {\n      \"equal\": {\n        \"phaseCount\": 2\n      },\n      \"autoAdvance\": false\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"subTargets\": [\n        \"bmc\",\n        \"bios\"\n      ]\n    }\n  },\n  \"description\": \"Canary cohort ahead of the fleet-wide rollout.\",\n  \"selector\": {\n    \"percentage\": {\n      \"percent\": 10,\n      \"seed\": \"fw-25-03-canary\"\n    }\n  }\n}"

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

```java Gated firmware rollout over a 10% cohort
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - 10% cohort\",\n  \"options\": {\n    \"maxConcurrentTargets\": 4,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 10,\n            \"scope\": \"currentPhase\"\n          }\n        },\n        {\n          \"failureCount\": {\n            \"thresholdCount\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"conflictPolicy\": {\n      \"retry\": {\n        \"retryTimeout\": \"30m\",\n        \"initialRetryDelay\": \"10s\",\n        \"maxRetryDelay\": \"5m\"\n      }\n    },\n    \"orderingPolicy\": {\n      \"random\": {\n        \"seed\": \"fw-25-03-canary\"\n      }\n    },\n    \"phasePolicy\": {\n      \"equal\": {\n        \"phaseCount\": 2\n      },\n      \"autoAdvance\": false\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"subTargets\": [\n        \"bmc\",\n        \"bios\"\n      ]\n    }\n  },\n  \"description\": \"Canary cohort ahead of the fleet-wide rollout.\",\n  \"selector\": {\n    \"percentage\": {\n      \"percent\": 10,\n      \"seed\": \"fw-25-03-canary\"\n    }\n  }\n}")
  .asString();
```

```php Gated firmware rollout over a 10% cohort
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run', [
  'body' => '{
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - 10% cohort",
  "options": {
    "maxConcurrentTargets": 4,
    "safetyPolicy": {
      "gates": [
        {
          "failureRate": {
            "thresholdPercent": 10,
            "scope": "currentPhase"
          }
        },
        {
          "failureCount": {
            "thresholdCount": 5,
            "scope": "cumulativeRun"
          }
        }
      ]
    },
    "conflictPolicy": {
      "retry": {
        "retryTimeout": "30m",
        "initialRetryDelay": "10s",
        "maxRetryDelay": "5m"
      }
    },
    "orderingPolicy": {
      "random": {
        "seed": "fw-25-03-canary"
      }
    },
    "phasePolicy": {
      "equal": {
        "phaseCount": 2
      },
      "autoAdvance": false
    }
  },
  "operation": {
    "firmware": {
      "version": "25.03.1",
      "subTargets": [
        "bmc",
        "bios"
      ]
    }
  },
  "description": "Canary cohort ahead of the fleet-wide rollout.",
  "selector": {
    "percentage": {
      "percent": 10,
      "seed": "fw-25-03-canary"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Gated firmware rollout over a 10% cohort
using RestSharp;

var client = new RestClient("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - 10% cohort\",\n  \"options\": {\n    \"maxConcurrentTargets\": 4,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 10,\n            \"scope\": \"currentPhase\"\n          }\n        },\n        {\n          \"failureCount\": {\n            \"thresholdCount\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"conflictPolicy\": {\n      \"retry\": {\n        \"retryTimeout\": \"30m\",\n        \"initialRetryDelay\": \"10s\",\n        \"maxRetryDelay\": \"5m\"\n      }\n    },\n    \"orderingPolicy\": {\n      \"random\": {\n        \"seed\": \"fw-25-03-canary\"\n      }\n    },\n    \"phasePolicy\": {\n      \"equal\": {\n        \"phaseCount\": 2\n      },\n      \"autoAdvance\": false\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"subTargets\": [\n        \"bmc\",\n        \"bios\"\n      ]\n    }\n  },\n  \"description\": \"Canary cohort ahead of the fleet-wide rollout.\",\n  \"selector\": {\n    \"percentage\": {\n      \"percent\": 10,\n      \"seed\": \"fw-25-03-canary\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Gated firmware rollout over a 10% cohort
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - 10% cohort",
  "options": [
    "maxConcurrentTargets": 4,
    "safetyPolicy": ["gates": [["failureRate": [
            "thresholdPercent": 10,
            "scope": "currentPhase"
          ]], ["failureCount": [
            "thresholdCount": 5,
            "scope": "cumulativeRun"
          ]]]],
    "conflictPolicy": ["retry": [
        "retryTimeout": "30m",
        "initialRetryDelay": "10s",
        "maxRetryDelay": "5m"
      ]],
    "orderingPolicy": ["random": ["seed": "fw-25-03-canary"]],
    "phasePolicy": [
      "equal": ["phaseCount": 2],
      "autoAdvance": false
    ]
  ],
  "operation": ["firmware": [
      "version": "25.03.1",
      "subTargets": ["bmc", "bios"]
    ]],
  "description": "Canary cohort ahead of the fleet-wide rollout.",
  "selector": ["percentage": [
      "percent": 10,
      "seed": "fw-25-03-canary"
    ]]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")! 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()
```

### Fleet-wide rollout excluding an earlier cohort

**Request**

```json
{
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - fleet",
  "options": {
    "maxConcurrentTargets": 12,
    "safetyPolicy": {
      "gates": [
        {
          "failureRate": {
            "thresholdPercent": 5,
            "scope": "cumulativeRun"
          }
        }
      ]
    },
    "phasePolicy": {
      "percentage": {
        "phases": [
          25,
          25,
          50
        ]
      },
      "autoAdvance": true
    }
  },
  "operation": {
    "firmware": {
      "version": "25.03.1",
      "ruleId": "8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
    },
    "excludeRunIds": [
      "3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41"
    ]
  }
}
```

**Response**

```json
{
  "id": "string",
  "name": "string",
  "operationType": "PowerControl",
  "status": "Unknown",
  "statusReason": "Unknown",
  "totalPhases": 1,
  "created": "2024-01-15T09:30:00Z",
  "updated": "2024-01-15T09:30:00Z",
  "description": "string",
  "operationCode": "string",
  "statusMessage": "string",
  "started": "2024-01-15T09:30:00Z",
  "finished": "2024-01-15T09:30:00Z",
  "stats": {
    "currentPhase": {
      "phaseIndex": 1,
      "selectedTargets": 1,
      "outcomeCounts": {
        "completed": 1,
        "failed": 1,
        "terminated": 1,
        "skipped": 1
      }
    },
    "cumulativePhase": {
      "phaseIndex": 1,
      "selectedTargets": 1,
      "outcomeCounts": {
        "completed": 1,
        "failed": 1,
        "terminated": 1,
        "skipped": 1
      }
    }
  }
}
```

**SDK Code**

```python Fleet-wide rollout excluding an earlier cohort
import requests

url = "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run"

payload = {
    "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
    "name": "Compute firmware 25.03 - fleet",
    "options": {
        "maxConcurrentTargets": 12,
        "safetyPolicy": { "gates": [{ "failureRate": {
                        "thresholdPercent": 5,
                        "scope": "cumulativeRun"
                    } }] },
        "phasePolicy": {
            "percentage": { "phases": [25, 25, 50] },
            "autoAdvance": True
        }
    },
    "operation": {
        "firmware": {
            "version": "25.03.1",
            "ruleId": "8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
        },
        "excludeRunIds": ["3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41"]
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Fleet-wide rollout excluding an earlier cohort
const url = 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"siteId":"60189e9c-7d12-438c-b9ca-6998d9c364b1","name":"Compute firmware 25.03 - fleet","options":{"maxConcurrentTargets":12,"safetyPolicy":{"gates":[{"failureRate":{"thresholdPercent":5,"scope":"cumulativeRun"}}]},"phasePolicy":{"percentage":{"phases":[25,25,50]},"autoAdvance":true}},"operation":{"firmware":{"version":"25.03.1","ruleId":"8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"},"excludeRunIds":["3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41"]}}'
};

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

```go Fleet-wide rollout excluding an earlier cohort
package main

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

func main() {

	url := "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run"

	payload := strings.NewReader("{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - fleet\",\n  \"options\": {\n    \"maxConcurrentTargets\": 12,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"phasePolicy\": {\n      \"percentage\": {\n        \"phases\": [\n          25,\n          25,\n          50\n        ]\n      },\n      \"autoAdvance\": true\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"ruleId\": \"8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n    },\n    \"excludeRunIds\": [\n      \"3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41\"\n    ]\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 Fleet-wide rollout excluding an earlier cohort
require 'uri'
require 'net/http'

url = URI("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")

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  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - fleet\",\n  \"options\": {\n    \"maxConcurrentTargets\": 12,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"phasePolicy\": {\n      \"percentage\": {\n        \"phases\": [\n          25,\n          25,\n          50\n        ]\n      },\n      \"autoAdvance\": true\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"ruleId\": \"8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n    },\n    \"excludeRunIds\": [\n      \"3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41\"\n    ]\n  }\n}"

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

```java Fleet-wide rollout excluding an earlier cohort
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - fleet\",\n  \"options\": {\n    \"maxConcurrentTargets\": 12,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"phasePolicy\": {\n      \"percentage\": {\n        \"phases\": [\n          25,\n          25,\n          50\n        ]\n      },\n      \"autoAdvance\": true\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"ruleId\": \"8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n    },\n    \"excludeRunIds\": [\n      \"3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41\"\n    ]\n  }\n}")
  .asString();
```

```php Fleet-wide rollout excluding an earlier cohort
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run', [
  'body' => '{
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - fleet",
  "options": {
    "maxConcurrentTargets": 12,
    "safetyPolicy": {
      "gates": [
        {
          "failureRate": {
            "thresholdPercent": 5,
            "scope": "cumulativeRun"
          }
        }
      ]
    },
    "phasePolicy": {
      "percentage": {
        "phases": [
          25,
          25,
          50
        ]
      },
      "autoAdvance": true
    }
  },
  "operation": {
    "firmware": {
      "version": "25.03.1",
      "ruleId": "8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
    },
    "excludeRunIds": [
      "3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41"
    ]
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Fleet-wide rollout excluding an earlier cohort
using RestSharp;

var client = new RestClient("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"name\": \"Compute firmware 25.03 - fleet\",\n  \"options\": {\n    \"maxConcurrentTargets\": 12,\n    \"safetyPolicy\": {\n      \"gates\": [\n        {\n          \"failureRate\": {\n            \"thresholdPercent\": 5,\n            \"scope\": \"cumulativeRun\"\n          }\n        }\n      ]\n    },\n    \"phasePolicy\": {\n      \"percentage\": {\n        \"phases\": [\n          25,\n          25,\n          50\n        ]\n      },\n      \"autoAdvance\": true\n    }\n  },\n  \"operation\": {\n    \"firmware\": {\n      \"version\": \"25.03.1\",\n      \"ruleId\": \"8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"\n    },\n    \"excludeRunIds\": [\n      \"3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41\"\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Fleet-wide rollout excluding an earlier cohort
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "name": "Compute firmware 25.03 - fleet",
  "options": [
    "maxConcurrentTargets": 12,
    "safetyPolicy": ["gates": [["failureRate": [
            "thresholdPercent": 5,
            "scope": "cumulativeRun"
          ]]]],
    "phasePolicy": [
      "percentage": ["phases": [25, 25, 50]],
      "autoAdvance": true
    ]
  ],
  "operation": [
    "firmware": [
      "version": "25.03.1",
      "ruleId": "8f2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
    ],
    "excludeRunIds": ["3b1f0c62-9a5d-4c8e-9f10-7d2e5a6b8c41"]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/task/run")! 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()
```