# Breakpoint

> Pause matching requests or responses in Cloak Proxy, edit the method, URL, headers, body or status, then execute, cancel or abort them.

Source: https://docs.subcloak.com/cloak-proxy/tools/breakpoint/

A breakpoint stops a request on its way to the server, or a response on its way back to the app, and waits for you. While it's paused you can change anything: the method, URL, headers and body of a request, or the status code, headers and body of a response. Use it to try an edge case once, by hand, without writing a script or a mock.

## Set a breakpoint

1. Right-click a request in the traffic list and choose **Tools › Breakpoint…**.

   Cloak Proxy creates a rule that matches the request's method and URL (without the query string), turns Breakpoint on, and opens the rule. To start from scratch instead, choose **Tools › Edit Breakpoint Rules…** (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>B</kbd>) and click **+**.

2. Check the matcher. See [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/) for wildcards, regex and subpaths.

3. Under **Pause on**, choose what to stop:
   - **Request: edit the method, URL, headers or body before it's sent**
   - **Response: edit the status, headers or body before the app gets it**

4. Make the request again in your app. Cloak Proxy plays a sound, brings itself to the front and opens the **Breakpoint** window.

*[Screenshot: A Breakpoint rule for GET https://api.example.com/v1/users with both Pause on options checked. A Breakpoint rule created from a request. Both the request and the response pause.]*

### Rule settings

| Setting | Default | What it does |
|---|---|---|
| Name and matcher | | Which requests pause. See [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/). |
| **Request: edit the method, URL, headers or body before it's sent** | On | Pauses the request after request scripts run and before Map Local, Mock Sets, Map Remote and the server. |
| **Response: edit the status, headers or body before the app gets it** | On | Pauses the response after response scripts run and before the app receives it. |

Only the first matching breakpoint rule counts. If that rule pauses only responses, the request isn't paused even if a later rule would pause it.

## Break on the next request only

(added in Cloak Proxy 0.2.0)

**Break on Next Request** pauses the next request like one you already captured, once, and then removes its rule. Use it to catch a single request, such as the next login or the next save, without leaving a breakpoint behind that stops every later request.

1. Right-click a request in the traffic list and choose **Break on Next Request**. You can also select it and choose **Proxy › Break on Next Request**.

   Cloak Proxy adds a one-time rule and turns Breakpoint on. The Tools window doesn't open.

2. Make the request again in your app. The Breakpoint window opens with the request paused.

3. Edit it and click **Execute**, or use **Cancel** or **Abort**, as with any [paused request](#edit-a-paused-request).

| Detail | One-time rule |
|---|---|
| Name | **Next** followed by the method, host and path, for example `Next POST api.example.com/v1/login`. |
| Matches | The request's method and URL without its query string, with subpaths off. |
| Pauses | The request only. Its response isn't paused. |
| Where it goes | At the bottom of the Breakpoint rule list, where you can see it until it's used. |
| When it's removed | As soon as a request matches it, while that request is still paused. |
| Requests at the same time | Only one request takes the breakpoint. If the app sends several matching requests at once, the others carry on without pausing. |

The item isn't available for encrypted tunnels. Only the first matching breakpoint rule counts, so if an enabled rule above the one-time rule matches the same request, that rule decides and the one-time rule keeps waiting. A one-time rule that never matches stays in the list, even after a restart; delete it in the Tools window if you no longer need it.

From an AI assistant, the [MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/) tool `break_on_next` does the same for a captured request's `id`. Then use `list_paused` and `resolve_paused`, described [below](#resolve-breakpoints-from-an-ai-assistant).

## Edit a paused request

*[Screenshot: The Breakpoint window with two paused messages on the left and a paused GET request on the right showing its URL, four headers and an empty body. A paused request. Edit anything, then click Execute.]*

The editor shows **Request paused** with the request number and the rule name. Under **Request** you can change:

| Field | Notes |
|---|---|
| Method | **GET**, **POST**, **PUT**, **PATCH**, **DELETE**, **HEAD**, **OPTIONS**, **CONNECT** or **TRACE**. |
| URL | The full URL, including the query string. Change the host to send the request somewhere else. |
| **Headers** | Edit names and values in place, click **Add** for a new header, or click the minus button to remove one. |
| **Body** | The body editor, described below. |

### The body editor

(added in Cloak Proxy 0.2.3)

The body has its own editor, with **Code**, **Tree** and **Hex** at the top (**Table** instead of **Tree** for form bodies).

| Mode | What you can do |
|---|---|
| **Code** | Line numbers, syntax colors, folding, find (<kbd>⌘</kbd> <kbd>F</kbd>) and replace (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>F</kbd>), undo, auto-indent and bracket pairing. |
| **Tree** | Edit a value in place, change its type, rename a key, add, duplicate, move or delete a key or item, filter keys and values, copy a key, value or path, and find things with JSONPath or jq. |
| **Table** | Edit form fields as rows. |
| **Hex** | Read binary bodies; **Edit as Text** switches to Code. |

**Format** (<kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>F</kbd>) and **Minify** only change whitespace; **Sort keys** reorders keys; **Revert** goes back to the original. The status reads **Valid JSON** or, for example, **Invalid JSON at line 5, column 19**: click it, or **Go to Error** in Tree, to jump there. Code and Tree edits share one undo history and keep the body's layout, so a minified body stays minified. <kbd>⌘</kbd> <kbd>↩</kbd> sends from inside the editor, and <kbd>Esc</kbd> never throws your edits away. The same editor is used for Map Local, Mock Sets, Compose and the API client.

Compressed bodies (gzip, deflate, Brotli) are decompressed before you see them, and the `Content-Encoding` header is removed, so you always edit readable text.

(added in Cloak Proxy 0.4.0) gRPC, gRPC-Web, Connect and Protobuf bodies open as JSON and are encoded again on Execute. See [Edit Protobuf and gRPC](https://docs.subcloak.com/cloak-proxy/inspect/protobuf-and-grpc/#edit-messages). Cloak Proxy sends the body back in the charset its `Content-Type` names and recalculates `Content-Length` when you click **Execute**, so you don't need to update it.

## Edit a paused response

*[Screenshot: A paused 200 response to GET api.example.com/v1/users with four headers and a JSON body marked Valid JSON. A paused response. Pick a status from Quick Status to test error handling.]*

The editor shows **Response paused** and the request it answers (**Response to GET …**). You can change:

| Field | Notes |
|---|---|
| **Status code** | Any number. The standard reason phrase is shown next to it and sent with the response. |
| **Quick Status** | Sets the status to 200, 201, 204, 301, 304, 400, 401, 403, 404, 409, 422, 429, 500, 502 or 503. |
| **Headers** | Same editor as for requests. |
| **Body** | Same editor as for requests, decompressed. |

> **Streamed responses:**
> A response breakpoint holds a streamed response (SSE, JSON lines) until it ends, so the app gets all its events at once. Request breakpoints don't affect streaming. See [Streaming responses](https://docs.subcloak.com/cloak-proxy/inspect/streams/#streams-pass-through-as-they-arrive).

## Execute, Cancel or Abort

Each paused message waits until you decide what to do with it.

| Button | Shortcut | What happens |
|---|---|---|
| **Execute** | <kbd>⌘</kbd> <kbd>↩</kbd> | Sends the message on with your edits. |
| **Cancel** | <kbd>Esc</kbd> | Sends the original message on and throws away your edits. |
| **Abort** | | Drops the message. The app's connection is closed, as if the network failed. The request shows as failed with **Aborted at the request breakpoint** or **Aborted at the response breakpoint**. |
| **Continue All** | | At the bottom of the list. Sends every paused message on, unedited (the same as **Cancel** for each). |

> **Binary bodies:**
> If a body isn't text, such as an image, the editor shows it empty. Leave it empty and **Execute** sends the original bytes. Type something and it replaces them.

## Copy the paused request

(added in Cloak Proxy 0.5.2)

The **Copy** menu in the editor's header copies the paused message as it stands, with your edits, so you can replay it from Terminal, paste it into a ticket or save it in a script before you decide what to do with it. What it copies is what **Execute** would send: the method, URL, headers and body you see, with `Content-Length` updated for an edited body.

| Item | What it copies |
|---|---|
| **Copy URL** | The URL. |
| **Copy as cURL** | A `curl` command that sends the request. |
| **Copy as ›** | The request as code, in any format from [Copy as code](https://docs.subcloak.com/cloak-proxy/inspect/copy-as-code/#formats). |
| **Copy Request** | The request as raw HTTP: the request line, the headers and the body, decompressed. |
| **Copy Response** | The paused response as raw HTTP: the status line, the headers and the body, decompressed. Only when a response is paused. |

Copying doesn't send anything: the message stays paused until you click **Execute**, **Cancel** or **Abort**. Like Copy as code, it includes every header as it is, `Authorization` and cookies too.

In the Linux beta, the Copy menu comes with the next Linux release.

## The Breakpoint window

The window opens by itself when something pauses. You can also open it with **Tools › Breakpoint Window**, or by clicking **N paused at breakpoint** in the main window's bottom bar.

| Part | What it shows |
|---|---|
| Paused list | Every paused message: a **Request** or **Response** badge, the method, the time it paused, the URL and **Rule: …**. Select one to edit it. |
| Count | **N paused** at the bottom of the list. |
| Editor | The selected message. |
| Empty window | **Nothing paused**, with **Manage Breakpoint Rules…** to open the rules. |

Several requests can be paused at once, for example when an app loads a page. Each one waits on its own; deciding on one doesn't release the others.

> **Your app has its own timeout:**
> Cloak Proxy waits as long as you need, but the app that made the request doesn't. If you take too long, it may give up and show a network error. Use **Continue All** to release everything quickly, and turn Breakpoint off when you're done. Quitting Cloak Proxy sends every paused message on unedited.

## Breakpoints with other tools

- Request scripts run before the request pauses, so you see their changes. Response scripts run before the response pauses.
- Responses from [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/) and [Mock Sets](https://docs.subcloak.com/cloak-proxy/tools/mock-sets/) pause too, so you can tweak a mock before the app sees it.
- Editing the URL at the request breakpoint changes what Map Local, Mock Sets and Map Remote see. The response breakpoint still matches the original URL, so it pauses even if you changed the URL.
- Requests sent with [Repeat or Compose](https://docs.subcloak.com/cloak-proxy/tools/repeat-and-compose/) pause like live traffic.

See [What happens when several tools match](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/#what-happens-when-several-tools-match) for the full order.

## Resolve breakpoints from an AI assistant

The [MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/) has two tools for breakpoints: `list_paused` lists what's waiting, and `resolve_paused` sends a message on with edits (`send`), unedited (`send_original`), or drops it (`abort`). See the [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/).

## Related

  - [Scripting](https://docs.subcloak.com/cloak-proxy/tools/scripting/): Make the same edit automatically on every matching request.
  - [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/): Answer a request with a fixed response instead of pausing.
  - [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/): Wildcards, regex and the order tools run in.
  - [Debug a mobile app](https://docs.subcloak.com/cloak-proxy/guides/debug-a-mobile-app/): Use breakpoints on traffic from an iPhone or Android device.
