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

# Patch agent instructions

> Replaces one exact string in the main agent's routing instructions with another, matching literally on whitespace, punctuation and case. Quote `oldString` from a read or search result; with `replaceAll` off, more than one match is an error rather than a guess.



## OpenAPI

````yaml /specs-prettified/realtime/openapi.stable.json patch /v1/stable/agent/instructions
openapi: 3.0.0
info:
  title: Realtime
  description: Realtime gateway API service
  version: 1.0.0
  contact: {}
servers:
  - url: https://realtime-api.voiceflow.com
security: []
tags: []
paths:
  /v1/stable/agent/instructions:
    patch:
      tags:
        - Agent
      summary: Patch agent instructions
      description: Replaces one exact string in the main agent's routing instructions
        with another, matching literally on whitespace, punctuation and case.
        Quote `oldString` from a read or search result; with `replaceAll` off,
        more than one match is an error rather than a guess.
      operationId: StableAgentController_patchInstructions
      parameters:
        - name: projectID
          required: true
          in: query
          schema:
            type: string
            description: The ID of the project to operate on.
        - name: environmentAlias
          required: true
          in: query
          schema:
            type: string
            description: The alias of the environment to operate on (e.g. `main`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StableInstructionsPatchRequest"
      responses:
        "200":
          description: Returns how many occurrences were replaced in the main agent's
            instructions, a unified diff of the changed lines, the document's
            line count after the write, and any references or mentions the new
            text left unresolved.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StableInstructionsPatchResponse"
          x-vf-doc:
            description: Returns how many occurrences were replaced in the main agent's
              instructions, a unified diff of the changed lines, the document's
              line count after the write, and any references or mentions the new
              text left unresolved.
      security:
        - token: []
components:
  schemas:
    StableInstructionsPatchRequest:
      type: object
      properties:
        oldString:
          type: string
          minLength: 1
          description: The exact text to replace, copied verbatim from a read or search
            result. Matching is literal — whitespace, punctuation and case must
            match. Do not include the line numbers a read adds.
        newString:
          type: string
          description: The text to put in its place. May be empty to delete.
        replaceAll:
          default: false
          description: Replace every occurrence. When false, more than one match is an
            error rather than a guess.
          type: boolean
      required:
        - oldString
        - newString
      additionalProperties: false
    StableInstructionsPatchResponse:
      type: object
      properties:
        message:
          type: string
          description: A human-readable summary naming the lines that changed.
        replacements:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
          description: How many occurrences were replaced.
        diff:
          type: string
          description: A unified diff of the changed lines, with 1-based hunk headers.
        totalLines:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
          description: How many lines the document has AFTER the write.
        unresolvedReferences:
          type: array
          items:
            type: string
          description: Braced {name} tokens anywhere in the document AFTER the patch that
            matched no variable or entity and were stored as literal text. The
            whole document is resolved, so a token the patch did not touch is
            reported too.
        unresolvedMentions:
          type: array
          items:
            type: string
          description: Backticked names anywhere in the document AFTER the patch that
            matched no attached tool, playbook or workflow. The whole document
            is resolved, so a name the patch did not touch is reported too.
      required:
        - message
        - replacements
        - diff
        - totalLines
        - unresolvedReferences
        - unresolvedMentions
  securitySchemes:
    token:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Voiceflow bearer token
````
