sessions
Execute Session File
POST
/
sessions
/
{session_id}
/
page
/
execute
/
file
Execute Session File
curl --request POST \
--url https://api.example.com/sessions/{session_id}/page/execute/file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"file_path": "<string>",
"type": "upload_file",
"category": "Interaction Actions",
"description": "Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.",
"id": "",
"selector": "<string>",
"press_enter": true,
"text_label": "<string>",
"param": {
"name": "file_path",
"type": "str",
"values": []
},
"timeout": 15000
},
"target_id": "<string>",
"record": true
}
'import requests
url = "https://api.example.com/sessions/{session_id}/page/execute/file"
payload = {
"action": {
"file_path": "<string>",
"type": "upload_file",
"category": "Interaction Actions",
"description": "Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.",
"id": "",
"selector": "<string>",
"press_enter": True,
"text_label": "<string>",
"param": {
"name": "file_path",
"type": "str",
"values": []
},
"timeout": 15000
},
"target_id": "<string>",
"record": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: {
file_path: '<string>',
type: 'upload_file',
category: 'Interaction Actions',
description: 'Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.',
id: '',
selector: '<string>',
press_enter: true,
text_label: '<string>',
param: {name: 'file_path', type: 'str', values: []},
timeout: 15000
},
target_id: '<string>',
record: true
})
};
fetch('https://api.example.com/sessions/{session_id}/page/execute/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sessions/{session_id}/page/execute/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => [
'file_path' => '<string>',
'type' => 'upload_file',
'category' => 'Interaction Actions',
'description' => 'Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.',
'id' => '',
'selector' => '<string>',
'press_enter' => true,
'text_label' => '<string>',
'param' => [
'name' => 'file_path',
'type' => 'str',
'values' => [
]
],
'timeout' => 15000
],
'target_id' => '<string>',
'record' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sessions/{session_id}/page/execute/file"
payload := strings.NewReader("{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sessions/{session_id}/page/execute/file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sessions/{session_id}/page/execute/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}"
response = http.request(request)
puts response.read_body{
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"action": {
"value": {},
"type": "form_fill",
"category": "Special Browser Actions",
"description": "Fill a form with multiple values. Important: If you detect a form requesting personal information, try to use this action at first, and otherwise use the regular fill action. CRITICAL: If this action fails once, use the regular form fill instead."
},
"success": true,
"message": "<string>",
"data": {
"markdown": "<string>",
"images": [
{
"url": "<string>",
"category": "favicon",
"description": "<string>"
}
],
"structured": {
"success": true,
"error": "<string>",
"data": {}
}
},
"exception": "<string>",
"exception_detail": {
"error_type": "<string>",
"dev_message": "<string>",
"user_message": "<string>",
"agent_message": "<string>",
"should_retry_later": false,
"should_notify_team": false
},
"captcha": {
"captcha_id": "<string>",
"page_id": "<string>",
"generation": 123,
"state": "solving",
"retry_after_ms": 1000,
"message": "",
"cancel_reason": "navigation"
},
"action_executed": true,
"code": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Path Parameters
Query Parameters
Body
application/json
Response
Successful Response
- FormFillAction
- GotoAction
- GotoNewTabAction
- CloseTabAction
- SwitchTabAction
- GoBackAction
- GoForwardAction
- ReloadAction
- WaitAction
- PressKeyAction
- ScrollUpAction
- ScrollDownAction
- CaptchaSolveAction
- HelpAction
- CompletionAction
- ScrapeAction
- EmailReadAction
- EmailVerificationReadAction
- SmsReadAction
- EvaluateJsAction
- ClickAction
- FillAction
- MultiFactorFillAction
- FallbackFillAction
- CheckAction
- SelectDropdownOptionAction
- UploadFileAction
- DownloadFileAction
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Execute Session File
curl --request POST \
--url https://api.example.com/sessions/{session_id}/page/execute/file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"file_path": "<string>",
"type": "upload_file",
"category": "Interaction Actions",
"description": "Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.",
"id": "",
"selector": "<string>",
"press_enter": true,
"text_label": "<string>",
"param": {
"name": "file_path",
"type": "str",
"values": []
},
"timeout": 15000
},
"target_id": "<string>",
"record": true
}
'import requests
url = "https://api.example.com/sessions/{session_id}/page/execute/file"
payload = {
"action": {
"file_path": "<string>",
"type": "upload_file",
"category": "Interaction Actions",
"description": "Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.",
"id": "",
"selector": "<string>",
"press_enter": True,
"text_label": "<string>",
"param": {
"name": "file_path",
"type": "str",
"values": []
},
"timeout": 15000
},
"target_id": "<string>",
"record": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: {
file_path: '<string>',
type: 'upload_file',
category: 'Interaction Actions',
description: 'Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.',
id: '',
selector: '<string>',
press_enter: true,
text_label: '<string>',
param: {name: 'file_path', type: 'str', values: []},
timeout: 15000
},
target_id: '<string>',
record: true
})
};
fetch('https://api.example.com/sessions/{session_id}/page/execute/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sessions/{session_id}/page/execute/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => [
'file_path' => '<string>',
'type' => 'upload_file',
'category' => 'Interaction Actions',
'description' => 'Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.',
'id' => '',
'selector' => '<string>',
'press_enter' => true,
'text_label' => '<string>',
'param' => [
'name' => 'file_path',
'type' => 'str',
'values' => [
]
],
'timeout' => 15000
],
'target_id' => '<string>',
'record' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sessions/{session_id}/page/execute/file"
payload := strings.NewReader("{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sessions/{session_id}/page/execute/file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sessions/{session_id}/page/execute/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {\n \"file_path\": \"<string>\",\n \"type\": \"upload_file\",\n \"category\": \"Interaction Actions\",\n \"description\": \"Upload file to interactive element with file path. Use with any upload file element, including button, input, a, span, div. CRITICAL: Use only this for file upload, do not use click.\",\n \"id\": \"\",\n \"selector\": \"<string>\",\n \"press_enter\": true,\n \"text_label\": \"<string>\",\n \"param\": {\n \"name\": \"file_path\",\n \"type\": \"str\",\n \"values\": []\n },\n \"timeout\": 15000\n },\n \"target_id\": \"<string>\",\n \"record\": true\n}"
response = http.request(request)
puts response.read_body{
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"action": {
"value": {},
"type": "form_fill",
"category": "Special Browser Actions",
"description": "Fill a form with multiple values. Important: If you detect a form requesting personal information, try to use this action at first, and otherwise use the regular fill action. CRITICAL: If this action fails once, use the regular form fill instead."
},
"success": true,
"message": "<string>",
"data": {
"markdown": "<string>",
"images": [
{
"url": "<string>",
"category": "favicon",
"description": "<string>"
}
],
"structured": {
"success": true,
"error": "<string>",
"data": {}
}
},
"exception": "<string>",
"exception_detail": {
"error_type": "<string>",
"dev_message": "<string>",
"user_message": "<string>",
"agent_message": "<string>",
"should_retry_later": false,
"should_notify_team": false
},
"captcha": {
"captcha_id": "<string>",
"page_id": "<string>",
"generation": 123,
"state": "solving",
"retry_after_ms": 1000,
"message": "",
"cancel_reason": "navigation"
},
"action_executed": true,
"code": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}