Skip to main content
DELETE
/
browser
/
sessions
/
{id}
/
pages
/
{pageId}
Close Tab
curl --request DELETE \
  --url https://api.example.com/browser/sessions/{id}/pages/{pageId}
{
  "success": true,
  "pageId": "<string>"
}

Overview

The DELETE /browser/sessions/{id}/pages/{pageId} endpoint closes a single tab in the session. The tab is identified by its CDP target identifier, which you can obtain from POST /browser/sessions/{id}/pages or GET /browser/sessions/{id}/pages. Closing the currently active tab promotes another tab to active. You cannot close the last remaining tab in a session — doing so returns 409 Conflict.

Path Parameters

id
string
required
Browser session ID (UUID). Create via POST /browser/sessions.
pageId
string
required
CDP target identifier of the tab to close. 32-character uppercase hex. Obtain via POST /pages or GET /pages.

Body

No request body. Send an empty request.

Example Request

curl -X DELETE "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages/EA5E9AA71C7A91C467F8CDBB266EE5E0" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

Success Response (200)

success
boolean
true when the tab was closed.
pageId
string
CDP target identifier of the closed tab (echoed back for correlation).
Example Response:
{
  "success": true,
  "pageId": "EA5E9AA71C7A91C467F8CDBB266EE5E0"
}

Error Responses

StatusDescription
401Unauthorized — invalid or missing API key.
404Session not found, not owned by the caller, or no tab with the given pageId exists in the session.
408Navigation timeout while processing the close (rare — occurs when beforeunload handlers block).
409Cannot close the last remaining tab in the session. Close the session instead.
503The browser session is temporarily unreachable.

Notes

  • If the closed tab was active, another tab is promoted to active. Call GET /browser/sessions/{id}/pages to inspect the new active tab.
  • To end a session entirely, call DELETE /browser/sessions/{id} rather than closing the last tab.