pub struct CreateRunRequest {
pub workflow: String,
pub payload: Option<Value>,
pub labels: Option<HashMap<String, String>>,
pub scheduled_at: Option<DateTime<Utc>>,
pub max_retries: Option<u32>,
pub max_cost_usd: Option<Decimal>,
pub concurrency_key: Option<String>,
}Expand description
Request to trigger a workflow.
§Examples
use ironflow_api::entities::CreateRunRequest;
use serde_json::json;
let req = CreateRunRequest {
workflow: "deploy".to_string(),
payload: Some(json!({"env": "prod"})),
labels: None,
scheduled_at: None,
max_retries: Some(2),
max_cost_usd: None,
concurrency_key: Some("issue:12".to_string()),
};
assert_eq!(req.workflow, "deploy");Fields§
§workflow: StringThe workflow name to trigger.
payload: Option<Value>Optional input payload for the workflow.
labels: Option<HashMap<String, String>>Optional key-value labels for categorization and filtering.
scheduled_at: Option<DateTime<Utc>>Optional deferred execution time. None means run immediately.
max_retries: Option<u32>How many times the run may be replayed automatically after a transient
failure. Defaults to 0, meaning no automatic retry.
Each retry waits an exponential backoff (30 s, 2 min, 8 min, capped at 15 min) before the run is replayed from the start. Failures that cannot succeed on replay – an unknown workflow, an invalid payload, an exhausted agent budget, a rejected approval, a manual cancellation – consume no attempt.
max_cost_usd: Option<Decimal>Optional cumulative cost cap for this run, in USD.
Overrides the workflow default and the server default. None falls back
to those. Must be zero or positive.
concurrency_key: Option<String>Optional exclusivity key, at most 255 bytes.
While a non-terminal run (pending, running, sleeping, retrying,
awaiting approval) holds the same key, the request is refused with
409 CONCURRENCY_CONFLICT naming that run. The key is released when
the run completes, fails, ends with a warning or is cancelled.
Implementations§
Source§impl CreateRunRequest
impl CreateRunRequest
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the request body.
§Errors
Returns a human-readable message when max_cost_usd is negative, or
when concurrency_key is blank or longer than
MAX_CONCURRENCY_KEY_LEN bytes.
§Examples
use ironflow_api::entities::CreateRunRequest;
use rust_decimal::Decimal;
let req = CreateRunRequest {
workflow: "deploy".to_string(),
payload: None,
labels: None,
scheduled_at: None,
max_retries: None,
max_cost_usd: Some(Decimal::new(-1, 0)),
concurrency_key: None,
};
assert!(req.validate().is_err());