{
  "openapi": "3.1.0",
  "info": {
    "title": "Monomer Agent API",
    "version": "2.0.0",
    "description": "The API that agents and your own programs use with Monomer: discovery, Organization and Workspace operations, the MCP server, and OAuth sign-in. Beta — may change."
  },
  "servers": [
    {
      "url": "https://api.monomer.cc",
      "description": "Public Control origin"
    }
  ],
  "x-monomer-public-contract": {
    "workspaceAuthority": "PATH_ONLY",
    "strictJson": "I_JSON_AND_RFC8785_JCS",
    "agentOAuthResources": {
      "AGENT_REST": "https://api.monomer.cc/v2/workspaces",
      "AGENT_MCP": "https://api.monomer.cc/mcp"
    }
  },
  "paths": {
    "/v2/workspaces/{workspaceId}/agent/explore/runs/{runId}/result": {
      "get": {
        "operationId": "downloadAgentExploreRunResult",
        "summary": "Download an Explore result with Agent REST OAuth authorization",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceId"
          },
          {
            "$ref": "#/components/parameters/ExploreRunId"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "csv",
                "arrow"
              ],
              "default": "arrow"
            },
            "description": "CSV is UTF-8 with BOM and formula mitigation, capped at 1,000,000,000 output bytes. Arrow preserves the original artifact. Interrupted transfers are not complete files."
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/ExploreResultArtifactResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/list": {
      "post": {
        "operationId": "agentWorkspaceList",
        "summary": "List Workspace resources",
        "description": "Lists installed Agent Workspace collections allowed by the current cumulative Workspace role, ordered by path with a cursor. Viewer discovery exposes Pages only; Explorer exposes internal collections; Owner additionally exposes management collections. Uninstalled owners are not advertised. Unfetched Catalog options return 409 CATALOG_SELECTION_OPTIONS_NOT_FETCHED with retryable=false and advertise refresh only to an admitted Explorer or higher. LIST never starts refresh, ingestion, or warehouse I/O.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentListRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentResourceListingResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/search": {
      "post": {
        "operationId": "agentWorkspaceSearch",
        "summary": "Search Workspace resources",
        "description": "Searches supported Workspace resources, one result list per query. path, queries, and limitPerQuery are required, and results return in input order. Supported kinds are CONNECTOR, CATALOG, SCHEMA, RELATION, SEMANTIC_MODEL, METRIC, DASHBOARD, and PAGE. PAGE searches current display titles by case-insensitive substring matching of every whitespace-separated query word; Page descriptions and Document content are not searched. workspace/pages searches Pages only; workspace with kinds [PAGE] is also Page-only. These requests allow Viewer or higher with current direct membership: Viewer sees only currently placed Pages and reader metadata as in Web, while Explorer or higher sees the authoring inventory including unplaced Pages. Deleted Pages are excluded. Other searches require Explorer or higher and search resource names and descriptions. Omitting kinds searches every supported kind in scope. Mixed results keep ranked metadata hits before Page hits under one limitPerQuery. There is no cursor.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentSearchRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentSearchResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/read": {
      "post": {
        "operationId": "agentWorkspaceRead",
        "summary": "Read a Workspace resource",
        "description": "Reads one exact Agent Workspace resource. availableOperations lists every follow-up operation that applies to the current caller and state; it is not final authorization or a guarantee of success. The workspace root's resources offer the same collection LIST. A current Dashboard includes Draft READ when the caller can edit and a Draft exists. A Draft or Session advertises refresh only when it has queries, and a Session advertises EDIT only when it has Variables. An empty Catalog Selection still offers the ingestion history LIST.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentReadRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentResourceEnvelopeResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/create": {
      "post": {
        "operationId": "agentWorkspaceCreate",
        "summary": "Create a Workspace resource",
        "description": "Creates a declared child resource from its collection input. Duplicate canonical names are conflicts; the Agent channel scope does not replace the user's cumulative Workspace role.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentCreateRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentActionResultResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/edit": {
      "post": {
        "operationId": "agentWorkspaceEdit",
        "summary": "Edit a Workspace resource",
        "description": "A closed request, selected by path, for a Semantic Model, Metric, Dashboard Draft, Dashboard Session, Connector Catalog Selection, or Catalog Selection. Applies 1 to 100 operations in order, atomically, to the owner's editable document (not the read envelope), and the owner validates the final document. Semantic Models, Metrics, and Selections are last-write-wins and reject revision, including null; Drafts and Sessions require a string revision for compare-and-set. A Selection accepts exactly one root replace with a complete document, and a Session accepts only replace of existing Variable names. A root replace for a Semantic definition or Draft needs a complete owner document, and intermediate documents during a partial patch may be incomplete. Identity and server state can't be edited; the owner checks the name match, existing keys, declared types, and revision at run time. Saving a Semantic definition with unresolved references doesn't guarantee that it can run.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentEditRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentActionResultResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/workspaces/{workspaceId}/agent/invoke": {
      "post": {
        "operationId": "agentWorkspaceInvoke",
        "summary": "Invoke a Workspace action",
        "description": "Passes a declared owner action to the current owner use case. Dashboard Draft start returns an existing Draft unchanged without applying the input parameterBindings, and creates a Draft from the bindings only when none exists; use edit to change an existing Draft's inputs. Every call revalidates input, permission, and state.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentWorkspaceId"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentInvokeRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentActionResultResponse"
          },
          "202": {
            "$ref": "#/components/responses/AgentActionResultAcceptedResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "operationId": "discoverAgentAuthorizationServer",
        "summary": "Get the OAuth authorization server metadata",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthAuthorizationServerMetadata"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource/mcp": {
      "get": {
        "operationId": "discoverMcpResource",
        "summary": "Get the protected resource metadata for MCP",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthProtectedResourceMetadata"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource/v2/workspaces": {
      "get": {
        "operationId": "discoverAgentRestResource",
        "summary": "Get the protected resource metadata for the REST API",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthProtectedResourceMetadata"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        }
      }
    },
    "/oauth/authorize": {
      "get": {
        "operationId": "authorizeAgentConnection",
        "summary": "Start OAuth authorization in the browser",
        "security": [],
        "responses": {
          "302": {
            "description": "Validated request redirects to browser consent; no credential in URL"
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        },
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resource",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "exchangeAgentOAuthToken",
        "summary": "Exchange an authorization code or refresh token for tokens",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "grant_type": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "resource": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "code_verifier": {
                    "type": "string"
                  },
                  "redirect_uri": {
                    "type": "string"
                  },
                  "refresh_token": {
                    "type": "string"
                  },
                  "scope": {
                    "type": "string"
                  }
                },
                "required": [
                  "grant_type",
                  "client_id",
                  "resource"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/oauth/revoke": {
      "post": {
        "operationId": "revokeAgentOAuthToken",
        "summary": "Revoke a token",
        "security": [],
        "responses": {
          "200": {
            "description": "Token invalidated or unknown (indistinguishable)"
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "$ref": "#/components/responses/AgentOAuthError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_id": {
                    "type": "string"
                  },
                  "token": {
                    "type": "string"
                  },
                  "token_type_hint": {
                    "type": "string"
                  }
                },
                "required": [
                  "client_id",
                  "token"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpMessage",
        "summary": "Send an MCP JSON-RPC message",
        "security": [
          {
            "agentMcpOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted"
          },
          "400": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "401": {
            "description": "OAuth required",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer resource_metadata pointing to MCP PRM"
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "429": {
            "$ref": "#/components/responses/AgentOAuthError"
          },
          "503": {
            "description": "OAuth token validation unavailable; no JSON-RPC handling",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Seconds before retrying"
              }
            }
          }
        },
        "description": "Stateless Streamable HTTP JSON-RPC 2.0 with ten tools. Every request, including initialization, notifications and tool listing, requires user-scoped AGENT_MCP OAuth with agent.workspace. monomer_list with only path=organizations or path=workspaces discovers current accessible Organizations or directly joined Workspaces. Organization resource calls require organizationId and omit workspaceId; Workspace resource calls require workspaceId and omit organizationId. monomer_docs reads public task guides without a target. No durable MCP session or persistent SSE.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "get": {
        "operationId": "mcpStreamUnsupported",
        "summary": "Open an event stream (not supported)",
        "security": [
          {
            "agentMcpOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "OAuth required",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer resource_metadata pointing to MCP PRM"
              }
            }
          },
          "405": {
            "description": "No persistent SSE stream"
          },
          "503": {
            "description": "OAuth token validation unavailable; no JSON-RPC handling",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Seconds before retrying"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "mcpSessionDeleteUnsupported",
        "summary": "Delete a session (not supported)",
        "security": [
          {
            "agentMcpOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "OAuth required",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer resource_metadata pointing to MCP PRM"
              }
            }
          },
          "405": {
            "description": "No durable MCP session"
          },
          "503": {
            "description": "OAuth token validation unavailable; no JSON-RPC handling",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Seconds before retrying"
              }
            }
          }
        }
      }
    },
    "/v2/agent/list": {
      "post": {
        "operationId": "agentDiscover",
        "summary": "List the Organizations or Workspaces you can access",
        "description": "Discover joined Organizations or directly joined Workspaces across all Organizations for the authenticated user. Only path is accepted.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "path"
                ],
                "properties": {
                  "path": {
                    "type": "string",
                    "enum": [
                      "organizations",
                      "workspaces"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Current accessible Organizations or Workspaces",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/OAuthOrganizationList"
                    },
                    {
                      "$ref": "#/components/schemas/OAuthWorkspaceList"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v2/agent/organizations/{organizationId}/list": {
      "post": {
        "operationId": "agentOrganizationList",
        "summary": "List Organization resources",
        "description": "Uses the explicitly targeted Organization and current Identity permissions. The OAuth grant identifies the user, not the Organization. No actor, organization or Workspace identifiers are accepted in the request body.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./agent-workspace.schema.json#/$defs/AgentOrganizationListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentResourceListingResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        },
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        ]
      }
    },
    "/v2/agent/organizations/{organizationId}/read": {
      "post": {
        "operationId": "agentOrganizationRead",
        "summary": "Read an Organization resource",
        "description": "Uses the explicitly targeted Organization and current Identity permissions. The OAuth grant identifies the user, not the Organization. No actor, organization or Workspace identifiers are accepted in the request body.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./agent-workspace.schema.json#/$defs/AgentOrganizationReadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentResourceEnvelopeResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        },
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        ]
      }
    },
    "/v2/agent/organizations/{organizationId}/create": {
      "post": {
        "operationId": "agentOrganizationCreate",
        "summary": "Create an Organization resource",
        "description": "Uses the explicitly targeted Organization and current Identity permissions. The OAuth grant identifies the user, not the Organization. No actor, organization or Workspace identifiers are accepted in the request body.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./agent-workspace.schema.json#/$defs/AgentOrganizationCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentActionResultResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        },
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        ]
      }
    },
    "/v2/agent/organizations/{organizationId}/invoke": {
      "post": {
        "operationId": "agentOrganizationInvoke",
        "summary": "Invoke an Organization action",
        "description": "Uses the explicitly targeted Organization and current Identity permissions. The OAuth grant identifies the user, not the Organization. No actor, organization or Workspace identifiers are accepted in the request body.",
        "security": [
          {
            "agentOAuth": [
              "agent.workspace"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./agent-workspace.schema.json#/$defs/AgentOrganizationInvokeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentActionResultResponse"
          },
          "202": {
            "$ref": "#/components/responses/AgentActionResultAcceptedResponse"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Problem500"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        },
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        ]
      }
    }
  },
  "components": {
    "headers": {
      "RetryAfterTwoSeconds": {
        "required": true,
        "schema": {
          "const": "2"
        }
      },
      "WwwAuthenticate": {
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "parameters": {
      "AgentWorkspaceId": {
        "name": "workspaceId",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "./agent-workspace.schema.json#/$defs/Uuid"
        }
      },
      "ExploreRunId": {
        "name": "runId",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/Uuid"
        }
      },
      "WorkspaceId": {
        "name": "workspaceId",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/Uuid"
        }
      }
    },
    "requestBodies": {
      "AgentCreateRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentCreateRequest"
            }
          }
        }
      },
      "AgentEditRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentEditRequest"
            }
          }
        }
      },
      "AgentInvokeRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentInvokeRequest"
            }
          }
        }
      },
      "AgentListRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentListRequest"
            }
          }
        }
      },
      "AgentReadRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentReadRequest"
            }
          }
        }
      },
      "AgentSearchRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentSearchRequest"
            }
          }
        }
      }
    },
    "responses": {
      "AgentActionResultAcceptedResponse": {
        "description": "Accepted asynchronous Agent action",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfterTwoSeconds"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentActionResult"
            }
          }
        }
      },
      "AgentActionResultResponse": {
        "description": "Completed synchronous Agent action",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentActionResult"
            }
          }
        }
      },
      "AgentOAuthError": {
        "description": "OAuth error without secrets or credential validity details",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        }
      },
      "AgentResourceEnvelopeResponse": {
        "description": "Canonical Agent resource envelope",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentResourceEnvelope"
            }
          }
        }
      },
      "AgentResourceListingResponse": {
        "description": "Canonical Agent resource listing response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentResourceListingResponse"
            }
          }
        }
      },
      "AgentSearchResponse": {
        "description": "Search results for each query, in the same order and number as the input queries.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentSearchResponse"
            }
          }
        }
      },
      "BadRequest": {
        "$ref": "#/components/responses/Problem400"
      },
      "Conflict": {
        "$ref": "#/components/responses/Problem409"
      },
      "ExploreResultArtifactResponse": {
        "description": "Original retained Arrow artifact or streamed CSV. CSV has no precomputed Content-Length; clients must reject interrupted transfers.",
        "headers": {
          "Content-Disposition": {
            "description": "Attachment filename for the Arrow artifact",
            "schema": {
              "type": "string"
            }
          },
          "Cache-Control": {
            "description": "Prevents browser and intermediary storage",
            "schema": {
              "type": "string",
              "const": "no-store"
            }
          }
        },
        "content": {
          "application/vnd.apache.arrow.file": {
            "schema": {
              "type": "string",
              "format": "binary"
            }
          },
          "text/csv": {
            "schema": {
              "type": "string",
              "format": "binary"
            }
          }
        }
      },
      "Forbidden": {
        "$ref": "#/components/responses/Problem403"
      },
      "Gone": {
        "description": "Explore result retention expired"
      },
      "NotFound": {
        "$ref": "#/components/responses/Problem404"
      },
      "Problem400": {
        "description": "Closed schema, path, or cursor Problem Details",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem401": {
        "description": "Missing or invalid credential Problem Details",
        "headers": {
          "WWW-Authenticate": {
            "$ref": "#/components/headers/WwwAuthenticate"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem403": {
        "description": "An admitted member lacks the required role: ROLE_REQUIRED Problem Details. Missing membership or target returns 404; invalid or expired credentials return 401.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem404": {
        "description": "Unknown, internal, or other-workspace identifier Problem Details with indistinguishable shape",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem409": {
        "description": "Revision, idempotency, cursor, cancellation, or result-readiness conflict Problem Details. Dashboard concurrency codes SESSION_CONFLICT, QUERY_RUN_CONFLICT, DRAFT_CONFLICT, EXECUTION_ADMISSION_CONFLICT and QUERY_RUN_CANCEL_CONFLICT are retryable.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem429": {
        "description": "Admission/backpressure Problem Details",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfterTwoSeconds"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem500": {
        "description": "Unexpected internal owner execution argument error. INTERNAL_ERROR is logged, sanitized, and not retryable; read the target before resending creates or starts.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "Problem503": {
        "description": "Owner or infrastructure Problem Details. EXECUTION_BACKPRESSURED is retryable. Retry-After is present if and only if retryable is true. Unconfirmed non-idempotent Agent changes use OWNER_UNAVAILABLE with retryable=false and require reading the target before resending.",
        "headers": {
          "Retry-After": {
            "description": "Present if and only if the Problem Details body has retryable=true. Absent for retryable=false, including AUTHENTICATION_FAILED and unconfirmed non-idempotent Agent changes.",
            "required": false,
            "schema": {
              "const": "2"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "$ref": "#/components/responses/Problem503"
      },
      "TooManyRequests": {
        "$ref": "#/components/responses/Problem429"
      },
      "Unauthorized": {
        "$ref": "#/components/responses/Problem401"
      }
    },
    "schemas": {
      "AgentActionResult": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentActionResult"
      },
      "AgentCreateRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentCreateRequest"
      },
      "AgentEditRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentEditRequest"
      },
      "AgentInvokeRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentInvokeRequest"
      },
      "AgentListRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentListRequest"
      },
      "AgentReadRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentReadRequest"
      },
      "AgentResourceEnvelope": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentResourceEnvelope"
      },
      "AgentResourceListingResponse": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentResourceListingResponse"
      },
      "AgentSearchRequest": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentSearchRequest"
      },
      "AgentSearchResponse": {
        "$ref": "./agent-workspace.schema.json#/$defs/AgentSearchResponse"
      },
      "OAuthAuthorizationServerMetadata": {
        "type": "object",
        "required": [
          "issuer",
          "authorization_endpoint",
          "token_endpoint",
          "revocation_endpoint",
          "response_types_supported",
          "grant_types_supported",
          "code_challenge_methods_supported",
          "token_endpoint_auth_methods_supported",
          "revocation_endpoint_auth_methods_supported",
          "scopes_supported",
          "client_id_metadata_document_supported",
          "authorization_response_iss_parameter_supported"
        ],
        "properties": {
          "issuer": {
            "type": "string",
            "format": "uri"
          },
          "authorization_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "token_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "revocation_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "response_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "revocation_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "client_id_metadata_document_supported": {
            "type": "boolean"
          },
          "authorization_response_iss_parameter_supported": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "OAuthError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "OAuthOrganization": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "displayName": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "ADMIN",
              "MEMBER"
            ]
          }
        },
        "required": [
          "organizationId",
          "displayName",
          "role"
        ],
        "additionalProperties": false
      },
      "OAuthOrganizationList": {
        "type": "object",
        "properties": {
          "organizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OAuthOrganization"
            }
          }
        },
        "required": [
          "organizations"
        ],
        "additionalProperties": false
      },
      "OAuthProtectedResourceMetadata": {
        "type": "object",
        "required": [
          "resource",
          "authorization_servers",
          "scopes_supported",
          "bearer_methods_supported"
        ],
        "properties": {
          "resource": {
            "type": "string",
            "format": "uri"
          },
          "authorization_servers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bearer_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "OAuthTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "const": "Bearer",
            "type": "string"
          },
          "expires_in": {
            "type": "integer",
            "minimum": 1
          },
          "refresh_token": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "const": "agent.workspace"
          }
        },
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "refresh_token",
          "scope"
        ],
        "additionalProperties": false
      },
      "OAuthWorkspace": {
        "type": "object",
        "properties": {
          "workspaceId": {
            "type": "string",
            "format": "uuid"
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "displayName": {
            "type": "string"
          },
          "organizationDisplayName": {
            "type": "string"
          },
          "sample": {
            "description": "Monomer's read-only sample data for Acme Cloud, a fictional company; null for a Workspace with your own data.",
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OAuthWorkspaceSample"
              }
            ]
          }
        },
        "required": [
          "workspaceId",
          "organizationId",
          "displayName",
          "organizationDisplayName",
          "sample"
        ],
        "additionalProperties": false
      },
      "OAuthWorkspaceList": {
        "type": "object",
        "properties": {
          "workspaces": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OAuthWorkspace"
            }
          }
        },
        "required": [
          "workspaces"
        ],
        "additionalProperties": false
      },
      "OAuthWorkspaceSample": {
        "type": "object",
        "properties": {
          "dataset": {
            "type": "string",
            "enum": [
              "acme-cloud@1",
              "acme-cloud@2",
              "acme-cloud@3"
            ]
          }
        },
        "required": [
          "dataset"
        ],
        "additionalProperties": false
      },
      "ProblemDetails": {
        "$ref": "./problem-details.schema.json"
      },
      "Uuid": {
        "type": "string",
        "format": "uuid"
      }
    },
    "securitySchemes": {
      "agentMcpOAuth": {
        "type": "oauth2",
        "description": "Every MCP request requires the existing AGENT_MCP OAuth resource. The channel scope is intersected with the authenticated user's current product permissions.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.monomer.cc/oauth/authorize",
            "tokenUrl": "https://api.monomer.cc/oauth/token",
            "scopes": {
              "agent.workspace": "Call the Agent Workspace MCP channel; current Workspace roles are evaluated from the authenticated user's current membership."
            }
          }
        },
        "x-monomer-expected-oauth-resource": "AGENT_MCP"
      },
      "agentOAuth": {
        "type": "oauth2",
        "description": "The trusted Agent REST ingress chooses the closed expected OAuth resource; callers cannot choose it from a body or Host header. The single channel scope is intersected with the authenticated user's current product permissions.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.monomer.cc/oauth/authorize",
            "tokenUrl": "https://api.monomer.cc/oauth/token",
            "scopes": {
              "agent.workspace": "Call the Agent Workspace REST channel; cumulative Workspace roles are evaluated from the authenticated user's current membership."
            }
          }
        },
        "x-monomer-expected-oauth-resource": "AGENT_REST"
      }
    }
  }
}
