{
    "openapi": "3.1.0",
    "info": {
        "title": "OpsBrain API",
        "version": "1.0.0",
        "description": "Read an organization's workflows, runs, flags, teams, members, insights and suggestions, queue runs, resolve or reopen flags, and start draft workflows from text. Authenticate with an organization API key as a Bearer token; each operation lists the scopes it needs in x-required-scopes. Lists use cursor pagination (limit and cursor, with meta.next_cursor). Errors are application/problem+json with a stable code. Every response carries X-Request-Id. Changes inside v1 only add fields and endpoints.",
        "contact": {
            "name": "OpsBrain support",
            "url": "https://opsbrain.io/help"
        }
    },
    "servers": [
        {
            "url": "https://app.opsbrain.io/api/v1"
        }
    ],
    "security": [
        {
            "ApiKey": []
        }
    ],
    "tags": [
        {
            "name": "Account",
            "description": "The key and organization behind a request."
        },
        {
            "name": "Workflows",
            "description": "Workflows, their versions and steps, and drafts started from text."
        },
        {
            "name": "Runs",
            "description": "Runs and their audit trail, and queueing new runs."
        },
        {
            "name": "Flags",
            "description": "Flags workers raised on steps."
        },
        {
            "name": "Teams",
            "description": "Teams and their queues."
        },
        {
            "name": "Insights",
            "description": "Health and performance from the nightly snapshots."
        },
        {
            "name": "Members",
            "description": "People in the organization."
        },
        {
            "name": "Suggestions",
            "description": "Suggestions for improving workflows."
        }
    ],
    "paths": {
        "/me": {
            "get": {
                "operationId": "getMe",
                "tags": [
                    "Account"
                ],
                "summary": "Show the key and organization",
                "description": "Returns the organization and key behind the request and the key's scopes. Works with any valid key, so it is a quick way to check a key.",
                "x-required-scopes": [],
                "responses": {
                    "200": {
                        "description": "The key and its organization.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MeResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/workflows": {
            "get": {
                "operationId": "listWorkflows",
                "tags": [
                    "Workflows"
                ],
                "summary": "List workflows",
                "description": "Workflows in the organization, with their current version. Steps are not included; get a single workflow for those.",
                "x-required-scopes": [
                    "workflows:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/WorkflowSort"
                    },
                    {
                        "$ref": "#/components/parameters/WorkflowFilterStatus"
                    },
                    {
                        "$ref": "#/components/parameters/WorkflowFilterCategory"
                    },
                    {
                        "$ref": "#/components/parameters/FilterTeamId"
                    },
                    {
                        "$ref": "#/components/parameters/FilterSearch"
                    },
                    {
                        "$ref": "#/components/parameters/FilterUpdatedSince"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of workflows.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkflowList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            },
            "post": {
                "operationId": "createDraftWorkflow",
                "tags": [
                    "Workflows"
                ],
                "summary": "Start a draft workflow from text",
                "description": "Turns a plain description into a draft workflow, as Describe it does in the app. It counts as a capture and an AI job, so plan limits apply. The draft is never published here; a manager reviews and publishes it in OpsBrain at review_url.",
                "x-required-scopes": [
                    "workflows:write"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreateDraftWorkflowRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "The draft was started.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            },
                            "Location": {
                                "$ref": "#/components/headers/Location"
                            },
                            "Idempotent-Replayed": {
                                "$ref": "#/components/headers/Idempotent-Replayed"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DraftWorkflowResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/ForbiddenOrPlanLimit"
                    },
                    "409": {
                        "$ref": "#/components/responses/IdempotencyConflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/WriteValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/workflows/{id}": {
            "get": {
                "operationId": "getWorkflow",
                "tags": [
                    "Workflows"
                ],
                "summary": "Get a workflow",
                "description": "A workflow with the steps of its current version, including choices, decisions and which steps ask for evidence.",
                "x-required-scopes": [
                    "workflows:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/WorkflowId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The workflow.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkflowResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/workflows/{id}/versions": {
            "get": {
                "operationId": "listWorkflowVersions",
                "tags": [
                    "Workflows"
                ],
                "summary": "List a workflow's versions",
                "description": "Every version of the workflow, newest first by default.",
                "x-required-scopes": [
                    "workflows:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/WorkflowId"
                    },
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/VersionSort"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of versions.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/VersionList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/workflows/{id}/insights": {
            "get": {
                "operationId": "getWorkflowInsights",
                "tags": [
                    "Insights"
                ],
                "summary": "Get workflow insights",
                "description": "Health, completion, the steps that slow people down, and per-team results for the workflow, from the latest nightly snapshots over the last 7 or 30 days.",
                "x-required-scopes": [
                    "insights:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/WorkflowId"
                    },
                    {
                        "$ref": "#/components/parameters/InsightWindow"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The workflow's insights.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkflowInsightsResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/runs": {
            "get": {
                "operationId": "listRuns",
                "tags": [
                    "Runs"
                ],
                "summary": "List runs",
                "description": "Runs in the organization. Step runs are not included; get a single run for those.",
                "x-required-scopes": [
                    "runs:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/RunSort"
                    },
                    {
                        "$ref": "#/components/parameters/RunFilterStatus"
                    },
                    {
                        "$ref": "#/components/parameters/RunFilterSource"
                    },
                    {
                        "$ref": "#/components/parameters/FilterRunPriority"
                    },
                    {
                        "$ref": "#/components/parameters/FilterWorkflowId"
                    },
                    {
                        "$ref": "#/components/parameters/FilterTeamId"
                    },
                    {
                        "$ref": "#/components/parameters/RunFilterWorkerId"
                    },
                    {
                        "$ref": "#/components/parameters/RunFilterExternalRef"
                    },
                    {
                        "$ref": "#/components/parameters/FilterCreatedSince"
                    },
                    {
                        "$ref": "#/components/parameters/FilterUpdatedSince"
                    },
                    {
                        "$ref": "#/components/parameters/RunFilterCompletedSince"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of runs.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/RunList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            },
            "post": {
                "operationId": "queueRun",
                "tags": [
                    "Runs"
                ],
                "summary": "Queue a run",
                "description": "Puts a run of a live workflow in a team's queue, as a trigger does. The run waits with status pending_pickup until someone claims it.",
                "x-required-scopes": [
                    "runs:write"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/QueueRunRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "The run was queued.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            },
                            "Location": {
                                "$ref": "#/components/headers/Location"
                            },
                            "Idempotent-Replayed": {
                                "$ref": "#/components/headers/Idempotent-Replayed"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/RunResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/IdempotencyConflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/WriteValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/runs/{id}": {
            "get": {
                "operationId": "getRun",
                "tags": [
                    "Runs"
                ],
                "summary": "Get a run",
                "description": "A run with its audit trail: every step run with the answer, skips, notes, flags and evidence. Evidence links need the evidence:read scope.",
                "x-required-scopes": [
                    "runs:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RunId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The run.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/RunResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/flags": {
            "get": {
                "operationId": "listFlags",
                "tags": [
                    "Flags"
                ],
                "summary": "List flags",
                "description": "Flags workers raised on steps, newest first by default.",
                "x-required-scopes": [
                    "flags:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/FlagSort"
                    },
                    {
                        "$ref": "#/components/parameters/FlagFilterStatus"
                    },
                    {
                        "$ref": "#/components/parameters/FlagFilterType"
                    },
                    {
                        "$ref": "#/components/parameters/FilterWorkflowId"
                    },
                    {
                        "$ref": "#/components/parameters/FilterTeamId"
                    },
                    {
                        "$ref": "#/components/parameters/FlagFilterRunId"
                    },
                    {
                        "$ref": "#/components/parameters/FilterCreatedSince"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of flags.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/FlagList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/flags/{id}": {
            "get": {
                "operationId": "getFlag",
                "tags": [
                    "Flags"
                ],
                "summary": "Get a flag",
                "description": "A single flag.",
                "x-required-scopes": [
                    "flags:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/FlagId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The flag.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/FlagResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/flags/{id}/resolve": {
            "post": {
                "operationId": "resolveFlag",
                "tags": [
                    "Flags"
                ],
                "summary": "Resolve a flag",
                "description": "Marks the flag resolved on behalf of the key's owner. Resolving a resolved flag changes nothing. No request body.",
                "x-required-scopes": [
                    "flags:write"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/FlagId"
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The flag after the change.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            },
                            "Idempotent-Replayed": {
                                "$ref": "#/components/headers/Idempotent-Replayed"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/FlagResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/IdempotencyConflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/WriteValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/flags/{id}/reopen": {
            "post": {
                "operationId": "reopenFlag",
                "tags": [
                    "Flags"
                ],
                "summary": "Reopen a flag",
                "description": "Marks a resolved flag open again. Reopening an open flag changes nothing. No request body.",
                "x-required-scopes": [
                    "flags:write"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/FlagId"
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The flag after the change.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            },
                            "Idempotent-Replayed": {
                                "$ref": "#/components/headers/Idempotent-Replayed"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/FlagResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/IdempotencyConflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/WriteValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/teams": {
            "get": {
                "operationId": "listTeams",
                "tags": [
                    "Teams"
                ],
                "summary": "List teams",
                "description": "Teams in the organization.",
                "x-required-scopes": [
                    "teams:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/TeamSort"
                    },
                    {
                        "$ref": "#/components/parameters/FilterSearch"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of teams.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TeamList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/teams/{id}": {
            "get": {
                "operationId": "getTeam",
                "tags": [
                    "Teams"
                ],
                "summary": "Get a team",
                "description": "A single team.",
                "x-required-scopes": [
                    "teams:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TeamId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The team.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TeamResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/teams/{id}/queue": {
            "get": {
                "operationId": "listTeamQueue",
                "tags": [
                    "Teams"
                ],
                "summary": "List a team's queue",
                "description": "Runs waiting to be claimed by the team: queued for the team, or queued with no team for a workflow the team is assigned to. Oldest first by default.",
                "x-required-scopes": [
                    "teams:read",
                    "runs:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TeamId"
                    },
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/TeamQueueSort"
                    },
                    {
                        "$ref": "#/components/parameters/FilterRunPriority"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of queued runs.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/RunList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/teams/{id}/insights": {
            "get": {
                "operationId": "getTeamInsights",
                "tags": [
                    "Insights"
                ],
                "summary": "Get team insights",
                "description": "How the team does on each workflow it runs, from the latest nightly snapshot per workflow over the last 7 or 30 days.",
                "x-required-scopes": [
                    "insights:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/TeamId"
                    },
                    {
                        "$ref": "#/components/parameters/InsightWindow"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The team's insights.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TeamInsightsResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/members": {
            "get": {
                "operationId": "listMembers",
                "tags": [
                    "Members"
                ],
                "summary": "List members",
                "description": "People in the organization, with email addresses.",
                "x-required-scopes": [
                    "members:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/MemberSort"
                    },
                    {
                        "$ref": "#/components/parameters/MemberFilterRole"
                    },
                    {
                        "$ref": "#/components/parameters/FilterTeamId"
                    },
                    {
                        "$ref": "#/components/parameters/FilterSearch"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of members.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MemberList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/suggestions": {
            "get": {
                "operationId": "listSuggestions",
                "tags": [
                    "Suggestions"
                ],
                "summary": "List suggestions",
                "description": "Suggestions for improving workflows. Read only: a manager accepts or rejects them inside OpsBrain.",
                "x-required-scopes": [
                    "suggestions:read"
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/SuggestionSort"
                    },
                    {
                        "$ref": "#/components/parameters/SuggestionFilterStatus"
                    },
                    {
                        "$ref": "#/components/parameters/SuggestionFilterType"
                    },
                    {
                        "$ref": "#/components/parameters/FilterWorkflowId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of suggestions.",
                        "headers": {
                            "X-Request-Id": {
                                "$ref": "#/components/headers/X-Request-Id"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuggestionList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationFailed"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "ApiKey": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "obk_...",
                "description": "An organization API key: obk_ followed by 40 characters, sent as Authorization: Bearer obk_.... Managers create keys in Settings, Integrations, API keys, and choose the key's scopes."
            }
        },
        "parameters": {
            "Limit": {
                "name": "limit",
                "in": "query",
                "required": false,
                "description": "Items per page.",
                "schema": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 25
                }
            },
            "Cursor": {
                "name": "cursor",
                "in": "query",
                "required": false,
                "description": "Opaque cursor from meta.next_cursor of the previous page.",
                "schema": {
                    "type": "string",
                    "maxLength": 2000
                }
            },
            "IdempotencyKey": {
                "name": "Idempotency-Key",
                "in": "header",
                "required": false,
                "description": "Any unique string, 1 to 255 visible ASCII characters. A repeat of the same request with the same key within 24 hours returns the first response instead of acting again. Only successful responses are stored, so a rejected request can be fixed and retried with the same key.",
                "schema": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255,
                    "pattern": "^[\\x21-\\x7E]+$"
                }
            },
            "WorkflowId": {
                "name": "id",
                "in": "path",
                "required": true,
                "description": "Workflow id.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "RunId": {
                "name": "id",
                "in": "path",
                "required": true,
                "description": "Run id.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "FlagId": {
                "name": "id",
                "in": "path",
                "required": true,
                "description": "Flag id.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "TeamId": {
                "name": "id",
                "in": "path",
                "required": true,
                "description": "Team id.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "InsightWindow": {
                "name": "window",
                "in": "query",
                "required": false,
                "description": "Window in days.",
                "schema": {
                    "type": "integer",
                    "enum": [
                        7,
                        30
                    ],
                    "default": 30
                }
            },
            "WorkflowSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "name",
                        "-name",
                        "created_at",
                        "-created_at",
                        "updated_at",
                        "-updated_at"
                    ],
                    "default": "-updated_at"
                }
            },
            "VersionSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "version_number",
                        "-version_number",
                        "created_at",
                        "-created_at"
                    ],
                    "default": "-version_number"
                }
            },
            "RunSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "created_at",
                        "-created_at",
                        "updated_at",
                        "-updated_at"
                    ],
                    "default": "-created_at"
                }
            },
            "FlagSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "created_at",
                        "-created_at"
                    ],
                    "default": "-created_at"
                }
            },
            "TeamSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "name",
                        "-name",
                        "created_at",
                        "-created_at"
                    ],
                    "default": "name"
                }
            },
            "TeamQueueSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "created_at",
                        "-created_at"
                    ],
                    "default": "created_at"
                }
            },
            "MemberSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "name",
                        "-name",
                        "created_at",
                        "-created_at"
                    ],
                    "default": "name"
                }
            },
            "SuggestionSort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "Field to sort by. Prefix with - for descending order. Ties are broken by id.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "created_at",
                        "-created_at"
                    ],
                    "default": "-created_at"
                }
            },
            "FilterSearch": {
                "name": "filter[search]",
                "in": "query",
                "required": false,
                "description": "Case-insensitive match anywhere in the name.",
                "schema": {
                    "type": "string",
                    "maxLength": 200
                }
            },
            "FilterTeamId": {
                "name": "filter[team_id]",
                "in": "query",
                "required": false,
                "description": "Only items for this team.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "FilterWorkflowId": {
                "name": "filter[workflow_id]",
                "in": "query",
                "required": false,
                "description": "Only items for this workflow.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "FilterCreatedSince": {
                "name": "filter[created_since]",
                "in": "query",
                "required": false,
                "description": "Only items created at or after this date or date-time.",
                "schema": {
                    "type": "string",
                    "examples": [
                        "2026-12-01",
                        "2026-12-01T08:00:00Z"
                    ]
                }
            },
            "FilterUpdatedSince": {
                "name": "filter[updated_since]",
                "in": "query",
                "required": false,
                "description": "Only items updated at or after this date or date-time.",
                "schema": {
                    "type": "string",
                    "examples": [
                        "2026-12-01",
                        "2026-12-01T08:00:00Z"
                    ]
                }
            },
            "FilterRunPriority": {
                "name": "filter[priority]",
                "in": "query",
                "required": false,
                "description": "Only runs with this priority.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "low",
                        "normal",
                        "high",
                        "critical"
                    ]
                }
            },
            "WorkflowFilterStatus": {
                "name": "filter[status]",
                "in": "query",
                "required": false,
                "description": "Only workflows with this status.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "live",
                        "draft",
                        "archived"
                    ]
                }
            },
            "WorkflowFilterCategory": {
                "name": "filter[category]",
                "in": "query",
                "required": false,
                "description": "Only workflows in this category.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "onboarding",
                        "customer_support",
                        "inventory",
                        "finance",
                        "hr",
                        "operations",
                        "it"
                    ]
                }
            },
            "RunFilterStatus": {
                "name": "filter[status]",
                "in": "query",
                "required": false,
                "description": "Only runs with this status.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "in_progress",
                        "completed",
                        "incomplete",
                        "abandoned",
                        "waiting_for_child",
                        "pending_pickup",
                        "handed_off"
                    ]
                }
            },
            "RunFilterSource": {
                "name": "filter[source]",
                "in": "query",
                "required": false,
                "description": "Only runs from this source.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "manual",
                        "handoff",
                        "external",
                        "api"
                    ]
                }
            },
            "RunFilterWorkerId": {
                "name": "filter[worker_id]",
                "in": "query",
                "required": false,
                "description": "Only runs done by this person.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "RunFilterExternalRef": {
                "name": "filter[external_ref]",
                "in": "query",
                "required": false,
                "description": "Only runs with exactly this external reference.",
                "schema": {
                    "type": "string",
                    "maxLength": 255
                }
            },
            "RunFilterCompletedSince": {
                "name": "filter[completed_since]",
                "in": "query",
                "required": false,
                "description": "Only runs completed at or after this date or date-time.",
                "schema": {
                    "type": "string",
                    "examples": [
                        "2026-12-01",
                        "2026-12-01T08:00:00Z"
                    ]
                }
            },
            "FlagFilterStatus": {
                "name": "filter[status]",
                "in": "query",
                "required": false,
                "description": "Only open or only resolved flags.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "open",
                        "resolved"
                    ]
                }
            },
            "FlagFilterType": {
                "name": "filter[type]",
                "in": "query",
                "required": false,
                "description": "Only flags of this type.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "general",
                        "unclear_instructions",
                        "equipment_issue",
                        "missing_resource",
                        "policy_conflict",
                        "system_error"
                    ]
                }
            },
            "FlagFilterRunId": {
                "name": "filter[run_id]",
                "in": "query",
                "required": false,
                "description": "Only flags raised on this run.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "MemberFilterRole": {
                "name": "filter[role]",
                "in": "query",
                "required": false,
                "description": "Only people with this role in the organization.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "manager",
                        "contributor",
                        "worker"
                    ]
                }
            },
            "SuggestionFilterStatus": {
                "name": "filter[status]",
                "in": "query",
                "required": false,
                "description": "Only suggestions with this status.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "pending",
                        "accepted",
                        "rejected",
                        "dismissed",
                        "stale"
                    ]
                }
            },
            "SuggestionFilterType": {
                "name": "filter[type]",
                "in": "query",
                "required": false,
                "description": "Only suggestions of this type.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "remove_step",
                        "update_instructions",
                        "add_step",
                        "reorder_steps",
                        "split_step",
                        "update_title",
                        "mark_optional",
                        "update_options",
                        "mark_required",
                        "change_step_type",
                        "merge_steps"
                    ]
                }
            }
        },
        "headers": {
            "X-Request-Id": {
                "description": "Id of this request. Quote it to support. If you send a valid X-Request-Id (8 to 64 letters, digits, dashes or underscores) it is echoed back; otherwise a new one is made.",
                "schema": {
                    "type": "string"
                }
            },
            "X-RateLimit-Limit": {
                "description": "Requests allowed in the current window, for the tightest limit that applies to this key and organization.",
                "schema": {
                    "type": "integer"
                }
            },
            "X-RateLimit-Remaining": {
                "description": "Requests left in the current window, for the same limit.",
                "schema": {
                    "type": "integer"
                }
            },
            "Retry-After": {
                "description": "Seconds to wait before trying again.",
                "schema": {
                    "type": "integer"
                }
            },
            "Location": {
                "description": "URL of the created resource.",
                "schema": {
                    "type": "string",
                    "format": "uri"
                }
            },
            "Idempotent-Replayed": {
                "description": "Present with the value true when this is the stored response to an earlier request with the same Idempotency-Key.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "true"
                    ]
                }
            },
            "WWW-Authenticate": {
                "description": "Always Bearer.",
                "schema": {
                    "type": "string"
                }
            }
        },
        "responses": {
            "Unauthorized": {
                "description": "The API key is missing, not valid, revoked, expired, replaced by rotation, or suspended. The code says which.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "WWW-Authenticate": {
                        "$ref": "#/components/headers/WWW-Authenticate"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "unauthenticated",
                                                "invalid_key",
                                                "key_revoked",
                                                "key_expired",
                                                "key_rotated",
                                                "key_suspended"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Forbidden": {
                "description": "The key lacks a scope this operation needs (scope_missing, with the scope named), or the organization's plan has lapsed (organization_restricted).",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "scope_missing",
                                                "organization_restricted",
                                                "forbidden"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "ForbiddenOrPlanLimit": {
                "description": "As Forbidden, or the organization has reached a plan limit: captures (capture_limit_reached), today's AI work (ai_limit_reached), or a feature its plan does not include (plan_limit_reached). The limit field names it.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "scope_missing",
                                                "organization_restricted",
                                                "forbidden",
                                                "capture_limit_reached",
                                                "ai_limit_reached",
                                                "plan_limit_reached"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "NotFound": {
                "description": "Nothing with that id exists in this organization. Ids from other organizations answer the same way.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "not_found"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "ValidationFailed": {
                "description": "A query parameter is not valid. errors lists each field.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "validation_failed"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "WriteValidationFailed": {
                "description": "A field or the Idempotency-Key header is not valid (validation_failed, with errors per field), or the Idempotency-Key was already used with a different request (idempotency_key_reused).",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "validation_failed",
                                                "idempotency_key_reused"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "IdempotencyConflict": {
                "description": "A request with this Idempotency-Key is still running. Wait a moment and retry.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "idempotency_key_in_use"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Too many requests for this key or organization in the current minute or day. Wait for Retry-After seconds.",
                "headers": {
                    "X-Request-Id": {
                        "$ref": "#/components/headers/X-Request-Id"
                    },
                    "X-RateLimit-Limit": {
                        "$ref": "#/components/headers/X-RateLimit-Limit"
                    },
                    "X-RateLimit-Remaining": {
                        "$ref": "#/components/headers/X-RateLimit-Remaining"
                    },
                    "Retry-After": {
                        "$ref": "#/components/headers/Retry-After"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "rate_limited"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "schemas": {
            "Problem": {
                "type": "object",
                "description": "An error body, sent as application/problem+json (RFC 9457).",
                "required": [
                    "type",
                    "title",
                    "status",
                    "code",
                    "request_id"
                ],
                "properties": {
                    "type": {
                        "type": "string",
                        "description": "Link to the documentation for this code.",
                        "format": "uri"
                    },
                    "title": {
                        "type": "string",
                        "description": "Short English summary of the problem type."
                    },
                    "status": {
                        "type": "integer",
                        "description": "HTTP status code."
                    },
                    "detail": {
                        "type": "string",
                        "description": "What went wrong and what to do next. Absent when there is nothing to add."
                    },
                    "code": {
                        "type": "string",
                        "description": "Stable machine code. Branch on this, not on title or detail. Values: unauthenticated, invalid_key, key_revoked, key_expired, key_rotated, key_suspended, scope_missing, organization_restricted, forbidden, capture_limit_reached, ai_limit_reached, plan_limit_reached, not_found, method_not_allowed, validation_failed, idempotency_key_reused, idempotency_key_in_use, rate_limited, http_error, server_error."
                    },
                    "request_id": {
                        "type": "string",
                        "description": "Same value as the X-Request-Id response header."
                    },
                    "errors": {
                        "type": "object",
                        "description": "Present when code is validation_failed. Keys are field names, with dot notation for nested fields (for example answers.0.value). Values are lists of messages.",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    },
                    "scope": {
                        "type": "string",
                        "description": "Present when code is scope_missing: the scope the key lacks.",
                        "enum": [
                            "workflows:read",
                            "runs:read",
                            "flags:read",
                            "teams:read",
                            "insights:read",
                            "suggestions:read",
                            "members:read",
                            "evidence:read",
                            "runs:write",
                            "flags:write",
                            "workflows:write"
                        ]
                    },
                    "limit": {
                        "type": "string",
                        "description": "Present when code is capture_limit_reached, ai_limit_reached or plan_limit_reached: the plan limit or feature that was hit (for example captures or ai_jobs_daily)."
                    }
                }
            },
            "ListMeta": {
                "type": "object",
                "description": "Pagination details for a list response.",
                "required": [
                    "limit",
                    "next_cursor",
                    "has_more"
                ],
                "properties": {
                    "limit": {
                        "type": "integer",
                        "description": "Page size used for this response."
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Pass as ?cursor= to get the next page. Null on the last page."
                    },
                    "has_more": {
                        "type": "boolean",
                        "description": "Whether another page exists."
                    }
                }
            },
            "WorkflowRef": {
                "type": "object",
                "description": "A workflow, by id and name.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    }
                }
            },
            "TeamRef": {
                "type": "object",
                "description": "A team, by id and name.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    }
                }
            },
            "PersonRef": {
                "type": "object",
                "description": "A person, by id and name.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    }
                }
            },
            "RunRef": {
                "type": "object",
                "description": "A run, by id and name.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "The run's display name, or the workflow name when the run has none."
                    }
                }
            },
            "StepRef": {
                "type": "object",
                "description": "A workflow step, by id and title.",
                "required": [
                    "id",
                    "title"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "title": {
                        "type": "string"
                    }
                }
            },
            "StepPositionRef": {
                "type": "object",
                "description": "A workflow step, by id, position and title.",
                "required": [
                    "id",
                    "position",
                    "title"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "position": {
                        "type": "integer",
                        "description": "Position of the step in its version, starting at 1."
                    },
                    "title": {
                        "type": "string"
                    }
                }
            },
            "Me": {
                "type": "object",
                "description": "The organization and key behind the request.",
                "required": [
                    "organization",
                    "key"
                ],
                "properties": {
                    "organization": {
                        "type": "object",
                        "description": "The organization the key belongs to.",
                        "required": [
                            "id",
                            "name"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "key": {
                        "type": "object",
                        "description": "The key used for this request.",
                        "required": [
                            "id",
                            "name",
                            "prefix",
                            "scopes",
                            "expires_at",
                            "owner"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string",
                                "description": "Name a manager gave the key."
                            },
                            "prefix": {
                                "type": "string",
                                "description": "First characters of the key, safe to show and log."
                            },
                            "scopes": {
                                "type": "array",
                                "description": "Scopes the key holds.",
                                "items": {
                                    "type": "string",
                                    "enum": [
                                        "workflows:read",
                                        "runs:read",
                                        "flags:read",
                                        "teams:read",
                                        "insights:read",
                                        "suggestions:read",
                                        "members:read",
                                        "evidence:read",
                                        "runs:write",
                                        "flags:write",
                                        "workflows:write"
                                    ]
                                }
                            },
                            "expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time",
                                "description": "When the key stops working. Null when it does not expire."
                            },
                            "owner": {
                                "$ref": "#/components/schemas/PersonRef",
                                "description": "The manager the key acts for."
                            }
                        }
                    }
                }
            },
            "LiveVersion": {
                "type": "object",
                "description": "The workflow's current version.",
                "required": [
                    "id",
                    "version_number",
                    "published_at",
                    "expected_duration_seconds"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "version_number": {
                        "type": "integer"
                    },
                    "published_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "expected_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    }
                }
            },
            "StepOption": {
                "type": "object",
                "description": "One choice a step offers.",
                "required": [
                    "label",
                    "value"
                ],
                "properties": {
                    "label": {
                        "type": "string"
                    },
                    "value": {
                        "type": "string"
                    }
                }
            },
            "StepDecision": {
                "type": "object",
                "description": "Where an answer leads.",
                "required": [
                    "when",
                    "next_step_id",
                    "next_workflow_id",
                    "ends_workflow"
                ],
                "properties": {
                    "when": {
                        "type": "string",
                        "description": "Answer that triggers this decision: yes, no, or a multiple choice option value."
                    },
                    "next_step_id": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uuid",
                        "description": "Step to go to next. Null when the decision starts another workflow or ends the run."
                    },
                    "next_workflow_id": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uuid",
                        "description": "Workflow to start. Null when the decision goes to a step or ends the run."
                    },
                    "ends_workflow": {
                        "type": "boolean",
                        "description": "Whether this answer ends the run."
                    }
                }
            },
            "Step": {
                "type": "object",
                "description": "One step of a workflow's current version.",
                "required": [
                    "id",
                    "position",
                    "type",
                    "title",
                    "instructions",
                    "required",
                    "allows_notes",
                    "asks_for_evidence",
                    "options",
                    "decisions"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "position": {
                        "type": "integer",
                        "description": "Position in the version, starting at 1."
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "confirmation",
                            "yes_no",
                            "multiple_choice",
                            "sub_checklist",
                            "number_input",
                            "short_text",
                            "long_text",
                            "photo_upload",
                            "file_upload",
                            "date_picker"
                        ]
                    },
                    "title": {
                        "type": "string"
                    },
                    "instructions": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "required": {
                        "type": "boolean"
                    },
                    "allows_notes": {
                        "type": "boolean"
                    },
                    "asks_for_evidence": {
                        "type": "boolean",
                        "description": "True for photo_upload and file_upload steps."
                    },
                    "options": {
                        "type": "array",
                        "description": "Choices, in order. Empty for steps without choices.",
                        "items": {
                            "$ref": "#/components/schemas/StepOption"
                        }
                    },
                    "decisions": {
                        "type": "array",
                        "description": "Branches out of this step. Empty when the step always goes to the next one.",
                        "items": {
                            "$ref": "#/components/schemas/StepDecision"
                        }
                    }
                }
            },
            "Workflow": {
                "type": "object",
                "description": "A workflow. The first five fields match the workflow object in webhook payloads.",
                "required": [
                    "id",
                    "name",
                    "status",
                    "category",
                    "url",
                    "description",
                    "creation_method",
                    "live_version",
                    "team_ids",
                    "created_at",
                    "updated_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "live",
                            "draft",
                            "archived"
                        ]
                    },
                    "category": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "onboarding",
                            "customer_support",
                            "inventory",
                            "finance",
                            "hr",
                            "operations",
                            "it",
                            null
                        ]
                    },
                    "url": {
                        "type": "string",
                        "description": "Link to the workflow in the OpsBrain app.",
                        "format": "uri"
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "creation_method": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "manual",
                            "recorded",
                            "imported",
                            "generated",
                            "template",
                            null
                        ]
                    },
                    "live_version": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/LiveVersion"
                            },
                            {
                                "type": "null"
                            }
                        ],
                        "description": "The current version. Null when the workflow has none."
                    },
                    "team_ids": {
                        "type": "array",
                        "description": "Teams the workflow is assigned to.",
                        "items": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "steps": {
                        "type": "array",
                        "description": "Steps of the current version, in order. Present only on GET /workflows/{id}, when the workflow has a current version.",
                        "items": {
                            "$ref": "#/components/schemas/Step"
                        }
                    }
                }
            },
            "DraftWorkflow": {
                "description": "A draft workflow just started from text.",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Workflow"
                    },
                    {
                        "type": "object",
                        "required": [
                            "review_url"
                        ],
                        "properties": {
                            "review_url": {
                                "type": "string",
                                "description": "Link where a manager reviews and publishes the draft in OpsBrain.",
                                "format": "uri"
                            }
                        }
                    }
                ]
            },
            "Version": {
                "type": "object",
                "description": "One version of a workflow.",
                "required": [
                    "id",
                    "workflow_id",
                    "version_number",
                    "is_live",
                    "published_at",
                    "change_notes",
                    "expected_duration_seconds",
                    "step_count",
                    "created_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "workflow_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "version_number": {
                        "type": "integer"
                    },
                    "is_live": {
                        "type": "boolean",
                        "description": "Whether this is the workflow's current version."
                    },
                    "published_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "Null for a version that was never published."
                    },
                    "change_notes": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "expected_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "step_count": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "description": "Number of steps in this version."
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "StepRunFlag": {
                "type": "object",
                "description": "A flag raised on this step run.",
                "required": [
                    "id",
                    "type",
                    "message",
                    "status",
                    "resolved_at",
                    "created_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "general",
                            "unclear_instructions",
                            "equipment_issue",
                            "missing_resource",
                            "policy_conflict",
                            "system_error"
                        ]
                    },
                    "message": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "open",
                            "resolved"
                        ]
                    },
                    "resolved_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "Evidence": {
                "type": "object",
                "description": "A photo or file the worker attached.",
                "required": [
                    "id",
                    "filename",
                    "mime_type",
                    "size_bytes",
                    "url"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "filename": {
                        "type": "string"
                    },
                    "mime_type": {
                        "type": "string"
                    },
                    "size_bytes": {
                        "type": "integer"
                    },
                    "url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Download link that works for one hour. Null when no link could be made.",
                        "format": "uri"
                    }
                }
            },
            "StepRun": {
                "type": "object",
                "description": "One step of a run as the worker left it.",
                "required": [
                    "id",
                    "step",
                    "status",
                    "answer",
                    "prefilled",
                    "skipped",
                    "skip_reason",
                    "notes",
                    "started_at",
                    "completed_at",
                    "duration_seconds",
                    "flags",
                    "evidence_count"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "step": {
                        "oneOf": [
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "position",
                                    "title",
                                    "type"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "position": {
                                        "type": "integer"
                                    },
                                    "title": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "confirmation",
                                            "yes_no",
                                            "multiple_choice",
                                            "sub_checklist",
                                            "number_input",
                                            "short_text",
                                            "long_text",
                                            "photo_upload",
                                            "file_upload",
                                            "date_picker"
                                        ]
                                    }
                                }
                            },
                            {
                                "type": "null"
                            }
                        ],
                        "description": "The step this run of it belongs to. Null if the step no longer exists."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "in_progress",
                            "completed",
                            "skipped"
                        ]
                    },
                    "answer": {
                        "description": "The worker's answer, as stored. Any JSON value, or null. Its shape depends on the step type."
                    },
                    "prefilled": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Value filled in ahead by a trigger or by POST /runs, if any."
                    },
                    "skipped": {
                        "type": "boolean"
                    },
                    "skip_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "notes": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "started_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "flags": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/StepRunFlag"
                        }
                    },
                    "evidence_count": {
                        "type": "integer",
                        "description": "Number of photos and files attached."
                    },
                    "evidence": {
                        "type": "array",
                        "description": "Photos and files attached. Present only when the key has the evidence:read scope.",
                        "items": {
                            "$ref": "#/components/schemas/Evidence"
                        }
                    }
                }
            },
            "Run": {
                "type": "object",
                "description": "A run of a workflow. Its fields match the run object in webhook payloads, plus ids for the workflow, version, team and worker.",
                "required": [
                    "id",
                    "status",
                    "name",
                    "source",
                    "priority",
                    "external_ref",
                    "workflow",
                    "workflow_version_id",
                    "team",
                    "worker",
                    "queued_at",
                    "claimed_at",
                    "due_at",
                    "started_at",
                    "completed_at",
                    "duration_seconds",
                    "duration_human",
                    "steps_completed",
                    "steps_skipped",
                    "flags_raised",
                    "notes",
                    "url",
                    "created_at",
                    "updated_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "in_progress",
                            "completed",
                            "incomplete",
                            "abandoned",
                            "waiting_for_child",
                            "pending_pickup",
                            "handed_off"
                        ]
                    },
                    "name": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "The run's display name, or the workflow name when the run has none."
                    },
                    "source": {
                        "type": "string",
                        "enum": [
                            "manual",
                            "handoff",
                            "external",
                            "api"
                        ],
                        "description": "How the run started. Runs queued through this API have source api."
                    },
                    "priority": {
                        "type": "string",
                        "enum": [
                            "low",
                            "normal",
                            "high",
                            "critical"
                        ]
                    },
                    "external_ref": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Reference from another system, as sent when the run was queued."
                    },
                    "workflow": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WorkflowRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "workflow_version_id": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uuid",
                        "description": "The workflow version the run follows."
                    },
                    "team": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/TeamRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "worker": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/PersonRef"
                            },
                            {
                                "type": "null"
                            }
                        ],
                        "description": "The person doing the run. Null while it waits in a queue."
                    },
                    "queued_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "claimed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "due_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "started_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "duration_human": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Duration in short form, for example 4m 30s."
                    },
                    "steps_completed": {
                        "type": "integer"
                    },
                    "steps_skipped": {
                        "type": "integer"
                    },
                    "flags_raised": {
                        "type": "integer",
                        "description": "Number of step runs with a flag."
                    },
                    "notes": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "url": {
                        "type": "string",
                        "description": "Link to the run in the OpsBrain app.",
                        "format": "uri"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "step_runs": {
                        "type": "array",
                        "description": "Every step run, in the order they started. Present only on GET /runs/{id} and POST /runs.",
                        "items": {
                            "$ref": "#/components/schemas/StepRun"
                        }
                    }
                }
            },
            "Flag": {
                "type": "object",
                "description": "A flag a worker raised on a step. id, type and message match the flag object in webhook payloads.",
                "required": [
                    "id",
                    "type",
                    "message",
                    "status",
                    "resolved_at",
                    "resolved_by",
                    "step",
                    "run",
                    "workflow",
                    "team",
                    "raised_by",
                    "created_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "general",
                            "unclear_instructions",
                            "equipment_issue",
                            "missing_resource",
                            "policy_conflict",
                            "system_error"
                        ]
                    },
                    "message": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "open",
                            "resolved"
                        ]
                    },
                    "resolved_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "resolved_by": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/PersonRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "step": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/StepRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "run": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/RunRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "workflow": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WorkflowRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "team": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/TeamRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "raised_by": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/PersonRef"
                            },
                            {
                                "type": "null"
                            }
                        ],
                        "description": "The worker on the run."
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "Team": {
                "type": "object",
                "description": "A team.",
                "required": [
                    "id",
                    "name",
                    "description",
                    "member_count",
                    "workflow_count",
                    "created_at",
                    "updated_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "member_count": {
                        "type": "integer"
                    },
                    "workflow_count": {
                        "type": "integer"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "Member": {
                "type": "object",
                "description": "A person in the organization.",
                "required": [
                    "id",
                    "name",
                    "email",
                    "role",
                    "team_ids",
                    "joined_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "format": "email"
                    },
                    "role": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "manager",
                            "contributor",
                            "worker",
                            null
                        ]
                    },
                    "team_ids": {
                        "type": "array",
                        "description": "Teams in this organization the person belongs to.",
                        "items": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    "joined_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "When the person joined the organization."
                    }
                }
            },
            "Suggestion": {
                "type": "object",
                "description": "A suggestion for improving a workflow. A manager accepts or rejects it inside OpsBrain. The first six fields match the optimization object in webhook payloads.",
                "required": [
                    "id",
                    "type",
                    "title",
                    "description",
                    "impact_score",
                    "url",
                    "status",
                    "workflow",
                    "step",
                    "created_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "remove_step",
                            "update_instructions",
                            "add_step",
                            "reorder_steps",
                            "split_step",
                            "update_title",
                            "mark_optional",
                            "update_options",
                            "mark_required",
                            "change_step_type",
                            "merge_steps"
                        ]
                    },
                    "title": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "impact_score": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "url": {
                        "type": "string",
                        "description": "Link to the suggestion in the OpsBrain app.",
                        "format": "uri"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "accepted",
                            "rejected",
                            "dismissed",
                            "stale"
                        ]
                    },
                    "workflow": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WorkflowRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "step": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/StepRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "Bottleneck": {
                "type": "object",
                "description": "A step that slows people down, from the latest step snapshot.",
                "required": [
                    "step",
                    "encounters",
                    "skip_rate",
                    "flag_rate",
                    "avg_duration_seconds"
                ],
                "properties": {
                    "step": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/StepPositionRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "encounters": {
                        "type": "integer",
                        "description": "How many times workers reached this step in the window."
                    },
                    "skip_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "flag_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "avg_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    }
                }
            },
            "WorkflowTeamInsight": {
                "type": "object",
                "description": "How one team does on the workflow.",
                "required": [
                    "team",
                    "total_runs",
                    "completed_runs",
                    "completion_rate",
                    "skip_rate",
                    "avg_duration_seconds",
                    "health_status"
                ],
                "properties": {
                    "team": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/TeamRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "total_runs": {
                        "type": "integer"
                    },
                    "completed_runs": {
                        "type": "integer"
                    },
                    "completion_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "skip_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "avg_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "health_status": {
                        "type": "string",
                        "enum": [
                            "good",
                            "warning",
                            "alert"
                        ]
                    }
                }
            },
            "WorkflowInsights": {
                "type": "object",
                "description": "Health, completion and bottlenecks for a workflow, from the nightly snapshots.",
                "required": [
                    "workflow",
                    "window_days",
                    "snapshot_date",
                    "total_runs",
                    "completed_runs",
                    "incomplete_runs",
                    "abandoned_runs",
                    "completion_rate",
                    "avg_duration_seconds",
                    "health_score",
                    "most_common_drop_off",
                    "bottlenecks",
                    "teams"
                ],
                "properties": {
                    "workflow": {
                        "$ref": "#/components/schemas/WorkflowRef"
                    },
                    "window_days": {
                        "type": "integer",
                        "enum": [
                            7,
                            30
                        ]
                    },
                    "snapshot_date": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Date of the snapshot used. Null when no snapshot exists yet.",
                        "format": "date"
                    },
                    "total_runs": {
                        "type": "integer"
                    },
                    "completed_runs": {
                        "type": "integer"
                    },
                    "incomplete_runs": {
                        "type": "integer"
                    },
                    "abandoned_runs": {
                        "type": "integer"
                    },
                    "completion_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "avg_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "health_score": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "description": "Score from 0 to 100."
                    },
                    "most_common_drop_off": {
                        "oneOf": [
                            {
                                "type": "object",
                                "required": [
                                    "step",
                                    "count"
                                ],
                                "properties": {
                                    "step": {
                                        "$ref": "#/components/schemas/StepPositionRef"
                                    },
                                    "count": {
                                        "type": "integer"
                                    }
                                }
                            },
                            {
                                "type": "null"
                            }
                        ],
                        "description": "The step where unfinished runs most often stopped."
                    },
                    "bottlenecks": {
                        "type": "array",
                        "description": "Up to five steps, slowest first.",
                        "items": {
                            "$ref": "#/components/schemas/Bottleneck"
                        }
                    },
                    "teams": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WorkflowTeamInsight"
                        }
                    }
                }
            },
            "TeamWorkflowInsight": {
                "type": "object",
                "description": "How the team does on one workflow, from its latest snapshot.",
                "required": [
                    "workflow",
                    "snapshot_date",
                    "total_runs",
                    "completed_runs",
                    "completion_rate",
                    "skip_rate",
                    "avg_duration_seconds",
                    "health_status"
                ],
                "properties": {
                    "workflow": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WorkflowRef"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    },
                    "snapshot_date": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date"
                    },
                    "total_runs": {
                        "type": "integer"
                    },
                    "completed_runs": {
                        "type": "integer"
                    },
                    "completion_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "skip_rate": {
                        "type": [
                            "number",
                            "null"
                        ],
                        "description": "Percentage from 0 to 100."
                    },
                    "avg_duration_seconds": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "health_status": {
                        "type": "string",
                        "enum": [
                            "good",
                            "warning",
                            "alert"
                        ]
                    }
                }
            },
            "TeamInsights": {
                "type": "object",
                "description": "How a team does on each workflow it runs, from the nightly snapshots.",
                "required": [
                    "team",
                    "window_days",
                    "workflows"
                ],
                "properties": {
                    "team": {
                        "$ref": "#/components/schemas/TeamRef"
                    },
                    "window_days": {
                        "type": "integer",
                        "enum": [
                            7,
                            30
                        ]
                    },
                    "workflows": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/TeamWorkflowInsight"
                        }
                    }
                }
            },
            "QueueRunRequest": {
                "type": "object",
                "description": "A run to put in a team's queue.",
                "required": [
                    "workflow_id"
                ],
                "properties": {
                    "workflow_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "A live workflow in this organization."
                    },
                    "team_id": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uuid",
                        "description": "Team whose queue gets the run. When the workflow is assigned to teams, it must be one of them. Leave out to queue the run with no team; it then shows in the queue of every team assigned to the workflow."
                    },
                    "name": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Display name for the run.",
                        "maxLength": 255
                    },
                    "external_ref": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Your reference, for example an order or ticket number. Filter runs by it later with filter[external_ref].",
                        "maxLength": 255
                    },
                    "priority": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "low",
                            "normal",
                            "high",
                            "critical",
                            null
                        ],
                        "description": "Defaults to normal."
                    },
                    "due_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "When the run is due. A date or date-time in the future."
                    },
                    "answers": {
                        "type": [
                            "array",
                            "null"
                        ],
                        "description": "Values to fill in ahead. Only short_text, long_text, number_input and date_picker steps accept one, and one answer per step. If any answer does not fit, the whole request fails with 422 and names it.",
                        "maxItems": 100,
                        "items": {
                            "type": "object",
                            "required": [
                                "step_id",
                                "value"
                            ],
                            "properties": {
                                "step_id": {
                                    "type": "string",
                                    "format": "uuid",
                                    "description": "A step in the workflow's live version."
                                },
                                "value": {
                                    "type": [
                                        "string",
                                        "number"
                                    ],
                                    "description": "The value, checked against the step's type and settings."
                                },
                                "mode": {
                                    "type": [
                                        "string",
                                        "null"
                                    ],
                                    "enum": [
                                        "editable",
                                        "readonly",
                                        "confirm",
                                        null
                                    ],
                                    "description": "editable (default): the worker can change it. readonly: shown as a value, not an input. confirm: the worker confirms or edits it before moving on."
                                }
                            }
                        }
                    }
                }
            },
            "CreateDraftWorkflowRequest": {
                "type": "object",
                "description": "Text to turn into a draft workflow.",
                "required": [
                    "name",
                    "text"
                ],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Name of the new workflow.",
                        "maxLength": 255
                    },
                    "text": {
                        "type": "string",
                        "description": "Plain description of the process. Vague text is refused with 422 on this field, with guidance.",
                        "maxLength": 6000
                    },
                    "team_ids": {
                        "type": [
                            "array",
                            "null"
                        ],
                        "description": "Teams to assign the draft to. Each must exist in this organization.",
                        "maxItems": 50,
                        "uniqueItems": true,
                        "items": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                }
            },
            "MeResponse": {
                "type": "object",
                "description": "Response body for GET /me.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Me"
                    }
                }
            },
            "WorkflowResponse": {
                "type": "object",
                "description": "A single workflow.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Workflow"
                    }
                }
            },
            "WorkflowList": {
                "type": "object",
                "description": "A page of workflows.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Workflow"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "DraftWorkflowResponse": {
                "type": "object",
                "description": "The draft workflow that was started.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/DraftWorkflow"
                    }
                }
            },
            "VersionList": {
                "type": "object",
                "description": "A page of workflow versions.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Version"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "WorkflowInsightsResponse": {
                "type": "object",
                "description": "Insights for one workflow.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/WorkflowInsights"
                    }
                }
            },
            "RunResponse": {
                "type": "object",
                "description": "A single run.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Run"
                    }
                }
            },
            "RunList": {
                "type": "object",
                "description": "A page of runs.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Run"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "FlagResponse": {
                "type": "object",
                "description": "A single flag.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Flag"
                    }
                }
            },
            "FlagList": {
                "type": "object",
                "description": "A page of flags.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Flag"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "TeamResponse": {
                "type": "object",
                "description": "A single team.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Team"
                    }
                }
            },
            "TeamList": {
                "type": "object",
                "description": "A page of teams.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Team"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "TeamInsightsResponse": {
                "type": "object",
                "description": "Insights for one team.",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/TeamInsights"
                    }
                }
            },
            "MemberList": {
                "type": "object",
                "description": "A page of members.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Member"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            },
            "SuggestionList": {
                "type": "object",
                "description": "A page of suggestions.",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Suggestion"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/ListMeta"
                    }
                }
            }
        }
    }
}
