---
title: "Edit runtime sandbox file"
method: PATCH
path: "/context/runtime/content"
tags: ["Context - Runtime"]
---

# Edit runtime sandbox file

`PATCH /context/runtime/content`

Replace occurrences of `oldString` with `newString` in a file in the workspace runtime sandbox, then push the change to the workspace's default branch on GitHub. By default `oldString` must occur exactly once; pass `replaceAll: true` to replace every occurrence.

## Request body

- object — Edit a file in the workspace runtime sandbox via string replacement, then push the change to the default branch.
  - `path` string, required — Path of the file to edit, relative to the workspace working directory.
  - `oldString` string, required — The exact substring to replace. Must occur exactly once unless `replaceAll` is `true`.
  - `newString` string, required — Replacement string. May be empty to delete the match. Must differ from `oldString`.
  - `replaceAll` boolean — When `true`, replace every occurrence of `oldString` instead of requiring a single match.
  - `commitMessage` string — Optional commit message override. Defaults to 'context(runtime): edit <path>'.

## Response `200`

Successful response

- object
  - `commit` object, required
    - `sha` string, required
    - `message` string, required

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Not found
- `500` — Internal server error

---

[API](https://skmtc.net/getcargo/apis/cargo-api.md) · [All operations](https://skmtc.net/getcargo/apis/cargo-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getcargo/cargo-api/revisions/1d5a19e01d83/schema)
