v50

latestOpenAPI 3.1.0raw.githubusercontent.com2025-01-16170291390.7 KB
Task Runs

Read Task Runs

Query for task runs.

post/api/task_runs/filter

Headers

x-prefect-api-versionstring

Request body

sort'ID_DESC' | 'EXPECTED_START_TIME_ASC' | 'EXPECTED_START_TIME_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'NEXT_SCHEDULED_START_TIME_ASC' | 'END_TIME_DESC'

Defines task run sorting options.

offsetinteger
limitinteger

Defaults to PREFECT_API_DEFAULT_LIMIT if not provided.

Example request

{
  "flows": {
    "name": {
      "any_": [
        "my-flow-1",
        "my-flow-2"
      ],
      "like_": "marvin"
    },
    "tags": {
      "all_": [
        "tag-1",
        "tag-2"
      ]
    }
  },
  "flow_runs": {
    "name": {
      "any_": [
        "my-flow-run-1",
        "my-flow-run-2"
      ],
      "like_": "marvin"
    },
    "tags": {
      "all_": [
        "tag-1",
        "tag-2"
      ]
    },
    "work_queue_name": {
      "any_": [
        "work_queue_1",
        "work_queue_2"
      ]
    }
  },
  "task_runs": {
    "name": {
      "any_": [
        "my-task-run-1",
        "my-task-run-2"
      ],
      "like_": "marvin"
    },
    "tags": {
      "all_": [
        "tag-1",
        "tag-2"
      ]
    }
  },
  "deployments": {
    "name": {
      "any_": [
        "my-deployment-1",
        "my-deployment-2"
      ],
      "like_": "marvin"
    },
    "tags": {
      "all_": [
        "tag-1",
        "tag-2"
      ]
    },
    "work_queue_name": {
      "any_": [
        "work_queue_1",
        "work_queue_2"
      ]
    }
  }
}

Response

Successful Response

idstring uuid
createdstring date-time
updatedstring date-time
namestring
flow_run_idstring uuid

The flow run id of the task run.

task_keystring required

A unique identifier for the task being run.

dynamic_keystring required

A dynamic key used to differentiate between multiple runs of the same task within the same flow run.

cache_keystring

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.

cache_expirationstring date-time

Specifies when the cached state should expire.

task_versionstring

The version of the task being run.

tagsstring[]

A list of tags for the task run.

state_idstring uuid

The id of the current task run state.

task_inputsobject

Tracks the source of inputs to a task run. Used for internal bookkeeping.

state_type'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING'

Enumeration of state types.

state_namestring

The name of the current task run state.

run_countinteger

The number of times the task run has been executed.

flow_run_run_countinteger

If the parent flow has retried, this indicates the flow retry this run is associated with.

expected_start_timestring date-time

The task run's expected start time.

next_scheduled_start_timestring date-time

The next time the task run is scheduled to start.

start_timestring date-time

The actual start time.

end_timestring date-time

The actual end time.

total_run_timenumber

Total run time. If the task run was executed multiple times, the time of each run will be summed.

estimated_run_timenumber

A real-time estimate of total run time.

estimated_start_time_deltanumber

The difference between actual and expected start time.

Example response

[
  {
    "name": "my-task-run",
    "tags": [
      "tag-1",
      "tag-2"
    ],
    "state": {
      "message": "Run started"
    }
  }
]