# Cancel a waterfall run (/docs/api/waterfalls/waterfall_cancel)

Stop a queued or running run. In-flight attempts are aborted and released; the partial result is kept.

`POST /v1/waterfalls/{id}/runs/{run_id}/cancel`

```json
{
  "operationId": "waterfall_cancel",
  "summary": "Cancel a waterfall run",
  "description": "Stop a queued or running run. In-flight attempts are aborted and released; the partial result is kept.",
  "tags": [
    "waterfalls"
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "pattern": "^wf_[a-z0-9]{8,40}$"
      },
      "required": true,
      "name": "id",
      "in": "path"
    },
    {
      "schema": {
        "type": "string",
        "pattern": "^wfr_[a-z0-9]{8,64}$"
      },
      "required": true,
      "name": "run_id",
      "in": "path"
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "object": {
                "type": "string",
                "enum": [
                  "waterfall_run"
                ]
              },
              "id": {
                "type": "string",
                "pattern": "^wfr_[a-z0-9]{8,64}$"
              },
              "waterfall_id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "sync",
                  "wait",
                  "async",
                  "batch",
                  "list",
                  "scheduled",
                  "test"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "queued",
                  "running",
                  "completed",
                  "failed",
                  "cancelled"
                ]
              },
              "outcome": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "hit",
                  "partial",
                  "miss",
                  "failed",
                  null
                ]
              },
              "stop_reason": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "first_hit",
                  "first_verified",
                  "until_fields_filled",
                  "all_then_merge",
                  "condition",
                  "exhausted",
                  "budget_exceeded",
                  "deadline_exceeded",
                  "cancelled",
                  "account_error",
                  null
                ]
              },
              "data": {
                "type": "object",
                "additionalProperties": {}
              },
              "_provenance": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "type": "string"
                    },
                    "endpoint_id": {
                      "type": "string"
                    },
                    "call_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "stage_id": {
                      "type": "string"
                    },
                    "step_id": {
                      "type": "string"
                    },
                    "fetched_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "confidence": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "verified": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "strategy": {
                      "type": "string",
                      "enum": [
                        "highest_quality",
                        "consensus",
                        "most_recent",
                        "prefer_verified",
                        "first_non_null",
                        "union"
                      ]
                    },
                    "conflicts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider": {
                            "type": "string"
                          },
                          "value": {}
                        },
                        "required": [
                          "provider"
                        ]
                      },
                      "maxItems": 20,
                      "default": []
                    }
                  },
                  "required": [
                    "provider",
                    "endpoint_id",
                    "call_id",
                    "stage_id",
                    "step_id",
                    "fetched_at",
                    "confidence",
                    "verified",
                    "strategy"
                  ]
                }
              },
              "_attempts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "stage_id": {
                      "type": "string"
                    },
                    "step_id": {
                      "type": "string"
                    },
                    "endpoint_id": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "call_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "hit",
                        "miss",
                        "failed",
                        "skipped",
                        "timeout",
                        "cancelled"
                      ]
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "circuit_open",
                        "over_step_budget",
                        "over_run_budget",
                        "missing_input",
                        "unsupported_mode",
                        "not_eligible",
                        "condition_false",
                        "deadline",
                        "stopped",
                        "low_confidence",
                        "missing_fields",
                        "unverified",
                        "client_error",
                        "rate_limited",
                        "server_error",
                        "timeout",
                        "account",
                        null
                      ]
                    },
                    "try": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "hedged": {
                      "type": "boolean"
                    },
                    "cost_micro": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "quote_micro": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "started_ms": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "latency_ms": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "verified": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "confidence": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "error": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request",
                            "unauthorized",
                            "insufficient_balance",
                            "max_cost_exceeded",
                            "scope_denied",
                            "budget_blocked",
                            "not_found",
                            "idempotency_mismatch",
                            "invalid_meta",
                            "rate_limited",
                            "upstream_error",
                            "response_buffer_limit",
                            "provider_capacity_unavailable",
                            "grid_saturated",
                            "upstream_timeout",
                            "conflict",
                            "internal_error",
                            "account_frozen",
                            "strict_filters",
                            "plan_limit_reached",
                            "validation_failed",
                            "deadline_exceeded",
                            "cancelled"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "maxLength": 500
                        },
                        "upstream_status": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "retry_after_ms": {
                          "type": [
                            "integer",
                            "null"
                          ],
                          "minimum": 0
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "upstream_status",
                        "retry_after_ms"
                      ]
                    },
                    "raw": {}
                  },
                  "required": [
                    "stage_id",
                    "step_id",
                    "endpoint_id",
                    "provider",
                    "call_id",
                    "status",
                    "reason",
                    "try",
                    "hedged",
                    "cost_micro",
                    "quote_micro",
                    "started_ms",
                    "latency_ms",
                    "verified",
                    "confidence",
                    "fields",
                    "error"
                  ]
                }
              },
              "stages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "stage_id": {
                      "type": "string"
                    },
                    "capability": {
                      "type": "string"
                    },
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "hit",
                        "partial",
                        "miss",
                        "failed"
                      ]
                    },
                    "stop_reason": {
                      "type": "string",
                      "enum": [
                        "first_hit",
                        "first_verified",
                        "until_fields_filled",
                        "all_then_merge",
                        "condition",
                        "exhausted",
                        "budget_exceeded",
                        "deadline_exceeded",
                        "cancelled",
                        "account_error"
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": {}
                    },
                    "cost_micro": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "latency_ms": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "stage_id",
                    "capability",
                    "outcome",
                    "stop_reason",
                    "data",
                    "cost_micro",
                    "latency_ms"
                  ]
                }
              },
              "fields_filled": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "cost_micro": {
                "type": "integer",
                "minimum": 0
              },
              "cost_per_field_micro": {
                "type": "integer",
                "minimum": 0
              },
              "latency_ms": {
                "type": "integer",
                "minimum": 0
              },
              "input": {
                "type": "object",
                "additionalProperties": {}
              },
              "error": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "invalid_request",
                      "unauthorized",
                      "insufficient_balance",
                      "max_cost_exceeded",
                      "scope_denied",
                      "budget_blocked",
                      "not_found",
                      "idempotency_mismatch",
                      "invalid_meta",
                      "rate_limited",
                      "upstream_error",
                      "response_buffer_limit",
                      "provider_capacity_unavailable",
                      "grid_saturated",
                      "upstream_timeout",
                      "conflict",
                      "internal_error",
                      "account_frozen",
                      "strict_filters",
                      "plan_limit_reached",
                      "validation_failed",
                      "deadline_exceeded",
                      "cancelled"
                    ]
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              },
              "batch_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "completed_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "cache": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "hit",
                      "partial",
                      "miss",
                      "stale",
                      "bypass"
                    ]
                  },
                  "age_s": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "fetched_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "saved_micro": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "fields_cached": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 80
                    },
                    "maxItems": 100
                  },
                  "fields_fetched": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 80
                    },
                    "maxItems": 100
                  }
                },
                "required": [
                  "status",
                  "age_s",
                  "fetched_at",
                  "saved_micro"
                ]
              }
            },
            "required": [
              "object",
              "id",
              "waterfall_id",
              "version",
              "mode",
              "status",
              "outcome",
              "stop_reason",
              "data",
              "_provenance",
              "_attempts",
              "stages",
              "fields_filled",
              "cost_micro",
              "cost_per_field_micro",
              "latency_ms",
              "error",
              "batch_id",
              "created_at",
              "completed_at"
            ]
          }
        }
      }
    },
    "default": {
      "description": "Error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "invalid_request",
                      "unauthorized",
                      "insufficient_balance",
                      "max_cost_exceeded",
                      "scope_denied",
                      "budget_blocked",
                      "not_found",
                      "idempotency_mismatch",
                      "invalid_meta",
                      "rate_limited",
                      "upstream_error",
                      "response_buffer_limit",
                      "provider_capacity_unavailable",
                      "grid_saturated",
                      "upstream_timeout",
                      "conflict",
                      "internal_error",
                      "account_frozen",
                      "strict_filters",
                      "plan_limit_reached",
                      "validation_failed",
                      "deadline_exceeded",
                      "cancelled"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "request_id": {
                    "type": "string"
                  },
                  "call_id": {
                    "type": "string"
                  },
                  "retry_after_ms": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "details": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              }
            },
            "required": [
              "error"
            ]
          }
        }
      }
    }
  }
}
```
