Create Profile
Profiles allow you to preserve the state of the browser between tasks.
They are most commonly used to allow users to preserve the log-in state in the agent between tasks. You’d normally create one profile per user and then use it for all their tasks.
You can set a user_id when creating a profile to associate it with a user in your system.
This allows you to later search for the profile using the GET /profiles endpoint with a query parameter.
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', userId: '<string>'})
};
fetch('https://api.browser-use.com/api/v4/profiles', 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/v4/profiles \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"userId": "<string>"
}
'import requests
url = "https://api.browser-use.com/api/v4/profiles"
payload = {
"name": "<string>",
"userId": "<string>"
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"userId": "<string>",
"name": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"cookieDomains": [
"<string>"
]
}{
"detail": "Insufficient credits"
}{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}Body
Response
Successful Response
View model for representing a profile. A profile lets you preserve the login state between sessions.
We recommend that you create a separate profile for each user of your app. You can assign a user_id to each profile to easily identify which user the profile belongs to.
Was this page helpful?
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', userId: '<string>'})
};
fetch('https://api.browser-use.com/api/v4/profiles', 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/v4/profiles \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"userId": "<string>"
}
'import requests
url = "https://api.browser-use.com/api/v4/profiles"
payload = {
"name": "<string>",
"userId": "<string>"
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"userId": "<string>",
"name": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"cookieDomains": [
"<string>"
]
}{
"detail": "Insufficient credits"
}{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}