{
    "openapi": "3.1.0",
    "info": {
        "title": "Cbox Flow API",
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "https://api.cboxflow.com"
        }
    ],
    "security": [
        {
            "bearer": []
        }
    ],
    "paths": {
        "/v1/approvals": {
            "get": {
                "operationId": "listApprovals",
                "summary": "List approvals, newest first; pending ones are what executions are waiting on.",
                "tags": [
                    "Approvals"
                ],
                "x-permission": "flow:approvals:read",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "pending",
                                "approved",
                                "rejected",
                                "expired",
                                "cancelled"
                            ]
                        }
                    },
                    {
                        "name": "execution_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/approvals/{approval_id}": {
            "get": {
                "operationId": "getApproval",
                "summary": "One approval: what it asks, who may decide it and how it was decided.",
                "tags": [
                    "Approvals"
                ],
                "x-permission": "flow:approvals:read",
                "parameters": [
                    {
                        "name": "approval_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/approvals/{approval_id}/decision": {
            "post": {
                "operationId": "decideApproval",
                "summary": "Approve or reject a pending approval.",
                "tags": [
                    "Approvals"
                ],
                "x-permission": "flow:approvals:write",
                "description": "Only a person can decide, with a role the step lists in `approvers`, and not the person who started the execution unless the step sets allow_self_approval. Approved continues the execution with {decision, decided_by, comment} as the step's result; rejected fails the step and the execution. A decided approval answers 409 approval_decided, an expired one 409 approval_expired.",
                "parameters": [
                    {
                        "name": "approval_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "decision": {
                                        "type": "string",
                                        "enum": [
                                            "approve",
                                            "reject"
                                        ]
                                    },
                                    "comment": {
                                        "type": "string",
                                        "maxLength": 2000,
                                        "nullable": true
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "decision"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/billing-details": {
            "get": {
                "operationId": "getBillingDetails",
                "summary": "The organization's billing address and whether its plan is active in billing.",
                "tags": [
                    "Organization"
                ],
                "x-permission": "flow:organization:write",
                "description": "subscribed is false until a full billing address is saved: the plan starts then. 503 billing_unavailable when billing cannot be reached.",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateBillingDetails",
                "summary": "Save the organization's billing address. When the plan has not started yet, it starts now.",
                "tags": [
                    "Organization"
                ],
                "x-permission": "flow:organization:write",
                "description": "Invoices print this address and tax is worked out from it. Some countries also need the state or region (subdivision, such as US-CA). 422 billing_address_required names what billing still misses.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "country": {
                                        "type": "string",
                                        "maxLength": 2,
                                        "minLength": 2,
                                        "description": "ISO 3166-1 alpha-2, such as DK."
                                    },
                                    "address_line1": {
                                        "type": "string",
                                        "maxLength": 190,
                                        "minLength": 1
                                    },
                                    "address_line2": {
                                        "type": "string",
                                        "maxLength": 190,
                                        "nullable": true
                                    },
                                    "postal_code": {
                                        "type": "string",
                                        "maxLength": 32,
                                        "minLength": 1
                                    },
                                    "city": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "minLength": 1
                                    },
                                    "subdivision": {
                                        "type": "string",
                                        "maxLength": 6,
                                        "nullable": true,
                                        "description": "ISO 3166-2 subdivision where the country needs one, such as US-CA."
                                    },
                                    "billing_email": {
                                        "type": "string",
                                        "maxLength": 190,
                                        "nullable": true,
                                        "description": "Where invoices are sent."
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "country",
                                    "address_line1",
                                    "postal_code",
                                    "city"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/caller": {
            "get": {
                "operationId": "getCaller",
                "summary": "Who you act as, in which organization, and what you may do.",
                "tags": [
                    "Organization"
                ],
                "x-permission": "flow:organization:read",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/connections": {
            "get": {
                "operationId": "listConnections",
                "summary": "The Cbox services this organization connected Flow to.",
                "tags": [
                    "Connections"
                ],
                "x-permission": "flow:connections:read",
                "parameters": [
                    {
                        "name": "service",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "commerce"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createConnection",
                "summary": "Connect Flow to a Cbox service with an access key from that service.",
                "tags": [
                    "Connections"
                ],
                "x-permission": "flow:connections:write",
                "description": "Create a service or agent access key in the service with only the permissions your workflows need, and paste it here. Flow checks it with the service and keeps it encrypted; it is never shown again. A key the service does not accept is 422 connection_key_refused.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "service": {
                                        "type": "string",
                                        "enum": [
                                            "commerce"
                                        ]
                                    },
                                    "name": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "minLength": 1
                                    },
                                    "key": {
                                        "type": "string",
                                        "maxLength": 400,
                                        "minLength": 8
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "service",
                                    "name",
                                    "key"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/connections/{connection_id}": {
            "get": {
                "operationId": "getConnection",
                "summary": "One connection: its service, who its key acts as there and what it may do.",
                "tags": [
                    "Connections"
                ],
                "x-permission": "flow:connections:read",
                "parameters": [
                    {
                        "name": "connection_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateConnection",
                "summary": "Rename a connection or replace its key.",
                "tags": [
                    "Connections"
                ],
                "x-permission": "flow:connections:write",
                "description": "A new key is checked with the service before it replaces the old one; triggers and steps keep working with the new key at once.",
                "parameters": [
                    {
                        "name": "connection_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "minLength": 1
                                    },
                                    "key": {
                                        "type": "string",
                                        "maxLength": 400,
                                        "minLength": 8
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteConnection",
                "summary": "Remove a connection. Revoke its key in the service too.",
                "tags": [
                    "Connections"
                ],
                "x-permission": "flow:connections:write",
                "description": "A connection an event trigger still uses answers 409 connection_in_use; delete the trigger first.",
                "parameters": [
                    {
                        "name": "connection_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions": {
            "get": {
                "operationId": "listExecutions",
                "summary": "List executions, newest first.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:read",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "queued",
                                "running",
                                "paused",
                                "compensating",
                                "succeeded",
                                "failed",
                                "cancelled"
                            ]
                        }
                    },
                    {
                        "name": "trigger",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "manual",
                                "api",
                                "agent",
                                "webhook",
                                "schedule",
                                "event",
                                "approval",
                                "workflow"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}": {
            "get": {
                "operationId": "getExecution",
                "summary": "One execution with its steps, what each ran with, every failed attempt, and its history.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:read",
                "description": "Each step has `input` (the arguments its latest attempt ran with; values under keys that name a credential, such as authorization, token or secret, read [redacted]) and `failures` (every failed attempt, oldest first). `history` holds the first 200 events; when `history_has_more` is true, read the rest with listExecutionEvents from `history_next_cursor`.",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/cancel": {
            "post": {
                "operationId": "cancelExecution",
                "summary": "Cancel an unfinished execution and its subworkflows.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "description": "Steps no worker holds never run. A step already running finishes and its result is kept, but nothing comes after it. A finished execution answers 409 execution_finished.",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/events": {
            "get": {
                "operationId": "listExecutionEvents",
                "summary": "An execution's history, oldest first: every start, attempt, retry, branch, wait and finish.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:read",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "step_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 63,
                            "description": "Only this step's events (all its loop items)."
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/pause": {
            "post": {
                "operationId": "pauseExecution",
                "summary": "Pause a running execution; no new step starts until it is resumed.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "description": "A step already running finishes. Timers keep counting, and so does the execution's timeout_seconds.",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/replay": {
            "post": {
                "operationId": "replayExecution",
                "summary": "Run a finished execution again as a new one, on the same version.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "description": "Without from_step every step runs again. With from_step the steps before it are copied from the original, not run again, and the original input is kept. Steps that run again get new idempotency keys, so an outside service sees new requests: Flow does not claim exactly-once effects across a replay. When any step that would run reaches outside Flow (anything but transform and wait), allow_side_effects must be true, or the answer is 422 side_effects_not_allowed naming those steps.",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "from_step": {
                                        "type": "string",
                                        "maxLength": 63,
                                        "description": "A step the original reached; the replay starts there."
                                    },
                                    "input": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "Other input for a replay from the start. Defaults to the original input."
                                    },
                                    "allow_side_effects": {
                                        "type": "boolean",
                                        "description": "Run steps that reach outside Flow again."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/resume": {
            "post": {
                "operationId": "resumeExecution",
                "summary": "Resume a paused execution.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/executions/{execution_id}/signals": {
            "post": {
                "operationId": "signalExecution",
                "summary": "Send a named signal to an execution waiting for it.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "description": "The earliest signal.wait step of the execution waiting for `name` succeeds with {signal, payload, sent_by} as its result, and the execution goes on. A signal nothing is waiting for is not kept: the answer is 409 signal_not_awaited, and the sender may retry.",
                "parameters": [
                    {
                        "name": "execution_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 100,
                                        "minLength": 1,
                                        "description": "The signal name the step waits for."
                                    },
                                    "payload": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "Data for the workflow; it becomes the step's result.payload."
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "name"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/plan": {
            "get": {
                "operationId": "getPlan",
                "summary": "Your organization's plan, what it allows, and the steps metered this month.",
                "tags": [
                    "Organization"
                ],
                "x-permission": "flow:organization:read",
                "description": "Steps past what the plan includes are billed, never refused. Waits, timers and retries are free; an agent step counts as 10. Limits of null are unlimited.",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/plans": {
            "get": {
                "operationId": "listPlans",
                "summary": "The plans Flow is sold on, from the local copy of Cbox Billing's catalog.",
                "tags": [
                    "Organization"
                ],
                "x-permission": "flow:organization:read",
                "description": "Read from the copy synced hourly and on plan.changed, never live from Billing. Net prices in minor units per currency. 503 plans_unavailable when no copy has ever been synced.",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/triggers": {
            "get": {
                "operationId": "listTriggers",
                "summary": "List triggers, newest first.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:read",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "webhook",
                                "schedule",
                                "event",
                                "approval"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/triggers/{trigger_id}": {
            "get": {
                "operationId": "getTrigger",
                "summary": "One trigger, when it last fired and its last error.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:read",
                "parameters": [
                    {
                        "name": "trigger_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateTrigger",
                "summary": "Rename, pause, resume or reschedule a trigger, or change its fixed input.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:write",
                "parameters": [
                    {
                        "name": "trigger_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "minLength": 1
                                    },
                                    "enabled": {
                                        "type": "boolean"
                                    },
                                    "input": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "Fixed input, by name. What a webhook delivery sends is merged over it."
                                    },
                                    "payload_input": {
                                        "type": "string",
                                        "maxLength": 63,
                                        "nullable": true,
                                        "description": "Webhook only: the object input that receives the whole request body. Without it, the body's keys are the inputs."
                                    },
                                    "cron": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "description": "Schedule only: a five-field cron expression, such as `0 7 * * 1-5`."
                                    },
                                    "timezone": {
                                        "type": "string",
                                        "maxLength": 64,
                                        "description": "Schedule only: an IANA time zone, such as `Europe/Copenhagen`. Default UTC."
                                    },
                                    "events": {
                                        "type": "array",
                                        "maxItems": 20,
                                        "items": {
                                            "type": "string"
                                        },
                                        "description": "Event: the Cbox event types that start the workflow, such as `commerce.order.paid` or `commerce.order.*`. Approval: the decisions that start it, from approved, rejected and expired."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteTrigger",
                "summary": "Delete a trigger. Executions it started are kept.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:write",
                "parameters": [
                    {
                        "name": "trigger_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/triggers/{trigger_id}/rotate-secret": {
            "post": {
                "operationId": "rotateTriggerSecret",
                "summary": "Give a webhook trigger a new signing secret; the old one stops working at once.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:write",
                "parameters": [
                    {
                        "name": "trigger_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflow-definitions/validate": {
            "post": {
                "operationId": "validateDefinition",
                "summary": "Check a definition without saving it.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "description": "Answers `valid`, the errors by JSON path, the hash and the input and output schemas.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "definition": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The definition as JSON (format cbox-flow/v1, see /schemas/workflow-definition/v1.json)."
                                    },
                                    "definition_yaml": {
                                        "type": "string",
                                        "maxLength": 262144,
                                        "description": "The same definition as YAML, instead of `definition`. Stored as JSON. Quote dates: unquoted YAML dates become numbers."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflow-templates": {
            "get": {
                "operationId": "listWorkflowTemplates",
                "summary": "Workflow templates to start a new workflow from.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflow-templates/{template_key}": {
            "get": {
                "operationId": "getWorkflowTemplate",
                "summary": "One workflow template with its definition.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "parameters": [
                    {
                        "name": "template_key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 80
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflow-versions/{version_id}": {
            "get": {
                "operationId": "getWorkflowVersion",
                "summary": "One published version: its frozen definition, hash and input and output schemas.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "parameters": [
                    {
                        "name": "version_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows": {
            "post": {
                "operationId": "createWorkflow",
                "summary": "Create a workflow with a draft definition.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:write",
                "description": "Without a definition the draft starts from a one-step starter. Nothing runs until a version is published.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 255,
                                        "minLength": 1
                                    },
                                    "handle": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "description": "Unique per organization; derived from the name when left out."
                                    },
                                    "description": {
                                        "type": "string",
                                        "maxLength": 2000,
                                        "nullable": true
                                    },
                                    "template": {
                                        "type": "string",
                                        "maxLength": 80,
                                        "description": "Start the draft from a workflow template (see listWorkflowTemplates) instead of a definition."
                                    },
                                    "definition": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The definition as JSON (format cbox-flow/v1, see /schemas/workflow-definition/v1.json)."
                                    },
                                    "definition_yaml": {
                                        "type": "string",
                                        "maxLength": 262144,
                                        "description": "The same definition as YAML, instead of `definition`. Stored as JSON. Quote dates: unquoted YAML dates become numbers."
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "name"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "operationId": "listWorkflows",
                "summary": "List workflows, newest first.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}": {
            "get": {
                "operationId": "getWorkflow",
                "summary": "One workflow with its draft, whether the draft is valid, and its published version.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateWorkflow",
                "summary": "Change a workflow's name, description or draft. Published versions are not touched.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:write",
                "description": "Pass `revision` to refuse a change made on a stale copy. A draft may be saved while invalid; publishing checks it.",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "revision": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "description": "Optimistic concurrency: the revision you read."
                                    },
                                    "name": {
                                        "type": "string",
                                        "maxLength": 255,
                                        "minLength": 1
                                    },
                                    "description": {
                                        "type": "string",
                                        "maxLength": 2000,
                                        "nullable": true
                                    },
                                    "definition": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The definition as JSON (format cbox-flow/v1, see /schemas/workflow-definition/v1.json)."
                                    },
                                    "definition_yaml": {
                                        "type": "string",
                                        "maxLength": 262144,
                                        "description": "The same definition as YAML, instead of `definition`. Stored as JSON. Quote dates: unquoted YAML dates become numbers."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}/executions": {
            "post": {
                "operationId": "startExecution",
                "summary": "Run the workflow's current published version.",
                "tags": [
                    "Executions"
                ],
                "x-permission": "flow:executions:write",
                "description": "The input is checked against the version's typed inputs and defaults are filled in. Send an Idempotency-Key so a retried request starts one execution: the same key with the same input answers the first execution for 24 hours (Idempotent-Replayed: true), the same key with other input is refused (422 idempotency_key_reused).",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "input": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The execution's input by name."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}/publish": {
            "post": {
                "operationId": "publishWorkflow",
                "summary": "Freeze the draft as the next immutable version and make it the one new executions use.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:versions:write",
                "description": "Refused when the draft is invalid or identical to the current version. Running executions keep the version they started with.",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "revision": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "description": "Publish only if the draft is still at this revision."
                                    },
                                    "note": {
                                        "type": "string",
                                        "maxLength": 500,
                                        "nullable": true,
                                        "description": "What changed, for the version history."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}/simulate": {
            "post": {
                "operationId": "simulateWorkflow",
                "summary": "Walk the draft with an input and mocked step results, without running anything.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "description": "Uses the same conditions, branches, loops and expressions as a real run. `transform` steps compute; every other step answers `mocks.<step_id>` (or `{}`). Nothing is stored, sent, metered or waited for. Send `definition` or `definition_yaml` to simulate that instead of the draft.",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "input": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The execution's input by name."
                                    },
                                    "mocks": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "A result per step id for steps that are not transforms."
                                    },
                                    "definition": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "The definition as JSON (format cbox-flow/v1, see /schemas/workflow-definition/v1.json)."
                                    },
                                    "definition_yaml": {
                                        "type": "string",
                                        "maxLength": 262144,
                                        "description": "The same definition as YAML, instead of `definition`. Stored as JSON. Quote dates: unquoted YAML dates become numbers."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}/triggers": {
            "post": {
                "operationId": "createTrigger",
                "summary": "Add a webhook or schedule trigger to a workflow.",
                "tags": [
                    "Triggers"
                ],
                "x-permission": "flow:triggers:write",
                "description": "A webhook trigger answers its URL and its signing secret once; keep the secret, it is not shown again. A schedule trigger answers when it is next due. An event trigger subscribes to a connected Cbox service's events (FLW-TRG-003): Flow registers a webhook endpoint there with the connection's key (it needs that service's admin rights), and each event starts the workflow with the event in `payload_input`.",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "webhook",
                                            "schedule",
                                            "event",
                                            "approval"
                                        ]
                                    },
                                    "connection_id": {
                                        "type": "string",
                                        "maxLength": 40,
                                        "description": "Event only: the connection to the service that sends the events."
                                    },
                                    "name": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "minLength": 1
                                    },
                                    "enabled": {
                                        "type": "boolean"
                                    },
                                    "input": {
                                        "type": "object",
                                        "additionalProperties": true,
                                        "description": "Fixed input, by name. What a webhook delivery sends is merged over it."
                                    },
                                    "payload_input": {
                                        "type": "string",
                                        "maxLength": 63,
                                        "nullable": true,
                                        "description": "Webhook only: the object input that receives the whole request body. Without it, the body's keys are the inputs."
                                    },
                                    "cron": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "description": "Schedule only: a five-field cron expression, such as `0 7 * * 1-5`."
                                    },
                                    "timezone": {
                                        "type": "string",
                                        "maxLength": 64,
                                        "description": "Schedule only: an IANA time zone, such as `Europe/Copenhagen`. Default UTC."
                                    },
                                    "events": {
                                        "type": "array",
                                        "maxItems": 20,
                                        "items": {
                                            "type": "string"
                                        },
                                        "description": "Event: the Cbox event types that start the workflow, such as `commerce.order.paid` or `commerce.order.*`. Approval: the decisions that start it, from approved, rejected and expired."
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "type"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/workflows/{workflow_id}/versions": {
            "get": {
                "operationId": "listWorkflowVersions",
                "summary": "A workflow's published versions, newest first.",
                "tags": [
                    "Workflows"
                ],
                "x-permission": "flow:workflows:read",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 40
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "description": "Page size, 1 to 100; 25 when left out."
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 512,
                            "description": "`next_cursor` from the previous page."
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "A refusal",
                        "content": {
                            "application/problem+json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Problem"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "Problem": {
                "type": "object",
                "required": [
                    "type",
                    "title",
                    "status",
                    "detail",
                    "code"
                ],
                "properties": {
                    "type": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "status": {
                        "type": "integer"
                    },
                    "detail": {
                        "type": "string"
                    },
                    "code": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}
