For AI agents: a documentation index is available at /llms.txt
Skip to main content

Fill and Submit a Form

Automate form interactions: typing into fields, selecting options, solving CAPTCHAs, and clicking submit.

Prerequisites

Steps

Use the REST API to fill and submit a form without opening a persistent browser connection.

View Full Code on GitHub

1. Build the BrowserQL mutation

Use the BrowserQL endpoint to navigate, fill fields, and submit the form in a single request:

https://production-sfo.browserless.io/chromium/bql?token=YOUR_API_TOKEN_HERE

2. Send the request

curl -X POST \
"https://production-sfo.browserless.io/chromium/bql?token=YOUR_API_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation FormExample { goto(url: \"https://www.browserless.io/practice-form\") { status } typeEmail: type(text: \"user@example.com\", selector: \"#Email\") { time } typeMessage: type(selector: \"#Message\", text: \"Hello from Browserless!\") { time } subject: select(selector: \"select#Subject\", value: \"Support\") { selector } solve { time solved } }",
"variables": {},
"operationName": "FormExample"
}'

The complete mutation including submitForm is shown in the BQL tab.

3. Check the output

The response is JSON confirming each mutation completed, including whether the CAPTCHA was solved:

{
"data": {
"goto": { "status": 200 },
"typeEmail": { "time": 120 },
"solve": { "time": 4200, "solved": true }
}
}

Next steps