---
title: "Update a mock rule"
method: PUT
path: "/v1/browser/mocks/{id}"
tags: ["Browser"]
---

# Update a mock rule

`PUT /v1/browser/mocks/{id}`

## Request

- Base URL: `http://localhost:9998`
- URL: `http://localhost:9998/v1/browser/mocks/{id}`
- Auth: HTTP bearer

## Path parameters

- `id` string, required

## Request body

- MockRuleRequest
  - `urlPattern` string, required: URL pattern to match (glob or substring)
  - `method` string, nullable: HTTP method filter (e.g. "GET", "POST")
  - `requestStage` string: CDP Fetch stage (default: "Request")
  - `action` string, required: Action type: "respond", "fail", or "modify"
  - `status` integer: HTTP status code for respond action
  - `headers` object: Response headers for respond action
  - `body` string: Response body for respond action
  - `failReason` string: Failure reason for fail action (e.g. "Failed", "TimedOut")
  - `modifyUrl` string: New URL for modify action
  - `description` string
  - `enabled` boolean: Whether the rule is active (default: true)

## Response `200`

Updated mock rule

- MockRule
  - `id` string, required
  - `urlPattern` string, required
  - `method` string, nullable
  - `requestStage` string, required: CDP Fetch request stage (e.g. "Request", "Response")
  - `action` MockAction, required
    - `type` string, required: Action type: "respond", "fail", or "modify"
    - `status` integer, nullable
    - `headers` object, nullable
    - `body` string, nullable
    - `failReason` string, nullable
    - `modifyUrl` string, nullable
  - `description` string, nullable
  - `enabled` boolean, required

## Other responses

- `400`: Invalid request
- `404`: Resource not found
- `503`: Browser service not initialized

---

[API](https://skmtc.dev/modelpiper/apis/toolpiper-api.md) · [All operations](https://skmtc.dev/modelpiper/apis/toolpiper-api/llms.txt) · [OpenAPI document](https://skmtc.dev/modelpiper/apis/toolpiper-api/revisions/6722bf56385c?raw)
