Browser lifecycle
Open, attach to, inspect, take over and close profile browsers through the Quin Local API, including session states and Quin Cloud saves.
Trang này chưa có bản tiếng Việt. Nội dung tiếng Anh được hiển thị bên dưới.
A session is Quin's handle on one profile's running browser. The Local API, RPA Plus and the app share one session manager, so a profile is never opened twice: opening a profile whose browser is already open (by you, a task or another script) attaches to it. Every launch goes through Quin's normal path — mode checks, proxy check, pinned runtime, Network Guard and, for Quin Cloud profiles, the lease, download and save on close.
Open a browser
POST /api/v1/browsers/open — scope browser:open.
| Field | Type | Default | Notes |
|---|---|---|---|
profile_id | string | required | Local id or Quin Cloud id (a Cloud profile not on this computer is downloaded first) |
start_url | string | – | http:/https: or about:blank only |
window | {width, height} | – | Viewport in pixels, 200–7680 × 200–4320 (400 invalid_window otherwise) |
wait | bool | true | true: answer when the browser is ready. false: answer 202 with a job at once |
timeout_s | int 5–3600 | 600 | How long to wait for the browser to be ready |
curl -s -X POST http://127.0.0.1:50380/api/v1/browsers/open \
-H "Authorization: Bearer $QUIN_API_TOKEN" -H "Content-Type: application/json" \
-H "Idempotency-Key: open-AbCd1234-20261102" \
--data '{"profile_id": "AbCd1234", "start_url": "https://example.com", "timeout_s": 300}'Response 200 (session object):
{
"session_id": "s_3f9c1d2e8a7b6c5d",
"profile_id": "AbCd1234",
"local_profile_id": "AbCd1234",
"cloud_profile_id": null,
"kind": "local",
"state": "RUNNING",
"opened_by": "api",
"created_at": "2026-11-02T09:12:44",
"runtime_id": "…",
"controlled_by": null,
"automation": {"bridge": "engine", "external_protocols": [],
"actions_endpoint": "/api/v1/browsers/s_3f9c1d2e8a7b6c5d/actions"},
"tabs": 1
}For a Quin Cloud profile profile_id is the Cloud id and local_profile_id the copy on this computer.
With "wait": false the answer is 202 {"job_id": "job_…", "state": "QUEUED"}; follow the job (its
result is the session object) — see Jobs.
Send an Idempotency-Key so that a retried open returns the first answer instead of starting again.
When opening fails
| HTTP | Code | Meaning |
|---|---|---|
| 409 | writer_busy, proxy_unreachable, … | Quin's specific reason (for example the Cloud profile is open on another computer) |
| 409 | launch_failed | The browser did not start; details.state and details.cause say more |
| 409 | cloud_unavailable | Quin Cloud is not available for a Cloud profile |
| 504 | launch_timeout | Not ready within timeout_s |
| 400 | invalid_profile_id, invalid_window | Bad input |
Session states
| State | Meaning |
|---|---|
PREPARING | Accepted, being prepared (Cloud: profile download) |
DOWNLOADING_RUNTIME, VERIFYING_RUNTIME | Getting the pinned browser runtime |
VALIDATING_PROXY | Checking the proxy before launch |
ACQUIRING_LEASE | Quin Cloud lease for a Cloud profile |
STARTING | Browser process starting |
RUNNING | Ready; actions accepted |
AUTOMATING | Ready, and an action or RPA run currently holds control |
STOPPING | Closing |
SYNCING | Cloud profile being saved |
CLOSED | Local profile closed |
SYNCED | Cloud profile closed and its revision committed by Quin Cloud |
RECOVERY_REQUIRED | Cloud profile needs recovery (for example the lease was lost) |
FAILED | Launch or save failed; see error |
CLOSED, SYNCED, RECOVERY_REQUIRED and FAILED are final. States are derived from Quin's own
components on every read: RUNNING only when the browser answered, SYNCED only after Quin Cloud
committed the revision.
List and inspect
| Method & path | Scope | Answer |
|---|---|---|
GET /browsers | browser:open | {"items": [session, …]} — open sessions, including browsers you opened from the Profiles page |
GET /browsers/{sid} | browser:open | One session; an unknown or long-gone id → 404 session_not_found |
GET /browsers/{sid}/tabs | browser:control | {"items": [{"tab": "t1", "url", "title", "active"}]} |
Control and takeover
Each session has one control lock. An API action holds it while it runs; an RPA run holds it for the whole run. An action from another holder gets:
{"error": {"code": "session_busy", "message": "Another automation controls this browser.",
"details": {"controlled_by": "rpa"}}}POST /browsers/{sid}/takeover (scope browser:control) cancels the current holder's in-flight
action or run and frees the lock:
{"session_id": "s_3f9c1d2e8a7b6c5d", "previous_holder": "rpa"}A cancelled RPA run is recorded as cancelled (taken over); a cancelled API action answers
409 taken_over. Your own clicks in the browser are never blocked — it is your browser — but they can
make the next action fail.
Close
POST /browsers/{sid}/close — scope browser:close. The body is optional.
| Field | Default | Notes |
|---|---|---|
sync | true | For a Cloud profile, wait until the save is SYNCED |
wait | true | false: answer 202 with a job at once |
timeout_s | 900 (5–3600) | A Cloud save can be large |
Closing first cancels whoever holds control. The answer is the session with its final state:
CLOSED for a local profile; SYNCED (or FAILED / RECOVERY_REQUIRED) for a Cloud profile with
sync: true. With sync: false the call returns without waiting for the Cloud save; Quin still saves
the profile. Not finished in time → 504 close_timeout.
POST /browsers/close-all — scope browser:close, body {"include_user": false, "sync": true} —
closes sessions opened by the API or RPA; browsers you opened yourself are closed only with
"include_user": true. It answers {"items": [...]} with one result per session.
Close policy for RPA tasks
Tasks started with POST /tasks take a close_policy:
close_if_opened_by_task(default) — close and save the browsers the task opened;close_and_sync— close and save; for tasks started through the Local API it closes the same browsers as the default;keep_open— leave browsers open.
A task started through the Local API never closes a browser you opened yourself. When the policy
closes a browser, the run shows SAVING until the profile is saved, and a Quin Cloud profile that could
not be saved turns a successful run into FAILED with profile_not_saved.
With the SDKs
with client.browsers.open(profile_id="AbCd1234", start_url="https://example.com") as session:
print(session.state, session.title())
# leaving the block closes the browser; a Cloud profile returns only once SYNCEDawait client.browsers.withSession({ profileId: "AbCd1234" }, async (b) => {
console.log(await b.title());
}); // always closes with syncA client that is killed while holding a browser leaves the browser open; closing is always explicit.