curl --request POST \
--url https://api.example.com/task_runs/ \
--header 'Content-Type: application/json' \
--data '
{
"task_key": "<string>",
"dynamic_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": {
"name": "<string>",
"message": "<string>",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": false,
"untrackable_result": false,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": false,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": true,
"retriable": true,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": [
"<string>"
],
"labels": {
"key": "value1",
"key2": 42
},
"task_inputs": {}
}
'import requests
url = "https://api.example.com/task_runs/"
payload = {
"task_key": "<string>",
"dynamic_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": {
"name": "<string>",
"message": "<string>",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": False,
"untrackable_result": False,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": False,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": True,
"retriable": True,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": ["<string>"],
"labels": {
"key": "value1",
"key2": 42
},
"task_inputs": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
task_key: '<string>',
dynamic_key: '<string>',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
state: {
name: '<string>',
message: '<string>',
data: '<unknown>',
state_details: {
flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
task_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
child_flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
scheduled_time: '2023-11-07T05:31:56Z',
cache_key: '<string>',
cache_expiration: '2023-11-07T05:31:56Z',
deferred: false,
untrackable_result: false,
pause_timeout: '2023-11-07T05:31:56Z',
pause_reschedule: false,
pause_key: '<string>',
run_input_keyset: {},
refresh_cache: true,
retriable: true,
transition_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
task_parameters_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
traceparent: '<string>',
deployment_concurrency_lease_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
},
name: '<string>',
flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
cache_key: '<string>',
cache_expiration: '2023-11-07T05:31:56Z',
task_version: '<string>',
empirical_policy: {
max_retries: 0,
retry_delay_seconds: 0,
retries: 123,
retry_delay: 123,
retry_jitter_factor: 123
},
tags: ['<string>'],
labels: {key: 'value1', key2: 42},
task_inputs: {}
})
};
fetch('https://api.example.com/task_runs/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/task_runs/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_key' => '<string>',
'dynamic_key' => '<string>',
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'state' => [
'name' => '<string>',
'message' => '<string>',
'data' => '<unknown>',
'state_details' => [
'flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'task_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'child_flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'scheduled_time' => '2023-11-07T05:31:56Z',
'cache_key' => '<string>',
'cache_expiration' => '2023-11-07T05:31:56Z',
'deferred' => false,
'untrackable_result' => false,
'pause_timeout' => '2023-11-07T05:31:56Z',
'pause_reschedule' => false,
'pause_key' => '<string>',
'run_input_keyset' => [
],
'refresh_cache' => true,
'retriable' => true,
'transition_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'task_parameters_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'traceparent' => '<string>',
'deployment_concurrency_lease_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'name' => '<string>',
'flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'cache_key' => '<string>',
'cache_expiration' => '2023-11-07T05:31:56Z',
'task_version' => '<string>',
'empirical_policy' => [
'max_retries' => 0,
'retry_delay_seconds' => 0,
'retries' => 123,
'retry_delay' => 123,
'retry_jitter_factor' => 123
],
'tags' => [
'<string>'
],
'labels' => [
'key' => 'value1',
'key2' => 42
],
'task_inputs' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/task_runs/"
payload := strings.NewReader("{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/task_runs/")
.header("Content-Type", "application/json")
.body("{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/task_runs/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created": "2023-11-07T05:31:56Z",
"updated": "2023-11-07T05:31:56Z",
"task_key": "<string>",
"dynamic_key": "<string>",
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": [
"<string>"
],
"labels": {
"key": "value1",
"key2": 42
},
"state_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_inputs": {},
"state_name": "<string>",
"run_count": 0,
"flow_run_run_count": 0,
"expected_start_time": "2023-11-07T05:31:56Z",
"next_scheduled_start_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"total_run_time": 0,
"estimated_run_time": 0,
"estimated_start_time_delta": 0,
"state": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Run started",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": false,
"untrackable_result": false,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": false,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": true,
"retriable": true,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Create Task Run
Create a task run. If a task run with the same flow_run_id, task_key, and dynamic_key already exists, the existing task run will be returned.
If no state is provided, the task run will be created in a PENDING state.
For more information, see https://docs.prefect.io/v3/concepts/tasks.
curl --request POST \
--url https://api.example.com/task_runs/ \
--header 'Content-Type: application/json' \
--data '
{
"task_key": "<string>",
"dynamic_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": {
"name": "<string>",
"message": "<string>",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": false,
"untrackable_result": false,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": false,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": true,
"retriable": true,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": [
"<string>"
],
"labels": {
"key": "value1",
"key2": 42
},
"task_inputs": {}
}
'import requests
url = "https://api.example.com/task_runs/"
payload = {
"task_key": "<string>",
"dynamic_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": {
"name": "<string>",
"message": "<string>",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": False,
"untrackable_result": False,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": False,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": True,
"retriable": True,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
},
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": ["<string>"],
"labels": {
"key": "value1",
"key2": 42
},
"task_inputs": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
task_key: '<string>',
dynamic_key: '<string>',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
state: {
name: '<string>',
message: '<string>',
data: '<unknown>',
state_details: {
flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
task_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
child_flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
scheduled_time: '2023-11-07T05:31:56Z',
cache_key: '<string>',
cache_expiration: '2023-11-07T05:31:56Z',
deferred: false,
untrackable_result: false,
pause_timeout: '2023-11-07T05:31:56Z',
pause_reschedule: false,
pause_key: '<string>',
run_input_keyset: {},
refresh_cache: true,
retriable: true,
transition_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
task_parameters_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
traceparent: '<string>',
deployment_concurrency_lease_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
},
name: '<string>',
flow_run_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
cache_key: '<string>',
cache_expiration: '2023-11-07T05:31:56Z',
task_version: '<string>',
empirical_policy: {
max_retries: 0,
retry_delay_seconds: 0,
retries: 123,
retry_delay: 123,
retry_jitter_factor: 123
},
tags: ['<string>'],
labels: {key: 'value1', key2: 42},
task_inputs: {}
})
};
fetch('https://api.example.com/task_runs/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/task_runs/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_key' => '<string>',
'dynamic_key' => '<string>',
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'state' => [
'name' => '<string>',
'message' => '<string>',
'data' => '<unknown>',
'state_details' => [
'flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'task_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'child_flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'scheduled_time' => '2023-11-07T05:31:56Z',
'cache_key' => '<string>',
'cache_expiration' => '2023-11-07T05:31:56Z',
'deferred' => false,
'untrackable_result' => false,
'pause_timeout' => '2023-11-07T05:31:56Z',
'pause_reschedule' => false,
'pause_key' => '<string>',
'run_input_keyset' => [
],
'refresh_cache' => true,
'retriable' => true,
'transition_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'task_parameters_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'traceparent' => '<string>',
'deployment_concurrency_lease_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'name' => '<string>',
'flow_run_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'cache_key' => '<string>',
'cache_expiration' => '2023-11-07T05:31:56Z',
'task_version' => '<string>',
'empirical_policy' => [
'max_retries' => 0,
'retry_delay_seconds' => 0,
'retries' => 123,
'retry_delay' => 123,
'retry_jitter_factor' => 123
],
'tags' => [
'<string>'
],
'labels' => [
'key' => 'value1',
'key2' => 42
],
'task_inputs' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/task_runs/"
payload := strings.NewReader("{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/task_runs/")
.header("Content-Type", "application/json")
.body("{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/task_runs/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_key\": \"<string>\",\n \"dynamic_key\": \"<string>\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {\n \"name\": \"<string>\",\n \"message\": \"<string>\",\n \"data\": \"<unknown>\",\n \"state_details\": {\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"child_flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scheduled_time\": \"2023-11-07T05:31:56Z\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"deferred\": false,\n \"untrackable_result\": false,\n \"pause_timeout\": \"2023-11-07T05:31:56Z\",\n \"pause_reschedule\": false,\n \"pause_key\": \"<string>\",\n \"run_input_keyset\": {},\n \"refresh_cache\": true,\n \"retriable\": true,\n \"transition_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"task_parameters_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"traceparent\": \"<string>\",\n \"deployment_concurrency_lease_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n },\n \"name\": \"<string>\",\n \"flow_run_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"cache_key\": \"<string>\",\n \"cache_expiration\": \"2023-11-07T05:31:56Z\",\n \"task_version\": \"<string>\",\n \"empirical_policy\": {\n \"max_retries\": 0,\n \"retry_delay_seconds\": 0,\n \"retries\": 123,\n \"retry_delay\": 123,\n \"retry_jitter_factor\": 123\n },\n \"tags\": [\n \"<string>\"\n ],\n \"labels\": {\n \"key\": \"value1\",\n \"key2\": 42\n },\n \"task_inputs\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created": "2023-11-07T05:31:56Z",
"updated": "2023-11-07T05:31:56Z",
"task_key": "<string>",
"dynamic_key": "<string>",
"name": "<string>",
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"task_version": "<string>",
"empirical_policy": {
"max_retries": 0,
"retry_delay_seconds": 0,
"retries": 123,
"retry_delay": 123,
"retry_jitter_factor": 123
},
"tags": [
"<string>"
],
"labels": {
"key": "value1",
"key2": 42
},
"state_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_inputs": {},
"state_name": "<string>",
"run_count": 0,
"flow_run_run_count": 0,
"expected_start_time": "2023-11-07T05:31:56Z",
"next_scheduled_start_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"total_run_time": 0,
"estimated_run_time": 0,
"estimated_start_time_delta": 0,
"state": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Run started",
"data": "<unknown>",
"state_details": {
"flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"child_flow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_time": "2023-11-07T05:31:56Z",
"cache_key": "<string>",
"cache_expiration": "2023-11-07T05:31:56Z",
"deferred": false,
"untrackable_result": false,
"pause_timeout": "2023-11-07T05:31:56Z",
"pause_reschedule": false,
"pause_key": "<string>",
"run_input_keyset": {},
"refresh_cache": true,
"retriable": true,
"transition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task_parameters_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"traceparent": "<string>",
"deployment_concurrency_lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
Data used by the Prefect REST API to create a task run
A unique identifier for the task being run.
A dynamic key used to differentiate between multiple runs of the same task within the same flow run.
The ID to assign to the task run. If not provided, a random UUID will be generated.
The state of the task run to create
Show child attributes
Show child attributes
"my-task-run"
The flow run id of the task run.
An optional cache key. If a COMPLETED state associated with this cache key is found, the cached COMPLETED state will be used instead of executing the task run.
Specifies when the cached state should expire.
The version of the task being run.
Defines of how a task run should retry.
Show child attributes
Show child attributes
A list of tags for the task run.
["tag-1", "tag-2"]
A dictionary of key-value labels. Values can be strings, numbers, or booleans.
Show child attributes
Show child attributes
{ "key": "value1", "key2": 42 }
The inputs to the task run.
Show child attributes
Show child attributes
Response
Successful Response
An ORM representation of task run data.
A unique identifier for the task being run.
A dynamic key used to differentiate between multiple runs of the same task within the same flow run.
"my-task-run"
The flow run id of the task run.
An optional cache key. If a COMPLETED state associated with this cache key is found, the cached COMPLETED state will be used instead of executing the task run.
Specifies when the cached state should expire.
The version of the task being run.
Defines of how a task run should retry.
Show child attributes
Show child attributes
A list of tags for the task run.
["tag-1", "tag-2"]
A dictionary of key-value labels. Values can be strings, numbers, or booleans.
Show child attributes
Show child attributes
{ "key": "value1", "key2": 42 }
The id of the current task run state.
Tracks the source of inputs to a task run. Used for internal bookkeeping.
Show child attributes
Show child attributes
The type of the current task run state.
SCHEDULED, PENDING, RUNNING, COMPLETED, FAILED, CANCELLED, CRASHED, PAUSED, CANCELLING The name of the current task run state.
The number of times the task run has been executed.
If the parent flow has retried, this indicates the flow retry this run is associated with.
The task run's expected start time.
The next time the task run is scheduled to start.
The actual start time.
The actual end time.
Total run time. If the task run was executed multiple times, the time of each run will be summed.
A real-time estimate of total run time.
The difference between actual and expected start time.
The current task run state.
Show child attributes
Show child attributes
Was this page helpful?