Create Session
Create a new session with a new task.
POST
/
sessions
Create Session
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
proxyCountryCode: 'us',
persistMemory: true,
keepAlive: true,
enableRecording: false
})
};
fetch('https://api.browser-use.com/api/v2/sessions', 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/sessions \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"proxyCountryCode": "us",
"persistMemory": true,
"keepAlive": true,
"enableRecording": false
}
'import requests
url = "https://api.browser-use.com/api/v2/sessions"
payload = {
"proxyCountryCode": "us",
"persistMemory": True,
"keepAlive": True,
"enableRecording": False
}
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",
"status": "active",
"startedAt": "2023-11-07T05:31:56Z",
"persistMemory": true,
"keepAlive": true,
"liveUrl": "<string>",
"recordingUrl": "<string>",
"finishedAt": "2023-11-07T05:31:56Z",
"proxyUsedMb": "0",
"proxyCost": "0"
}{
"detail": "Profile not found"
}{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}{
"detail": "Too many concurrent active sessions. Please wait for one to finish, kill one, or upgrade your plan."
}Body
application/json
Request model for creating a session.
Country code for proxy location. Defaults to US. Set to null to disable proxy.
Available options:
ad, ae, af, ag, ai, al, am, an, ao, aq, ar, as, at, au, aw, az, ba, bb, bd, be, bf, bg, bh, bi, bj, bl, bm, bn, bo, bq, br, bs, bt, bv, bw, by, bz, ca, cc, cd, cf, cg, ch, ci, ck, cl, cm, co, cr, cs, cu, cv, cw, cx, cy, cz, de, dj, dk, dm, do, dz, ec, ee, eg, eh, er, es, et, fi, fj, fk, fm, fo, fr, ga, gd, ge, gf, gg, gh, gi, gl, gm, gn, gp, gq, gr, gs, gt, gu, gw, gy, hk, hm, hn, hr, ht, hu, id, ie, il, im, in, iq, ir, is, it, je, jm, jo, jp, ke, kg, kh, ki, km, kn, kp, kr, kw, ky, kz, la, lb, lc, li, lk, lr, ls, lt, lu, lv, ly, ma, mc, md, me, mf, mg, mh, mk, ml, mm, mn, mo, mp, mq, mr, ms, mt, mu, mv, mw, mx, my, mz, na, nc, ne, nf, ng, ni, nl, no, np, nr, nu, nz, om, pa, pe, pf, pg, ph, pk, pl, pm, pn, pr, ps, pt, pw, py, qa, re, ro, rs, ru, rw, sa, sb, sc, sd, se, sg, sh, si, sj, sk, sl, sm, sn, so, sr, ss, st, sv, sx, sy, sz, tc, td, tf, tg, th, tj, tk, tl, tm, tn, to, tr, tt, tv, tw, tz, ua, ug, uk, us, uy, uz, va, vc, ve, vg, vi, vn, vu, wf, ws, xk, ye, yt, za, zm, zw Response
Successful Response
View model for representing a (browser) session.
Was this page helpful?
⌘I
Create Session
const options = {
method: 'POST',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
proxyCountryCode: 'us',
persistMemory: true,
keepAlive: true,
enableRecording: false
})
};
fetch('https://api.browser-use.com/api/v2/sessions', 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/sessions \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"proxyCountryCode": "us",
"persistMemory": true,
"keepAlive": true,
"enableRecording": false
}
'import requests
url = "https://api.browser-use.com/api/v2/sessions"
payload = {
"proxyCountryCode": "us",
"persistMemory": True,
"keepAlive": True,
"enableRecording": False
}
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",
"status": "active",
"startedAt": "2023-11-07T05:31:56Z",
"persistMemory": true,
"keepAlive": true,
"liveUrl": "<string>",
"recordingUrl": "<string>",
"finishedAt": "2023-11-07T05:31:56Z",
"proxyUsedMb": "0",
"proxyCost": "0"
}{
"detail": "Profile not found"
}{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}{
"detail": "Too many concurrent active sessions. Please wait for one to finish, kill one, or upgrade your plan."
}