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

# Replace text in a report definition

Changes part of a report by exact-text replacement, so a small change (a column, a filter, one chart property) sends only that change instead of the whole report.

Read `GET /reports/{reportId}/file` first and copy each `oldText` from its `content`, including whitespace. Without `replaceAll`, `oldText` must occur exactly once. Edits apply in order; if any one fails, nothing is saved. A field removed from the file is cleared; fields outside the file cannot be added.

Returns the new `content` and `hash`. Pass `expectedHash` to get `409` instead of editing a report that changed since you read it. Requires **edit** access to the report.


## OpenAPI

````yaml /api-reference/api.yaml patch /api/v1/deployments/{deploymentId}/reports/{reportId}/file
openapi: 3.1.0
info:
  title: Cube Platform API
  version: 1.0.0
  description: >-
    Programmatically manage Cube: deployments and everything scoped to them

    (environments, folders, reports, workbooks, notifications, workspace, and
    agents),

    plus account-level users, groups, policies, embedding, and AI settings.
    Data-model

    authoring, dev mode, branches, and uploads live under /build/api/v1 — same
    host and

    token, routed to the build pods.
servers:
  - url: https://{tenant}.cubecloud.dev
    description: Your tenant host. Replace the whole host if you use a custom domain.
    variables:
      tenant:
        default: your-tenant
        description: Your Cube tenant subdomain
security:
  - bearerAuth: []
tags:
  - name: Deployments
  - name: Deployment Creation
  - name: Environments
  - name: Env Variables
  - name: Regions
  - name: Data Model
  - name: Data Model Uploads
  - name: GitHub
  - name: GitHub Connection
  - name: dbt Sync
  - name: Databricks Metric View Publication
  - name: Databricks Metric View Integration
  - name: Snowflake Semantic View Sync
  - name: Folders
  - name: Reports
  - name: External Documents
  - name: Workbooks
  - name: Workbook Promotions
  - name: Dashboard Exports
  - name: Notifications
  - name: Scheduled Tasks
  - name: Workspace
  - name: Agents
  - name: Users
  - name: Users Admin
  - name: API Keys
  - name: User Attributes
  - name: User Attribute Values
  - name: Tenant Settings
  - name: OAuth Integrations
  - name: User OAuth Tokens
  - name: OIDC Token Configs
  - name: App Theme
  - name: Embed
  - name: Embed Tenants
  - name: Dashboard Embed Access
  - name: Usage Analytics
  - name: OpenAPI Spec
paths:
  /api/v1/deployments/{deploymentId}/reports/{reportId}/file:
    patch:
      tags:
        - Reports
      summary: Replace text in a report definition
      operationId: replaceReportFileText
      parameters:
        - in: path
          name: deploymentId
          required: true
          schema:
            type: number
        - in: path
          name: reportId
          required: true
          schema:
            type: number
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplaceJsonConfigTextInput'
        description: ReplaceJsonConfigTextInput
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonConfigFileDto'
          description: ''
components:
  schemas:
    ReplaceJsonConfigTextInput:
      properties:
        edits:
          description: >-
            Replacements applied in order, each to the result of the previous
            one. Either all apply or nothing is saved.
          items:
            $ref: '#/components/schemas/TextReplacementInput'
          maxItems: 50
          minItems: 1
          type: array
        expectedHash:
          oneOf:
            - pattern: ^[a-f0-9]{64}$
              type: string
            - type: 'null'
          description: >-
            The `hash` from your last read. When set, the request fails with 409
            if the configuration changed since then.
      required:
        - edits
      type: object
    JsonConfigFileDto:
      properties:
        content:
          description: >-
            The configuration as canonical JSON text: keys sorted, 2-space
            indentation, trailing newline. `oldText` in a replacement must match
            this text exactly.
          type: string
        hash:
          description: >-
            SHA-256 of `content`. Send it back as `expectedHash` to reject the
            write if the configuration changed since you read it.
          type: string
      required:
        - content
        - hash
      type: object
    TextReplacementInput:
      properties:
        newText:
          description: Text to put in place of `oldText`.
          type: string
        oldText:
          description: >-
            Exact text to replace, copied from `content`, including whitespace.
            Must occur exactly once unless `replaceAll` is set.
          minLength: 1
          type: string
        replaceAll:
          oneOf:
            - type: boolean
            - type: 'null'
          description: Replace every occurrence of `oldText` instead of requiring one.
      required:
        - oldText
        - newText
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Token authentication. Send `Authorization: Bearer <YOUR_TOKEN>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.