---
title: "Replace text in project files"
method: POST
path: "/v1/integration/projects/{projectId}/files/replace"
tags: ["Unified Project Lifecycle APIs"]
---

# Replace text in project files

`POST /v1/integration/projects/{projectId}/files/replace`

## Request

- Base URL: `https://integration-adapter.connect.cloud.precisely.com`
- URL: `https://integration-adapter.connect.cloud.precisely.com/v1/integration/projects/{projectId}/files/replace`
- Auth: HTTP bearer

Replaces matching text in project files through the unified project API.

**Features:**
- Supports literal, whole-word, case-sensitive, and regular-expression matching.
- Returns one aggregate result contract for Advanced and Mainframe Replication.
- Delegates matching, preflight, replacement, and persistence to Connect Portal.

**Use Cases:**
- Rename a connection reference consistently across project files.
- Apply a bounded regular-expression replacement before validating a project.

**Authorization:** Requires `replication-pipeline::update` when permission harmonization is
enabled, or legacy `replication-pipeline::manage` otherwise.

## Path parameters

- `projectId` string, required

## Query parameters

- `projectType` 'REPLICATION' | 'MAINFRAME_REPLICATION' | 'ADVANCED_REPLICATION': Supported project types for unified project operations
- `pipelineId` string

## Request body

- ProjectFileReplaceRequest: Request payload for replacing matching text in project files
  - `searchTerm` string, required: Text or regular expression to replace
  - `matchCase` boolean: When true, matching is case-sensitive
  - `matchWord` boolean: When true, only whole-word matches are replaced
  - `regex` boolean: When true, searchTerm is treated as a regular expression
  - `filesToInclude` ProjectFileSearchSelectorRequest[]: Restricts replacement to files matching one of these selectors
    - `kind` 'EXACT' | 'GLOB' | 'REGEX': How the pattern is interpreted: EXACT | GLOB | REGEX
    - `pattern` string: The selector pattern
  - `view` 'CURRENT' | 'COMMITTED': File-tree view to replace in: CURRENT | COMMITTED
  - `revisionNumber` integer: Optional revision number
  - `maxMatchesPerFile` integer: Maximum matches allowed in one file
  - `maxTotalMatches` integer: Maximum matches allowed across all files
  - `maxFilesScanned` integer: Maximum number of files to scan
  - `maxBytesScanned` integer: Maximum number of bytes to scan
  - `deadlineSeconds` integer: Maximum operation duration in seconds
  - `includeLine` boolean: When true, include the updated line in each replacement match
  - `replacement` string, required: Replacement text; an empty string removes matched text
  - `maxChangedBytes` integer: Maximum number of changed output bytes

## Response `200`

Project file replacement completed

- ProjectFileReplaceResponse: Aggregate result of replacing text in project files
  - `projectId` string: Unique identifier of the project
  - `projectType` 'REPLICATION' | 'MAINFRAME_REPLICATION' | 'ADVANCED_REPLICATION': Resolved project type
  - `dataFlowId` string: Resolved portal dataflow identifier
  - `filesScanned` integer: Total number of files scanned; for Mainframe, derived from returned changed-file results
  - `filesMatched` integer: Number of files containing matches
  - `filesChanged` integer: Number of files changed
  - `matchCount` integer: Total number of matches; for Mainframe, every returned match was replaced
  - `replacementCount` integer: Total number of replacements written
  - `changedBytes` integer: Total UTF-8 bytes written for changed files; unavailable for Mainframe
  - `files` ProjectFileReplaceResultResponse[]: Per-file replacement outcomes in deterministic search order
    - `fileId` string: Unique identifier of the file
    - `fileName` string: File name derived from the flattened path
    - `flattenedPath` string: Path of the file within the project's flattened file tree; unavailable for Mainframe
    - `version` integer: Version assigned after replacement; unavailable for Mainframe
    - `replacementCount` integer: Number of replacements written to this file
    - `matches` ProjectFileSearchMatchResponse[]: Updated line text and replacement-adjusted columns
      - `line` integer: One-based line number of the match
      - `startColumn` integer: Zero-based start column of the match
      - `endColumn` integer: Zero-based end column of the match
      - `searchContentResult` string: Matched text or capture result

## Other responses

- `400`: Bad Request — invalid project type or replacement request
- `401`: Unauthorized
- `403`: Forbidden — requires replication-pipeline::update when permission harmonization is enabled, or legacy replication-pipeline::manage otherwise
- `404`: Not Found — project does not exist
- `409`: Conflict — a concurrent change or project state prevented replacement
- `422`: Unprocessable Entity — a file is unreadable or a preflight limit was exceeded
- `500`: Internal Server Error — replacement delegation or mapping failed

---

[API](https://skmtc.dev/precisely/apis/precisely-integration-adapter-service.md) · [All operations](https://skmtc.dev/precisely/apis/precisely-integration-adapter-service/llms.txt) · [OpenAPI document](https://skmtc.dev/precisely/apis/precisely-integration-adapter-service/revisions/2d2629f4987d?raw)
