---
title: "TM Segment Batch Operations"
method: PATCH
path: "/tms/{tmId}/segments"
tags: ["Translation Memory"]
---

# TM Segment Batch Operations

`PATCH /tms/{tmId}/segments`

## Request

- Base URL: `https://api.crowdin.com/api/v2`
- URL: `https://api.crowdin.com/api/v2/tms/{tmId}/segments`
- Auth: none declared
- TypeScript: <https://skmtc.dev/crowdin/apis/crowdin-api-v2/docs/tms/:tmId/segments/patch.ts> (a function with typed inputs; its response is checked against the schema)

**Required scopes:** `tm` (Read and Write).

Perform batch operations on translation memory segments. Supports `add` (create new segment or append a record to an existing segment), `remove` (delete segment or delete a single record from a segment), and `replace` (update record text).

## Path parameters

- `tmId` integer, required

## Request body

- union[]
  - union
    - object: A JSON Patch `Add` operation as defined by [RFC 6902](https://tools.ietf.org/html/rfc6902#section-4.1)
      - `op` 'add': Patch operation to perform
      - `path` '/-', json-pointer: A JSON Pointer as defined by <a href="https://tools.ietf.org/html/rfc6901" target="_blank">RFC 6901</a>
      - `value` TmSegmentCreateForm, required
        - `records` object[], required
          - `languageId` string: Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany)
          - `text` string: Record text
    - object: A JSON Patch `Add` operation that appends a new record (translation in a previously absent language) to an existing TM segment
      - `op` 'add': Patch operation to perform
      - `path` '/{segmentId}/records/-', json-pointer: A JSON Pointer as defined by <a href="https://tools.ietf.org/html/rfc6901" target="_blank">RFC 6901</a>
      - `value` object, required
        - `languageId` string: Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany)
        - `text` string
    - object: A JSON Patch `Remove` operation as defined by [RFC 6902](https://tools.ietf.org/html/rfc6902#section-4.2)
      - `op` 'remove': Patch operation to perform
      - `path` '/{segmentId}', json-pointer: A JSON Pointer as defined by <a href="https://tools.ietf.org/html/rfc6901" target="_blank">RFC 6901</a>
    - object: A JSON Patch `Remove` operation that deletes a single record (translation in a specific language) from an existing TM segment
      - `op` 'remove': Patch operation to perform
      - `path` '/{segmentId}/records/{recordId}', json-pointer: A JSON Pointer as defined by <a href="https://tools.ietf.org/html/rfc6901" target="_blank">RFC 6901</a>
    - object: A JSON Patch `Replace` operation as defined by [RFC 6902](https://tools.ietf.org/html/rfc6902#section-4.3)
      - `op` 'replace': Patch operation to perform
      - `path` '/{segmentId}/records/{recordId}/text', json-pointer: A JSON Pointer as defined by <a href="https://tools.ietf.org/html/rfc6901" target="_blank">RFC 6901</a>
      - `value` string, required

## Response `200`

TM segments were successfully updated

- TmSegmentUpdatedCollectionResource: Base schema of resource container. Container is a wrapper object that contains payload in required `data` property and provides space for adding any other metadata.
  - `data` TmSegmentResource[], required
    - `data` TmSegment, required
      - `id` integer: Segment Identifier
      - `records` object[]
        - `id` integer: Record Identifier
        - `languageId` string: Language Identifier
        - `text` string: Record text
        - `usageCount` integer: Count usage of segment record
        - `createdBy` integer: Creator User Identifier
        - `updatedBy` integer: Redactor User Identifier
        - `createdAt` string, date-time, nullable: Date in UTC, ISO 8601
        - `updatedAt` string, date-time, nullable: Date in UTC, ISO 8601

## Other responses

- `400`: Invalid Request Parameters
- `401`: Unauthorized
- `403`: Forbidden
- `404`: TM with specified id was not found
- `405`: Method Not Allowed

---

[API](https://skmtc.dev/crowdin/apis/crowdin-api-v2.md) - [All operations](https://skmtc.dev/crowdin/apis/crowdin-api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/crowdin/apis/crowdin-api-v2/revisions/27aae7751699?raw)
