{
  "slug": "playwright-api-request-contexts-gain-cookie-management-ae377c96518e",
  "title": "Playwright API request contexts gain cookie management",
  "tools": [
    "playwright"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-10-07T20:40:43.000Z",
  "announced_at": "2026-10-07T20:40:43.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When API-level tests need request-context cookie control, use `addCookies()` to add cookies, `cookies()` to inspect them, and `clearCookies()` to remove them.",
    "examples": [
      "await request.addCookies([{ name: 'session-id', value: '42', url: 'https://example.com' }]);\nconsole.log(await request.cookies('https://example.com'));\nawait request.clearCookies({ name: 'session-id' });"
    ],
    "gotchas": [
      "Version: v1.64.0",
      "addCookies(cookies) — `cookies` (required): Array of cookie objects. Each needs `name` and `value`, plus either `url` or both `domain` and `path`.",
      "cookies(urls) — `urls`: URL or list of URLs; filters returned cookies to those affecting the specified URLs. Omit to return all cookies.",
      "clearCookies(options) — `options.name`: String or RegExp filter; only cookies with the given name are removed. The options object and its filters are optional.",
      "Prerequisite: The methods were added in Playwright v1.64. Use an `APIRequestContext`; `browserContext.request` and `page.request` share their BrowserContext cookie jar, while `apiRequest.newContext()` creates an isolated cookie store.",
      "The methods mirror the `BrowserContext` methods."
    ]
  },
  "why_it_matters": "Manage cookies for an API request context during API-level testing.",
  "sources": [
    "https://github.com/microsoft/playwright/releases/tag/v1.64.0",
    "https://playwright.dev/docs/api/class-apirequestcontext"
  ],
  "rank": 0.9804,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v1+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "gap-20261007",
    "verdict_id": "gap-20261007:gap-20261007-bdf5b973c35fe6e6-11:gate",
    "evidence_hash": "d55d809be2ea27eaa2466c245352f93486b5b4d563d8e70bca21767e52f93303"
  },
  "review": {
    "draft_hash": "3ac2905ed2a58c5d5781d1ee8306b700ea91046f6080ad7a9e904a7a6117bf21",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T20:40:43.000Z",
    "decision": "gap-20261007:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.98 >= 0.9; 2 needed) and Jev gave 0.76 (>= 0.6 needed)."
  }
}
