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

# Correct segments of one language

> Corrects source text, translation and/or speaker of up to 500 segments of one target language at once, with the web editor's own save logic. Every entry is checked before anything is written: an unknown, deleted or duplicate segment id, a field the dub's engine does not allow or an unknown speaker returns 400 naming the segment, and nothing is written.

Engine v1 (per segment): a changed target_text or speaker is saved and voiced at the next POST /api/v1/dubs/{id}/update (pending_revoice becomes true); an empty target_text mutes the segment. A changed source_text sent alone is saved and the segment is re-translated and re-voiced in this language right away; sent together with a target_text, both are saved and the given translation is kept. also_retranslate_languages re-translates and re-voices every segment with a changed source_text into those languages too.

Engine v2 (batch): speaker and also_retranslate_languages are not available (400); edits are saved and marked as pending changes, and nothing is re-translated or voiced until POST /api/v1/dubs/{id}/update, whose "Apply changes" itself carries corrected source texts over to every language of the dub.

Each entry is reported as "updated", "unchanged" (all values already as stored: nothing written, nothing counted) or "failed" (with error, not counted); "updated" with an error means the text was saved but the re-translation failed.

While a review is in progress, an update or a lip sync is running for this language (or one in also_retranslate_languages), or a changed segment is being re-translated or re-voiced, the request returns 409 and changes nothing.

Every segment that actually changes costs one of its 2 API edits. See [Edit limits](/guides/edit-limits). No credits are charged.



## OpenAPI

````yaml /openapi.json patch /api/v1/dubs/{id}/segments
openapi: 3.1.0
info:
  title: Dubly API
  version: 1.0.0
  description: >-
    The Dubly public API creates, edits and downloads AI-dubbed videos. Every
    request authenticates with an API token as a Bearer token
    ([Authentication](/authentication)). Every answer is JSON in an envelope: `{
    "status": "success", "response": … }` on success, `{ "status": "error",
    "message": … }` on failure — see [Errors](/guides/errors).
servers:
  - url: https://app.dubly.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Create dubs
    description: >-
      Start a dub from a YouTube video, a Google Drive file or a public video
      URL.
  - name: Dubs
    description: >-
      Read a dub's status and results, rename, move or delete it, list its
      downloads and set the original-voice volume.
  - name: Dub editing
    description: >-
      Read and correct segments, edit the timeline, re-voice a segment and apply
      the changes with an update. See [Edit limits](/guides/edit-limits).
  - name: Lip sync
    description: >-
      Start lip sync for a language, follow its progress and switch lip sync per
      block.
  - name: Subtitled video
    description: Burn subtitles into the video of a language and fetch the result.
  - name: Account
    description: List the projects and custom voices of your account.
paths:
  /api/v1/dubs/{id}/segments:
    patch:
      tags:
        - Dub editing
      summary: Correct segments of one language
      description: >-
        Corrects source text, translation and/or speaker of up to 500 segments
        of one target language at once, with the web editor's own save logic.
        Every entry is checked before anything is written: an unknown, deleted
        or duplicate segment id, a field the dub's engine does not allow or an
        unknown speaker returns 400 naming the segment, and nothing is written.


        Engine v1 (per segment): a changed target_text or speaker is saved and
        voiced at the next POST /api/v1/dubs/{id}/update (pending_revoice
        becomes true); an empty target_text mutes the segment. A changed
        source_text sent alone is saved and the segment is re-translated and
        re-voiced in this language right away; sent together with a target_text,
        both are saved and the given translation is kept.
        also_retranslate_languages re-translates and re-voices every segment
        with a changed source_text into those languages too.


        Engine v2 (batch): speaker and also_retranslate_languages are not
        available (400); edits are saved and marked as pending changes, and
        nothing is re-translated or voiced until POST /api/v1/dubs/{id}/update,
        whose "Apply changes" itself carries corrected source texts over to
        every language of the dub.


        Each entry is reported as "updated", "unchanged" (all values already as
        stored: nothing written, nothing counted) or "failed" (with error, not
        counted); "updated" with an error means the text was saved but the
        re-translation failed.


        While a review is in progress, an update or a lip sync is running for
        this language (or one in also_retranslate_languages), or a changed
        segment is being re-translated or re-voiced, the request returns 409 and
        changes nothing.


        Every segment that actually changes costs one of its 2 API edits. See
        [Edit limits](/guides/edit-limits). No credits are charged.
      operationId: patch-dub-segments
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            The dub ID (path parameter). The dub must have finished processing
            (status "Dubbed"); otherwise the request returns 400.
          schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                target_language:
                  type: string
                  enum:
                    - af
                    - ar
                    - hy
                    - as
                    - az
                    - be
                    - bn
                    - bs
                    - bg
                    - ca
                    - ceb
                    - ny
                    - zh
                    - hr
                    - cs
                    - da
                    - nl
                    - en
                    - et
                    - fil
                    - fi
                    - fr
                    - gl
                    - ka
                    - de
                    - el
                    - gu
                    - ha
                    - he
                    - hi
                    - hu
                    - is
                    - id
                    - ga
                    - it
                    - ja
                    - jv
                    - kn
                    - kk
                    - ko
                    - ky
                    - lv
                    - ln
                    - lt
                    - lb
                    - mk
                    - ms
                    - ml
                    - mr
                    - ne
                    - 'no'
                    - ps
                    - fa
                    - pl
                    - pt
                    - pa
                    - ro
                    - ru
                    - sr
                    - sd
                    - sk
                    - sl
                    - so
                    - es
                    - sw
                    - sv
                    - ta
                    - te
                    - th
                    - tr
                    - uk
                    - ur
                    - vi
                    - cy
                    - en-GB
                    - en-US
                    - es-419
                    - es-ES
                  description: >-
                    BCP 47 code of the language whose segments are corrected. A
                    language the dub does not have returns 404.
                segments:
                  minItems: 1
                  maxItems: 500
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                        description: >-
                          Segment id from GET /api/v1/dubs/{id}/segments. An
                          unknown or deleted id returns 400.
                      source_text:
                        type: string
                        description: >-
                          Corrected source text. v1: re-translated and re-voiced
                          in target_language right away, unless target_text is
                          sent too. v2: applied at the next update.
                      target_text:
                        type: string
                        description: >-
                          Corrected translation. v1: voiced at the next update;
                          an empty string mutes the segment. v2: applied at the
                          next update.
                      speaker:
                        type: string
                        minLength: 1
                        description: >-
                          Speaker id from speakers of GET
                          /api/v1/dubs/{id}/segments; voiced at the next update.
                          Engine v1 only (supportsVoiceSwap) — 400 on v2.
                    required:
                      - id
                    additionalProperties: false
                  description: >-
                    1–500 entries { id, source_text?, target_text?, speaker? };
                    each id at most once. Fields left out stay as they are.
                    Split larger corrections into several requests.
                also_retranslate_languages:
                  type: array
                  items:
                    type: string
                    enum:
                      - af
                      - ar
                      - hy
                      - as
                      - az
                      - be
                      - bn
                      - bs
                      - bg
                      - ca
                      - ceb
                      - ny
                      - zh
                      - hr
                      - cs
                      - da
                      - nl
                      - en
                      - et
                      - fil
                      - fi
                      - fr
                      - gl
                      - ka
                      - de
                      - el
                      - gu
                      - ha
                      - he
                      - hi
                      - hu
                      - is
                      - id
                      - ga
                      - it
                      - ja
                      - jv
                      - kn
                      - kk
                      - ko
                      - ky
                      - lv
                      - ln
                      - lt
                      - lb
                      - mk
                      - ms
                      - ml
                      - mr
                      - ne
                      - 'no'
                      - ps
                      - fa
                      - pl
                      - pt
                      - pa
                      - ro
                      - ru
                      - sr
                      - sd
                      - sk
                      - sl
                      - so
                      - es
                      - sw
                      - sv
                      - ta
                      - te
                      - th
                      - tr
                      - uk
                      - ur
                      - vi
                      - cy
                      - en-GB
                      - en-US
                      - es-419
                      - es-ES
                  description: >-
                    Engine v1: other languages of the dub into which every
                    segment whose source_text changed is re-translated and
                    re-voiced as well (the editor's "Apply to languages"). Must
                    not contain target_language; muted segments there stay
                    muted. A language the dub does not have returns 400. Each
                    segment re-translated there costs one of its API edits.
                    Engine v2: 400 — the update carries source corrections over
                    to every language by itself.
              required:
                - target_language
                - segments
              additionalProperties: false
            examples:
              v1:
                summary: 'Engine v1: correct a source line, a translation and a speaker'
                value:
                  target_language: de
                  segments:
                    - id: 5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54
                      source_text: Welcome to our product demo.
                    - id: c9e0d2f1-47ab-4c3e-8f21-6a5b4d3c2e10
                      target_text: Danke fürs Zuschauen!
                      speaker: '2'
                  also_retranslate_languages:
                    - fr
              v2:
                summary: 'Engine v2: correct texts, applied at the next update'
                value:
                  target_language: de
                  segments:
                    - id: 5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54
                      source_text: Welcome to our product demo.
                    - id: c9e0d2f1-47ab-4c3e-8f21-6a5b4d3c2e10
                      target_text: Danke fürs Zuschauen!
      responses:
        '200':
          description: What happened to each entry, in the order of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  response:
                    type: object
                    properties:
                      dub_id:
                        type: string
                      target_language:
                        type: string
                      segments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            result:
                              type: string
                              enum:
                                - updated
                                - unchanged
                                - failed
                              description: >-
                                "updated", "unchanged" (all values already as
                                stored: nothing written, nothing counted) or
                                "failed" (nothing saved, not counted).
                            api_edits_remaining:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                              description: >-
                                API edits left for this segment after this
                                request (at most 2).
                            error:
                              type: string
                              description: >-
                                On "failed": why nothing was saved. On
                                "updated": the text was saved, but the
                                re-translation failed or did not start.
                          required:
                            - id
                            - result
                            - api_edits_remaining
                      retranslated_languages:
                        type: array
                        items:
                          type: string
                        description: >-
                          v1: the languages of also_retranslate_languages the
                          changed source texts were re-translated into. Always
                          empty on v2.
                    required:
                      - dub_id
                      - target_language
                      - segments
                      - retranslated_languages
                required:
                  - status
                  - response
              examples:
                v1:
                  summary: 'Engine v1: one segment changed and re-translated into "fr"'
                  value:
                    status: success
                    response:
                      dub_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      target_language: de
                      segments:
                        - id: 5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54
                          result: updated
                          api_edits_remaining: 1
                        - id: c9e0d2f1-47ab-4c3e-8f21-6a5b4d3c2e10
                          result: unchanged
                          api_edits_remaining: 2
                      retranslated_languages:
                        - fr
                v2:
                  summary: 'Engine v2: both corrections saved as pending changes'
                  value:
                    status: success
                    response:
                      dub_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      target_language: de
                      segments:
                        - id: 5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54
                          result: updated
                          api_edits_remaining: 1
                        - id: c9e0d2f1-47ab-4c3e-8f21-6a5b4d3c2e10
                          result: updated
                          api_edits_remaining: 1
                      retranslated_languages: []
                partial:
                  summary: >-
                    Engine v1: a saved source text whose re-translation failed,
                    and a failed entry
                  value:
                    status: success
                    response:
                      dub_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      target_language: de
                      segments:
                        - id: 5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54
                          result: updated
                          api_edits_remaining: 1
                          error: >-
                            The source text was saved, but re-translating it
                            failed: Failed to sync the segment. Please try
                            again.
                        - id: c9e0d2f1-47ab-4c3e-8f21-6a5b4d3c2e10
                          result: failed
                          api_edits_remaining: 2
                          error: Unexpected error while saving this segment.
                      retranslated_languages: []
        '400':
          description: >-
            BAD_REQUEST — The dub ID is not a UUID, the body is invalid (an
            unknown field, no segments or more than 500, a segment id twice),
            the dub has not finished processing (status "Dubbed"), a segment id
            is unknown or deleted, a field is one the dub's engine does not
            allow (v2: speaker, also_retranslate_languages), a speaker is
            unknown, or also_retranslate_languages names target_language or a
            language the dub does not have. The message names the segment;
            nothing is written.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: UNAUTHORIZED — Missing or invalid API token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            FORBIDDEN — A segment that would change — in target_language or in
            also_retranslate_languages — has used all its 2 API edits. Nothing
            was changed, nothing was counted; these segments can still be edited
            in the Dubly web app. Example message: "API edit limit reached: a
            segment can be edited at most 2 times through the API. Exhausted:
            5b1e7c2a-9d43-4f8e-a6b0-2c7d9e1f3a54 ("de"). Nothing was changed —
            these segments can still be edited in the Dubly web app."
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            NOT_FOUND — An unknown dub, a dub of another account, or a
            target_language the dub does not have.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            CONFLICT — A review is in progress, an update or a lip sync is
            running for this language (or one in also_retranslate_languages), or
            a changed segment is being re-translated or re-voiced. Nothing was
            changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: >-
            INTERNAL_ERROR — The dub, its segments or its API usage could not be
            read, or the API edit limit could not be checked (nothing was
            changed), or every changed segment failed to save — no API edit was
            counted. A failed save can still have written part of a segment;
            check them with GET /api/v1/dubs/{id}/segments.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          const: error
        message:
          type: string
      required:
        - status
        - message
      description: >-
        The error envelope. The HTTP status carries the error code; `message`
        says what went wrong, in English.
      examples:
        - status: error
          message: Dub not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API token from Settings → API in the Dubly web app, sent as
        `Authorization: Bearer <token>`.

````

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