Overview
Dispatches real keydown+keyup events one character at a time against the active page of a browser session. Works with any focused input — if selector is provided, the target element is focused (and optionally cleared) before typing.
Path Parameters
Browser session ID (UUID).
Body
Text to type. UTF-8 supported. Each character fires a native keydown+keyup pair so input/change/autocomplete listeners run.
Optional CSS selector to focus before typing. When omitted, keystrokes go to whatever element is currently focused.
How long to wait (ms) for the selector to become visible. Ignored when no selector is given.
When true, clears the field’s current value before typing. Safe default is false so typing appends.
Base inter-key delay in milliseconds. Capped at 5000.
Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/keyboard/type" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"selector": "#email",
"text": "[email protected]",
"clear": true
}'
Response
Success Response (200)
True when the keystrokes were dispatched successfully.
Number of characters (UTF-8 code points) dispatched.
Example Response:
{
"success": true,
"charactersTyped": 18
}
Error Responses
| Status | Description |
|---|
400 | Invalid body — missing text, delay out of range, bad parameters. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found, or selector did not become visible before timeout. |
503 | The browser session is temporarily unreachable. |
Notes
- Composed input is not supported. CJK dead-key composition, emoji composition sequences, and similar composed input are typed character-by-character, not as composition events.
- Existing value is preserved unless
clear: true. Typing appends to the field’s current value. Set clear: true to overwrite.
- Shadow-root and iframe targets aren’t addressable. If the element is inside a shadow root or cross-origin iframe, the selector must match the shadow host or the endpoint will return 404.