# Create a WorkflowRun

URL: /docs/api/workloads/workflowrun/create

`POST /apis/funcd.io/v1alpha1/namespaces/{namespace}/workflowruns`

## Authentication

One of:

- `bearer`: A credential of funcd's config, sent as Authorization: Bearer followed by its token.
- `apiKey`: A credential of funcd's config, sent in the X-Api-Key header.

## Parameters

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `namespace` | path | string, required | The object's namespace. |
| `dryRun` | query | boolean | Admit the write and store nothing. |

## Body

`WorkflowRun` as `application/json`, required.

```json
{
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "metadata": {
      "additionalProperties": false,
      "properties": {
        "creationTimestamp": {
          "description": "When funcd created the object.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "deletionTimestamp": {
          "description": "When funcd held the object at its deletion: an object of an Engineless add-on kind with deletion: delete stays, deleting, until its Function has destroyed what it holds. funcd sets it on no other object, and a write keeps it.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "finalizers": {
          "description": "funcd does not read it.",
          "items": {
            "type": "string"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "generateName": {
          "description": "A prefix from which funcd makes the name, adding a random suffix, when a create leaves name empty.",
          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
          "type": "string"
        },
        "generation": {
          "description": "Set by funcd: 1 when the object is created, then one more each time its spec changes.",
          "format": "int64",
          "type": "integer"
        },
        "name": {
          "description": "The object's name, unique among the objects of its kind in its namespace. A create may leave it empty and set generateName instead.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "namespace": {
          "description": "The namespace the object belongs to. A cluster-scoped kind has none.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "ownerReferences": {
          "description": "The objects that own this one. funcd deletes an owned object when its owner goes.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "blockOwnerDeletion": {
                "description": "funcd does not read it.",
                "type": "boolean"
              },
              "controller": {
                "description": "Whether this owner is the one that manages the object.",
                "type": "boolean"
              },
              "kind": {
                "description": "The kind of the object it names.",
                "type": "string"
              },
              "name": {
                "description": "The name of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "namespace": {
                "description": "The namespace of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "uid": {
                "description": "The owner's unique ID.",
                "type": "string"
              }
            },
            "required": [
              "uid",
              "kind",
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "resourceGroup": {
          "description": "The resource group the object belongs to, within its namespace.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "resourceVersion": {
          "description": "An opaque version of the stored object, which funcd sets. An update that sends it gets a conflict when the object changed since; compare it for equality only.",
          "type": "string"
        },
        "tags": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Labels on the object, as keys and values.",
          "type": "object"
        },
        "uid": {
          "description": "The object's unique ID, which funcd sets when it creates the object.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "spec": {
      "additionalProperties": false,
      "properties": {
        "cancel": {
          "description": "When true, the run is cancelled: nothing more starts, the calls in flight are closed and their late answers dropped, though a call may already have done its work, and the run ends Cancelled without calling its onFailure step. It wins over paused, a finished run ignores it, and funcdctl workflow cancel sets it.",
          "type": "boolean"
        },
        "input": {
          "description": "The run input: the first step receives it, and expressions read it as input. Over workflow.payloadLimit bytes, or off the input schema in the Workflow's status.contract, it is refused at apply or fails the run when it starts. It is fixed once the run is created; a replay sets none and takes its source's."
        },
        "paused": {
          "description": "When true, the run pauses: no step or retry starts, the calls in flight finish, and paused time does not count toward the run's timeout. A run created paused waits to start, and a finished run ignores it. funcdctl workflow pause and resume set and clear it.",
          "type": "boolean"
        },
        "replay": {
          "additionalProperties": false,
          "properties": {
            "allowDrift": {
              "description": "Lets the replay re-run an image step whose artifact digest changed since the source run, on the current artifact; a child workflow's steps count too. false, the default, fails the replay with DigestDrift instead.",
              "type": "boolean"
            },
            "from": {
              "description": "The step to re-run from: it and every step that depends on it run again, a step the source never ran runs too, and the others keep the source's outputs. It is not the onFailure step, and no step outside that set may have failed or been cancelled in the source.",
              "maxLength": 63,
              "minLength": 1,
              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            },
            "run": {
              "description": "The finished run to replay: a run of the same Workflow in this namespace that workflow.retention has not removed yet.",
              "maxLength": 63,
              "minLength": 1,
              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            }
          },
          "required": [
            "run",
            "from"
          ],
          "type": "object",
          "description": "Starts the run from a finished run, as funcdctl workflow replay does: replay.from and each step that depends on it run again, and the others keep the source's outputs. It is fixed once the run is created and leaves input empty; a source that cannot seed the run fails it, and its ReplaySeeded condition says why."
        },
        "workflow": {
          "description": "The Workflow to run, in the run's namespace, fixed once the run is created. The run stays Pending while that Workflow, a child it calls or a step's Function is missing or not ready.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        }
      },
      "required": [
        "workflow"
      ],
      "type": "object"
    },
    "status": {
      "additionalProperties": false,
      "properties": {
        "conditions": {
          "description": "The conditions that explain the phase.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "lastTransitionTime": {
                "description": "When the status last changed.",
                "format": "date-time",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
                "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
                "type": "string"
              },
              "message": {
                "description": "A sentence that explains the status.",
                "type": "string"
              },
              "observedGeneration": {
                "description": "The object's generation when funcd set the condition.",
                "format": "int64",
                "type": "integer"
              },
              "reason": {
                "description": "A short CamelCase reason for the status.",
                "type": "string"
              },
              "status": {
                "description": "Whether the condition holds.",
                "type": "string"
              },
              "type": {
                "description": "What the condition reports, such as Ready.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "status"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "observedGeneration": {
          "description": "The generation of the spec that funcd last acted on.",
          "format": "int64",
          "type": "integer"
        },
        "phase": {
          "description": "Where the run is in its lifecycle: empty before the run starts, Pending while it waits for its Workflow, a child it calls or a step's Function to be ready, Running while its steps run. Succeeded, Failed and Cancelled are final.",
          "enum": [
            "Pending",
            "Running",
            "Paused",
            "Succeeded",
            "Failed",
            "Cancelled"
          ],
          "type": "string"
        },
        "pins": {
          "description": "The Function revisions the run calls, pinned before it starts: one for each Function its steps call, ref targets and child workflows' steps included. Until the run ends or is cancelled, funcd keeps these revisions, and an edit to the Workflow or a Function does not change the code the run calls.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "function": {
                "description": "The name of a Function the run's steps call.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "functionUID": {
                "description": "That Function's UID when the run started: a Function re-created under the name is not the pinned one, and a step that calls it fails.",
                "type": "string"
              },
              "imageDigest": {
                "description": "The digest of that Revision's image; empty for a file:// artifact, which has none.",
                "type": "string"
              },
              "revision": {
                "description": "The Revision the run calls: the Function's current revision when the run started.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              }
            },
            "required": [
              "function",
              "functionUID",
              "revision"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "steps": {
          "description": "Each step of the run in spec order, the onFailure step included: its phase, attempts, times and error.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "attempts": {
                "description": "The calls made to the step's Function, each carrying its number in the X-Funcd-Attempt header; 0 for a builtin or workflow step.",
                "format": "int64",
                "type": "integer"
              },
              "endedAt": {
                "description": "When the step succeeded, failed or was cancelled while running.",
                "format": "date-time",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
                "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
                "type": "string"
              },
              "error": {
                "description": "Why the step failed, or that it was cancelled while running: the first line of the cause, cut at 512 bytes.",
                "type": "string"
              },
              "name": {
                "description": "The step's name.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "phase": {
                "description": "Where the step is. It is Skipped when its when.condition is false, its join cannot be met or a step it depends on failed; a running step that a failure elsewhere stops goes back to Pending.",
                "enum": [
                  "Pending",
                  "Running",
                  "Succeeded",
                  "Failed",
                  "Skipped",
                  "Cancelled"
                ],
                "type": "string"
              },
              "revision": {
                "description": "The step's image with the digest it resolved to when the run started; empty for a builtin or workflow step. A replay compares it to detect a changed artifact.",
                "type": "string"
              },
              "startedAt": {
                "description": "When the step started running.",
                "format": "date-time",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
                "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "traceId": {
          "description": "The run's W3C trace ID, 32 lowercase hex characters, which every step call joins, a child workflow's included. funcdctl workflow logs reads the run's logs by it.",
          "type": "string"
        },
        "workflowUID": {
          "description": "The UID of the Workflow when the run started. A started run whose Workflow is deleted, or re-created under a new UID, is cancelled.",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "required": [
    "metadata",
    "spec",
    "apiVersion",
    "kind"
  ],
  "type": "object"
}
```

## Answers

| Status | Problem type | When | What to do |
| --- | --- | --- | --- |
| 200 |  | OK |  |
| 400 | `urn:funcd:problem:invalid` | A field breaks a rule that the schema cannot hold, which the detail names. | Correct the field that the detail names. |
| 400 | `urn:funcd:problem:invalid` | The body's metadata.namespace is not the namespace of the path. | Send the object to the path of its own namespace. |
| 400 | `about:blank` | The body is missing or is not JSON. | Send a JSON body. |
| 400 | `urn:funcd:problem:invalid` | The run input in spec.input does not match the input schema in the Workflow's status.contract. | Correct the fields that the detail names. |
| 401 | `urn:funcd:problem:unauthorized` | The request carries no bearer token or API key, or one that funcd does not know. | Send a credential of funcd's config as a bearer token in the Authorization header, or in X-Api-Key. |
| 403 | `urn:funcd:problem:forbidden` | The credential's role or namespaces do not allow it to create a WorkflowRun in the namespace. | Use a credential whose role allows it, such as a developer of the namespace or an admin. |
| 409 | `urn:funcd:problem:conflict` | A WorkflowRun of that name already exists in the namespace. | Start a new run under another name: a run's spec.workflow, spec.input and spec.replay are fixed once it is created, so replacing the existing run cannot change them. |
| 413 | `urn:funcd:problem:payload-too-large` | The body is larger than 1 MiB. | Send a smaller body. |
| 413 | `urn:funcd:problem:payload-too-large` | The run input in spec.input is larger than workflow.payloadLimit, 256 KiB by default. | Send a smaller input, and pass large data by reference, such as the key of an object in a Bucket. |
| 415 | `about:blank` | The Content-Type of the body is not JSON. | Send the body as application/json. |
| 422 | `about:blank` | The query holds a parameter that the operation does not take. | Send only the parameters that the operation lists. |
| 422 | `about:blank` | The dryRun parameter is neither true nor false. | Send dryRun=true, or leave it out. |
| 422 | `about:blank` | The namespace in the path is not a DNS-1123 label. | Use at most 63 lowercase letters, digits and hyphens, starting and ending with a letter or a digit. |
| 422 | `about:blank` | The body breaks the schema: a field that it does not know, of the wrong type or past its limits. | Correct the field at the location that the detail gives. |