{
  "openapi": "3.1.0",
  "info": {
    "title": "DareBuild Codex Agent API",
    "version": "2026-07-18",
    "description": "OAuth-protected MCP plus tokenized Account and Project webhook APIs for DareBuild agents. Use OAuth authorization-code with PKCE for ChatGPT/App-style MCP clients, or use copied Account/Project Codex tokens for Codex and non-OAuth fallback clients."
  },
  "servers": [
    {
      "url": "https://elonman.darebuild.com"
    }
  ],
  "externalDocs": {
    "description": "DareBuild Agent README",
    "url": "https://elonman.darebuild.com/agents.md"
  },
  "paths": {
    "/.well-known/oauth-protected-resource": {
      "get": {
        "operationId": "mcpOAuthProtectedResource",
        "summary": "OAuth protected resource metadata for the account MCP server",
        "responses": {
          "200": {
            "description": "Protected resource metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "operationId": "mcpOAuthAuthorizationServer",
        "summary": "OAuth authorization server metadata",
        "responses": {
          "200": {
            "description": "Authorization server metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/oauth/register/": {
      "post": {
        "operationId": "mcpOAuthRegisterClient",
        "summary": "Dynamically register an OAuth client for MCP",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthClientRegistration"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered OAuth client",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/authorize/": {
      "get": {
        "operationId": "mcpOAuthAuthorize",
        "summary": "Authorize an OAuth client with PKCE",
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "const": "code"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": true,
            "schema": {
              "const": "S256"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTML approval page for the logged-in user",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "302": {
            "description": "Redirect with authorization code"
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token/": {
      "post": {
        "operationId": "mcpOAuthToken",
        "summary": "Exchange an authorization code for an MCP access token",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OAuth access token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/account/current/": {
      "get": {
        "operationId": "accountCurrentSession",
        "summary": "Discover the current account webhook from a logged-in session",
        "description": "Requires a normal DareBuild login session, usually created by a human-approved magic link. Returns the private account webhook URL, command catalog, projects, and capabilities.",
        "parameters": [
          {
            "name": "group_unique",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional team unique code when the logged-in user belongs to multiple teams."
          }
        ],
        "responses": {
          "200": {
            "description": "Current account payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/account/{account_token}/projects/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountToken"
        }
      ],
      "get": {
        "operationId": "accountListProjects",
        "summary": "List account projects and agent commands",
        "responses": {
          "200": {
            "description": "Account payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "accountAction",
        "summary": "Run an account-scoped action",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/AccountListAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountCreateProjectAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountConnectCloudflareAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountDisconnectCloudflareAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountConfigureCustomDomainAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountRemoveCustomDomainAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountProjectLimitApprovalAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountDeleteProjectAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountMemberAction"
                  },
                  {
                    "$ref": "#/components/schemas/AccountProjectCollaboratorAction"
                  }
                ]
              },
              "examples": {
                "list": {
                  "value": {
                    "action": "list"
                  }
                },
                "create": {
                  "value": {
                    "action": "create",
                    "name": "New app",
                    "starter_key": "blank",
                    "subdomain": "new-app"
                  }
                },
                "createCustomDomain": {
                  "value": {
                    "action": "create",
                    "name": "Test3 hello world",
                    "starter_key": "hello-world",
                    "subdomain": "test3",
                    "custom_domain": "test3.darefail.com",
                    "cloudflare": {
                      "zone_name": "darefail.com",
                      "proxy_mode": "dns_only"
                    }
                  }
                },
                "configureCustomDomain": {
                  "value": {
                    "action": "configure_custom_domain",
                    "project_id": 123,
                    "custom_domain": "test3.darefail.com",
                    "cloudflare": {
                      "zone_name": "darefail.com",
                      "proxy_mode": "dns_only"
                    }
                  }
                },
                "removeCustomDomain": {
                  "value": {
                    "action": "remove_custom_domain",
                    "project_id": 123,
                    "custom_domain": "test3.darefail.com"
                  }
                },
                "requestProjectLimitApproval": {
                  "value": {
                    "action": "request_project_limit_approval",
                    "name": "New app",
                    "starter_key": "blank"
                  }
                },
                "inviteProjectUser": {
                  "value": {
                    "action": "invite_project_user",
                    "project_url": "https://project-name.darebuild.com/",
                    "email": "editor@example.com",
                    "role": "editor",
                    "allowed_paths": [
                      "public/homepage.css",
                      "public/homepage.js"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/account/mcp/": {
      "get": {
        "operationId": "accountMcpInfoBearer",
        "summary": "Describe the bearer-auth account MCP server",
        "responses": {
          "200": {
            "description": "MCP server info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "accountMcpBearer",
        "summary": "Account MCP JSON-RPC endpoint using Authorization: Bearer",
        "security": [
          {
            "McpOAuth": [
              "darebuild.account"
            ]
          },
          {
            "AccountCodexBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/account/{account_token}/mcp/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountToken"
        }
      ],
      "get": {
        "operationId": "accountMcpInfo",
        "summary": "Describe the tokenized account MCP server",
        "responses": {
          "200": {
            "description": "MCP server info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "accountMcp",
        "summary": "Account MCP JSON-RPC endpoint",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/account/{account_token}/README.md": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountToken"
        }
      ],
      "get": {
        "operationId": "accountReadme",
        "summary": "Fetch the token-specific account agent README",
        "responses": {
          "200": {
            "description": "Markdown README",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/project/mcp/": {
      "get": {
        "operationId": "projectMcpInfoBearer",
        "summary": "Describe the bearer-auth project MCP server",
        "responses": {
          "200": {
            "description": "MCP server info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "projectMcpBearer",
        "summary": "Project MCP JSON-RPC endpoint using Authorization: Bearer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/mcp/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "get": {
        "operationId": "projectMcpInfo",
        "summary": "Describe the tokenized project MCP server",
        "responses": {
          "200": {
            "description": "MCP server info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "projectMcp",
        "summary": "Project MCP JSON-RPC endpoint",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/manifest/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "get": {
        "operationId": "projectManifest",
        "summary": "List project metadata, files, tasks, migrations, and permissions",
        "responses": {
          "200": {
            "description": "Project manifest",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/client.py": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "get": {
        "operationId": "projectClient",
        "summary": "Download a Python client for the project API",
        "responses": {
          "200": {
            "description": "Python client",
            "content": {
              "text/x-python": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/preview/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectPreview",
        "summary": "Render a preview with optional file overlays",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rendered preview",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/changes/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectPushChanges",
        "summary": "Push file changes and optionally publish",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Revision result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/media/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "get": {
        "operationId": "projectListMedia",
        "summary": "List project media uploaded through DareBuild",
        "responses": {
          "200": {
            "description": "Media list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "projectUploadMedia",
        "summary": "Upload images, videos, audio, fonts, or PDFs through DareBuild-managed storage",
        "description": "Agents must upload media through DareBuild and use returned URLs. Do not request AWS or S3 credentials.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/MediaUploadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Uploaded media",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/files/protection/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectProtectFiles",
        "summary": "Lock or hide files from AI",
        "description": "Codex can lock or hide files. Unlocking and unhiding require a human in the GUI.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FileProtectionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Protection result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/migrations/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectCreateMigration",
        "summary": "Create and optionally run a database migration",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MigrationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Migration result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/migrations/{migration_id}/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        },
        {
          "name": "migration_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "operationId": "projectMigrationDetail",
        "summary": "Fetch migration status",
        "responses": {
          "200": {
            "description": "Migration detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/tasks/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectCreateOrUpdateTask",
        "summary": "Create or update a background task",
        "description": "Creates or updates Python background task code. Backend-unlocked projects, including the jamespsteinberg@gmail.com free backend-access account, can use task code to launch project-owned or explicitly granted deployed Modal GPU functions through runner_service.sdk helpers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/tasks/{task_id}/run/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        },
        {
          "name": "task_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "operationId": "projectRunTask",
        "summary": "Queue a background task run",
        "description": "Queues a project background task run in the runner, including Modal GPU launcher tasks.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued task",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/modal/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "get": {
        "operationId": "projectListModalDeployments",
        "summary": "List project Modal deployments",
        "description": "Lists DareBuild-managed Modal deployments and enabled Modal function grants for the project. Modal credentials are never returned.",
        "responses": {
          "200": {
            "description": "Modal deployments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "projectManageModalDeployment",
        "summary": "Create, update, or destroy a project-owned Modal deployment",
        "description": "Deploys or destroys a DareBuild-managed Modal app under the runner account. Deploys generate app names as darebuild-build-<build_id>-<slug>, require source_code defining def handler(*args, **kwargs), record function grants, and queue Slack monitoring.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModalDeploymentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Modal deployment result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/codex/v1/{project_token}/project/": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectToken"
        }
      ],
      "post": {
        "operationId": "projectUpdateMetadata",
        "summary": "Update project metadata such as name or subdomain",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Project result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "McpOAuth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://elonman.darebuild.com/oauth/authorize/",
            "tokenUrl": "https://elonman.darebuild.com/oauth/token/",
            "scopes": {
              "darebuild.account": "Use DareBuild account MCP tools, including project tools that require project_id or project_url."
            }
          }
        }
      },
      "AccountCodexBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Legacy Account Codex token copied from Team settings or discovered through the logged-in session endpoint."
      }
    },
    "parameters": {
      "AccountToken": {
        "name": "account_token",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "Private Account Codex token copied from Team settings."
      },
      "ProjectToken": {
        "name": "project_token",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "Private Project Codex token returned by the account webhook."
      }
    },
    "schemas": {
      "OAuthClientRegistration": {
        "type": "object",
        "properties": {
          "client_name": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "scope": {
            "type": "string",
            "default": "darebuild.account"
          },
          "client_uri": {
            "type": "string",
            "format": "uri"
          },
          "logo_uri": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "redirect_uris"
        ],
        "additionalProperties": true
      },
      "OAuthTokenRequest": {
        "type": "object",
        "properties": {
          "grant_type": {
            "type": "string",
            "const": "authorization_code"
          },
          "client_id": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "redirect_uri": {
            "type": "string",
            "format": "uri"
          },
          "code_verifier": {
            "type": "string"
          },
          "resource": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "grant_type",
          "code",
          "redirect_uri",
          "code_verifier"
        ],
        "additionalProperties": true
      },
      "JsonRpcRequest": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "method": {
            "type": "string",
            "enum": [
              "initialize",
              "tools/list",
              "tools/call",
              "notifications/initialized"
            ]
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "jsonrpc",
          "method"
        ],
        "additionalProperties": true
      },
      "JsonRpcResponse": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "result": {
            "type": "object",
            "additionalProperties": true
          },
          "error": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "jsonrpc"
        ],
        "additionalProperties": true
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error_code": {
            "type": "string"
          },
          "error_message": {
            "type": "string"
          },
          "billing": {
            "$ref": "#/components/schemas/BillingStatus"
          },
          "payment_url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "ok",
          "error_code",
          "error_message"
        ]
      },
      "BillingStatus": {
        "type": "object",
        "properties": {
          "backend_access_enabled": {
            "type": "boolean"
          },
          "payment_required": {
            "type": "boolean"
          },
          "payment_url": {
            "type": "string",
            "format": "uri"
          },
          "checkout_start_url": {
            "type": "string",
            "format": "uri"
          },
          "checkout_method": {
            "type": "string",
            "enum": [
              "",
              "POST"
            ]
          },
          "card_entry": {
            "type": "string",
            "const": "gui_only"
          },
          "price": {
            "type": "string"
          },
          "free_backend_access": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AccountListAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "list",
              "list_projects",
              "list_members"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "ProjectLimitStatus": {
        "type": "object",
        "properties": {
          "active_count": {
            "type": "integer"
          },
          "limit": {
            "type": "integer",
            "default": 25
          },
          "remaining": {
            "type": [
              "integer",
              "null"
            ]
          },
          "limit_reached": {
            "type": "boolean"
          },
          "approval_required": {
            "type": "boolean"
          },
          "can_create_project": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "request_approval_action": {
            "type": "string",
            "const": "request_project_limit_approval"
          }
        }
      },
      "AccountCreateProjectAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "create",
              "create_project"
            ]
          },
          "name": {
            "type": "string"
          },
          "starter_key": {
            "type": "string",
            "enum": [
              "blank",
              "hello-world",
              "project-auth-password",
              "allauth-login-links",
              "todo-list",
              "background-timestamp-task"
            ]
          },
          "subdomain": {
            "type": "string",
            "description": "Optional DareBuild subdomain label, for example test3 for test3.darebuild.com."
          },
          "custom_domain": {
            "type": "string",
            "description": "Optional hostname to attach, for example test3.darefail.com."
          },
          "cloudflare": {
            "$ref": "#/components/schemas/CloudflareDnsConfig"
          }
        },
        "required": [
          "action",
          "name"
        ]
      },
      "AccountConnectCloudflareAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "connect_cloudflare",
              "cloudflare_connection",
              "cloudflare_status"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "AccountDisconnectCloudflareAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "disconnect_cloudflare",
              "remove_cloudflare_connection"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "AccountConfigureCustomDomainAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "configure_custom_domain",
              "connect_custom_domain",
              "connect_cloudflare_domain"
            ]
          },
          "project_id": {
            "type": "integer"
          },
          "custom_domain": {
            "type": "string",
            "example": "test3.darefail.com"
          },
          "cloudflare": {
            "$ref": "#/components/schemas/CloudflareDnsConfig"
          }
        },
        "required": [
          "action",
          "project_id",
          "custom_domain"
        ]
      },
      "AccountRemoveCustomDomainAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "remove_custom_domain",
              "disconnect_custom_domain",
              "delete_custom_domain"
            ]
          },
          "project_id": {
            "type": "integer"
          },
          "custom_domain": {
            "type": "string",
            "example": "test3.darefail.com"
          },
          "domain_id": {
            "type": "integer"
          }
        },
        "required": [
          "action",
          "project_id"
        ]
      },
      "CloudflareDnsConfig": {
        "type": "object",
        "properties": {
          "api_token": {
            "type": "string",
            "description": "Operator-only fallback one-time Cloudflare API token with Zone:DNS:Edit and Zone:Zone:Read permissions. End-user agents should use connect_cloudflare and the returned approval_url instead. The token is not returned by DareBuild."
          },
          "zone_id": {
            "type": "string"
          },
          "zone_name": {
            "type": "string",
            "example": "darefail.com"
          },
          "proxied": {
            "type": "boolean",
            "default": false,
            "description": "Only honored for compatibility. dns_only always creates an unproxied record; cloudflare_saas creates proxied routing through Cloudflare for SaaS. Use DNS records, not Cloudflare Workers, to connect custom domains to DareBuild projects."
          },
          "proxy_mode": {
            "type": "string",
            "enum": [
              "dns_only",
              "cloudflare_saas"
            ],
            "default": "dns_only",
            "description": "dns_only creates a gray-cloud CNAME. cloudflare_saas uses Cloudflare for SaaS Custom Hostnames and platform SaaS settings. Neither mode requires a Cloudflare Worker for ordinary domain setup."
          }
        }
      },
      "AccountProjectLimitApprovalAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "request_project_limit_approval",
              "request_project_approval"
            ]
          },
          "name": {
            "type": "string"
          },
          "starter_key": {
            "type": "string"
          }
        },
        "required": [
          "action"
        ]
      },
      "AccountDeleteProjectAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "delete",
              "delete_project"
            ]
          },
          "project_id": {
            "type": "integer"
          }
        },
        "required": [
          "action",
          "project_id"
        ]
      },
      "AccountMemberAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "invite_user",
              "update_member_role",
              "remove_member"
            ]
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "member",
              "editor"
            ]
          }
        },
        "required": [
          "action",
          "email"
        ]
      },
      "AccountProjectCollaboratorAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "list_project_collaborators",
              "invite_project_user",
              "remove_project_collaborator"
            ]
          },
          "project_id": {
            "type": "integer"
          },
          "project_url": {
            "type": "string",
            "format": "uri",
            "description": "Public project URL, for example https://project-name.darebuild.com/. Use this when the user supplies a project URL instead of an id."
          },
          "project_hostname": {
            "type": "string",
            "description": "Public project hostname, for example project-name.darebuild.com."
          },
          "project_subdomain": {
            "type": "string",
            "description": "DareBuild project subdomain label, for example project-name."
          },
          "project_public_code": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": [
              "editor"
            ]
          },
          "allowed_paths": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "action"
        ]
      },
      "MediaUploadRequest": {
        "type": "object",
        "properties": {
          "media": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "binary"
            },
            "description": "One or more images, videos, audio files, fonts, or PDFs."
          }
        },
        "required": [
          "media"
        ]
      },
      "MediaAsset": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "size_bytes": {
            "type": "integer"
          },
          "sha256": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "storage": {
            "type": "object",
            "properties": {
              "managed_by": {
                "type": "string",
                "const": "darebuild"
              },
              "account": {
                "type": "string"
              }
            },
            "description": "DareBuild-managed storage metadata. No AWS credentials are returned."
          }
        },
        "required": [
          "id",
          "name",
          "content_type",
          "size_bytes",
          "url"
        ]
      },
      "PreviewRequest": {
        "type": "object",
        "properties": {
          "page_slug": {
            "type": "string",
            "default": "homepage"
          },
          "files": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "method": {
            "type": "string",
            "default": "GET"
          },
          "path": {
            "type": "string"
          },
          "query": {
            "type": "object"
          },
          "post": {
            "type": "object"
          }
        }
      },
      "ChangesRequest": {
        "type": "object",
        "properties": {
          "files": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "delete": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publish": {
            "type": "boolean",
            "default": true
          },
          "message": {
            "type": "string"
          },
          "base_revision_id": {
            "type": "integer"
          }
        }
      },
      "FileProtectionRequest": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "lock",
              "hide",
              "lock_and_hide"
            ]
          },
          "paths": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "action",
          "paths"
        ]
      },
      "MigrationRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "sql": {
            "type": "string"
          },
          "run": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "name",
          "sql"
        ]
      },
      "TaskRequest": {
        "type": "object",
        "description": "Background task definition. Modal GPU launcher tasks should call runner_service.sdk.modal_function_spawn, modal_function_remote, or modal_function_get. The runner rejects Modal functions that are not project-owned or explicitly granted to the project.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "Python code executed by the runner background task."
          },
          "params": {
            "type": "object"
          },
          "cron_minute": {
            "type": "string",
            "default": "*"
          },
          "cron_hour": {
            "type": "string",
            "default": "*"
          },
          "cron_day_of_week": {
            "type": "string",
            "default": "*"
          },
          "cron_day_of_month": {
            "type": "string",
            "default": "*"
          },
          "cron_month_of_year": {
            "type": "string",
            "default": "*"
          },
          "cron_timezone": {
            "type": "string",
            "default": "UTC"
          },
          "enabled": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "name",
          "code"
        ]
      },
      "ModalDeploymentRequest": {
        "type": "object",
        "description": "DareBuild-managed Modal lifecycle request. action=deploy creates or updates a project-owned Modal app named darebuild-build-<build_id>-<slug>; action=destroy stops a managed app. Modal credentials stay in the runner and are never returned.",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "deploy",
              "create",
              "update",
              "destroy",
              "delete",
              "stop"
            ]
          },
          "id": {
            "type": "integer"
          },
          "deployment_id": {
            "type": "integer"
          },
          "slug": {
            "type": "string"
          },
          "app_name": {
            "type": "string",
            "description": "Optional for destroy only; deploy app_name is generated from the project id and slug."
          },
          "function_name": {
            "type": "string",
            "default": "run"
          },
          "source_code": {
            "type": "string",
            "description": "For deploy: Python source defining def handler(*args, **kwargs)."
          },
          "pip_packages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "gpu": {
            "type": "string",
            "enum": [
              "",
              "T4",
              "L4",
              "A10G",
              "A100",
              "A100-40GB",
              "A100-80GB",
              "H100",
              "H200",
              "B200"
            ]
          },
          "timeout_seconds": {
            "type": "integer",
            "default": 300,
            "minimum": 1,
            "maximum": 3600
          },
          "environment_name": {
            "type": "string"
          }
        },
        "required": [
          "action"
        ]
      },
      "ProjectUpdateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          }
        }
      }
    }
  }
}