{
  "openapi": "3.1.0",
  "info": {
    "title": "Promptbox Browser",
    "version": "2.3.1",
    "description": "Control a JavaScript-enabled browser: navigate, inspect pages, fill forms, click controls, manage tabs, take screenshots, and reuse saved profiles. POST JSON with a bearer API key from admin@promptbox.cn. Set mode=agent for guided control IDs; omit it for low-level locators. Use current page IDs and a unique request_id for each state-changing action. Operations have a 45-second deadline; expired agent operations close their sessions. Inspect uncertain results before retrying. Human-verification pages require human help. See browser.md for actions, limits, and recovery. Version 2.3.1 bounds browser CPU and raster thread pools and corrects automatic startup under web-worker virtual-memory limits. The helper allows up to 110 hosting threads within the verified 120-thread account allowance, preserves ten slots for other work, and reserves capacity before opening pages. Resource-intensive pages may still close sessions; inspect uncertain results before recovery.",
    "contact": {
      "email": "admin@promptbox.cn"
    }
  },
  "servers": [
    {
      "url": "https://promptbox.cn"
    }
  ],
  "security": [
    {
      "browserKey": []
    }
  ],
  "paths": {
    "/api/browser.php": {
      "post": {
        "operationId": "browserAction",
        "summary": "Perform one browser action",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "create",
                      "close",
                      "navigate",
                      "snapshot",
                      "click",
                      "fill",
                      "press",
                      "select",
                      "check",
                      "hover",
                      "scroll",
                      "wait",
                      "screenshot",
                      "tabs",
                      "new_tab",
                      "switch_tab",
                      "close_tab",
                      "back",
                      "forward",
                      "reload",
                      "evaluate",
                      "save_profile",
                      "delete_profile",
                      "dialog_policy",
                      "drag",
                      "sessions",
                      "open",
                      "follow",
                      "fill_form"
                    ]
                  },
                  "session_id": {
                    "type": "string"
                  },
                  "tab_id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "profile": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,64}$"
                  },
                  "selector": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "frame": {
                    "type": "string"
                  },
                  "exact": {
                    "type": "boolean"
                  },
                  "value": {},
                  "key": {
                    "type": "string"
                  },
                  "checked": {
                    "type": "boolean"
                  },
                  "expression": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "agent"
                    ],
                    "description": "Omit for original low-level interface."
                  },
                  "prompt_text": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "attached",
                      "detached",
                      "visible",
                      "hidden"
                    ]
                  },
                  "timeout_ms": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25000
                  },
                  "width": {
                    "type": "number"
                  },
                  "height": {
                    "type": "number"
                  },
                  "x": {
                    "type": "number"
                  },
                  "y": {
                    "type": "number"
                  },
                  "from_x": {
                    "type": "number"
                  },
                  "from_y": {
                    "type": "number"
                  },
                  "to_x": {
                    "type": "number"
                  },
                  "to_y": {
                    "type": "number"
                  },
                  "request_id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{8,160}$",
                    "description": "Required for agent mutations. Duplicate ID within 24 hours prevents redispatch."
                  },
                  "page_id": {
                    "type": "string",
                    "description": "Latest observed page ID; prior controls become stale."
                  },
                  "field_id": {
                    "type": "string"
                  },
                  "target_id": {
                    "type": "string"
                  },
                  "link_id": {
                    "type": "string"
                  },
                  "focus": {
                    "type": "string",
                    "description": "Filter observed controls by text/label."
                  },
                  "fields": {
                    "type": "object",
                    "maxProperties": 20,
                    "additionalProperties": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "description": "Agent fill_form: observed field IDs to values; selects use opaque option IDs. Sequential; does not submit."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action result with ok=true. See browser.md for action-specific result fields.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "session_id": {
                      "type": "string"
                    },
                    "tab_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "JSON error. Do not automatically retry side-effecting actions."
          }
        }
      },
      "get": {
        "operationId": "browserHealth",
        "summary": "Authenticated worker health when health=1, otherwise public metadata",
        "parameters": [
          {
            "name": "health",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                1
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Worker readiness or endpoint metadata"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "browserKey": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
