Skip to main content
POST
/
browser
/
sessions
/
{id}
/
keyboard
/
type
Keyboard Type
curl --request POST \
  --url https://api.example.com/browser/sessions/{id}/keyboard/type \
  --header 'Content-Type: application/json' \
  --data '
{
  "text": "<string>",
  "selector": "<string>",
  "timeout": 123,
  "clear": true,
  "delay": 123
}
'
{
  "success": true,
  "charactersTyped": 123
}

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

id
string
required
Browser session ID (UUID).

Body

text
string
required
Text to type. UTF-8 supported. Each character fires a native keydown+keyup pair so input/change/autocomplete listeners run.
selector
string
Optional CSS selector to focus before typing. When omitted, keystrokes go to whatever element is currently focused.
timeout
integer
default:"5000"
How long to wait (ms) for the selector to become visible. Ignored when no selector is given.
clear
boolean
default:"false"
When true, clears the field’s current value before typing. Safe default is false so typing appends.
delay
integer
default:"40"
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)

success
boolean
True when the keystrokes were dispatched successfully.
charactersTyped
integer
Number of characters (UTF-8 code points) dispatched.
Example Response:
{
  "success": true,
  "charactersTyped": 18
}

Error Responses

StatusDescription
400Invalid body — missing text, delay out of range, bad parameters.
401Unauthorized — invalid or missing API key.
404Session not found, or selector did not become visible before timeout.
503The 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.