> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcargo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit runtime sandbox file

> 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.



## OpenAPI

````yaml https://api.getcargo.io/openapi.json patch /context/runtime/content
openapi: 3.1.0
info:
  title: Cargo API
  version: 1.0.0
  description: Cargo Platform API v1
servers:
  - url: https://api.getcargo.io/v1
    description: Cargo API
security:
  - bearerAuth: []
paths:
  /context/runtime/content:
    patch:
      tags:
        - Context - Runtime
      summary: Edit runtime sandbox file
      description: >-
        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.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                path:
                  type: string
                  minLength: 1
                  title: Path
                  description: >-
                    Path of the file to edit, relative to the workspace working
                    directory.
                oldString:
                  type: string
                  minLength: 1
                  title: Old string
                  description: >-
                    The exact substring to replace. Must occur exactly once
                    unless `replaceAll` is `true`.
                newString:
                  type: string
                  title: New string
                  description: >-
                    Replacement string. May be empty to delete the match. Must
                    differ from `oldString`.
                replaceAll:
                  title: Replace all
                  description: >-
                    When `true`, replace every occurrence of `oldString` instead
                    of requiring a single match.
                  type: boolean
                commitMessage:
                  title: Commit message
                  description: >-
                    Optional commit message override. Defaults to
                    'context(runtime): edit <path>'.
                  type: string
                  minLength: 1
              required:
                - path
                - oldString
                - newString
              additionalProperties: false
              title: Request body
              description: >-
                Edit a file in the workspace runtime sandbox via string
                replacement, then push the change to the default branch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  commit:
                    type: object
                    properties:
                      sha:
                        type: string
                        title: SHA
                      message:
                        type: string
                        title: Message
                    required:
                      - sha
                      - message
                    additionalProperties: false
                    title: Commit
                required:
                  - commit
                additionalProperties: false
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````