Agent Session Upload File Presigned Url
Generate a secure presigned URL for uploading files to an agent session.
POST
/
files
/
sessions
/
{session_id}
/
presigned-url
Agent Session Upload File Presigned Url
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: '<string>', sizeBytes: 5242880})
};
fetch('https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"fileName": "<string>",
"sizeBytes": 5242880
}
'import requests
url = "https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url"
payload = {
"fileName": "<string>",
"sizeBytes": 5242880
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"url": "<string>",
"method": "POST",
"fields": {},
"fileName": "<string>",
"expiresIn": 123
}{
"detail": "Unsupported content type"
}{
"detail": "Session not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "An internal server error occurred"
}Authorizations
Path Parameters
Body
application/json
Request model for uploading a file to the user's files bucket.
The name of the file to upload
Required string length:
1 - 255The content type of the file to upload
Available options:
image/jpg, image/jpeg, image/png, image/gif, image/webp, image/svg+xml, application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/plain, text/csv, text/markdown Required range:
1 <= x <= 10485760Response
Successful Response
Response model for a presigned upload URL.
The URL to upload the file to.
The HTTP method to use for the upload.
Allowed value:
"POST"The form fields to include in the upload request.
Show child attributes
Show child attributes
The name of the file to upload (should be referenced when user wants to use the file in a task).
The number of seconds until the presigned URL expires.
Was this page helpful?
⌘I
Agent Session Upload File Presigned Url
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: '<string>', sizeBytes: 5242880})
};
fetch('https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"fileName": "<string>",
"sizeBytes": 5242880
}
'import requests
url = "https://api.browser-use.com/api/v2/files/sessions/{session_id}/presigned-url"
payload = {
"fileName": "<string>",
"sizeBytes": 5242880
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"url": "<string>",
"method": "POST",
"fields": {},
"fileName": "<string>",
"expiresIn": 123
}{
"detail": "Unsupported content type"
}{
"detail": "Session not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "An internal server error occurred"
}