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

# Patch change

> Patch an existing change by updating metadata and/or applying file operations, then snapshot the result into a new change-owned commit. File content must be base64-encoded. When the change is conflicted, `files` writes are refused; submit a `resolutions` array instead to incrementally resolve conflicts — when every contested path is resolved the change becomes clean. `files` and `resolutions` are mutually exclusive on a single PATCH. A PATCH on a conflicted change without `resolutions` returns 409 MERGE_CONFLICT with a `details.conflict_paths` array listing the still-conflicted paths.

<Note>**Required scope:** `write`</Note>


## OpenAPI

````yaml /openapi.json patch /{org}/{repo}/changes/{change_id}
openapi: 3.1.0
info:
  title: Depot API
  description: Depot HTTP API v1
  version: 1.0.0
servers:
  - url: https://api.mesa.dev/v1
security:
  - apiKey: []
paths:
  /{org}/{repo}/changes/{change_id}:
    patch:
      tags:
        - Change
      summary: Patch change
      description: >-
        Patch an existing change by updating metadata and/or applying file
        operations, then snapshot the result into a new change-owned commit.
        File content must be base64-encoded. When the change is conflicted,
        `files` writes are refused; submit a `resolutions` array instead to
        incrementally resolve conflicts — when every contested path is resolved
        the change becomes clean. `files` and `resolutions` are mutually
        exclusive on a single PATCH. A PATCH on a conflicted change without
        `resolutions` returns 409 MERGE_CONFLICT with a `details.conflict_paths`
        array listing the still-conflicted paths.
      operationId: updateChange
      parameters:
        - in: path
          name: org
          schema:
            type: string
            minLength: 1
          required: true
          description: Organization slug
        - in: path
          name: repo
          schema:
            type: string
            minLength: 1
          required: true
          description: Repository name
        - in: path
          name: change_id
          schema:
            type: string
            pattern: ^[zyxwvutsrqponmlk]{32}$
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  description: >-
                    Replacement change description. Omit to preserve the
                    existing description; pass an empty string to clear it.
                  type: string
                author:
                  type: object
                  properties:
                    name:
                      type: string
                      minLength: 1
                    email:
                      type: string
                      format: email
                    date:
                      type: string
                      format: date-time
                  required:
                    - name
                    - email
                committer:
                  type: object
                  properties:
                    name:
                      type: string
                      minLength: 1
                    email:
                      type: string
                      format: email
                    date:
                      type: string
                      format: date-time
                  required:
                    - name
                    - email
                files:
                  minItems: 1
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          path:
                            type: string
                            minLength: 1
                          content:
                            type: string
                          encoding:
                            default: base64
                            type: string
                            const: base64
                          action:
                            type: string
                            const: upsert
                          mode:
                            type: string
                            enum:
                              - '100644'
                              - '100755'
                        required:
                          - path
                          - content
                      - type: object
                        properties:
                          path:
                            type: string
                            minLength: 1
                          action:
                            type: string
                            const: delete
                        required:
                          - path
                          - action
                base_commit_oid:
                  type: string
                  pattern: ^[0-9a-f]{40}$
                resolutions:
                  description: >-
                    Conflict resolutions to apply to a conflicted change. When
                    present, the change advances to a new commit: fully resolved
                    paths collapse into the target-term tree and the change
                    becomes clean when no conflicts remain. `files` and
                    `resolutions` are mutually exclusive — a conflicted change
                    must be resolved via `resolutions` before regular file
                    writes land.
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          path:
                            type: string
                            minLength: 1
                            description: Repository-relative path of the file to resolve.
                          content:
                            description: >-
                              Base64-encoded replacement bytes. Mutually
                              exclusive with `take`. Use this for hand-edited
                              content, or when the resolution is neither side of
                              the conflict verbatim.
                            type: string
                          take:
                            description: >-
                              Pick one side of the conflict as the resolution
                              without round-tripping its bytes through the
                              client. The server reads the selected side
                              directly. Mutually exclusive with `content`. If
                              the selected side has no content at this path (an
                              add/delete conflict where that side deleted or
                              never added the file), the resolution deletes the
                              path from the merge output.
                            type: string
                            enum:
                              - target
                              - source
                          encoding:
                            default: base64
                            description: Only base64 is supported today.
                            type: string
                            const: base64
                        required:
                          - path
                      - type: object
                        properties:
                          path:
                            type: string
                            minLength: 1
                            description: >-
                              Repository-relative path of the file whose hunks
                              are being resolved.
                          hunks:
                            minItems: 1
                            type: array
                            items:
                              type: object
                              properties:
                                hunk_id:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    Must match a `hunk_id` from a prior
                                    MERGE_CONFLICT error response for the
                                    containing path.
                                content:
                                  description: >-
                                    Base64-encoded replacement bytes. Mutually
                                    exclusive with `take`.
                                  type: string
                                take:
                                  description: >-
                                    Pick one side (`target` or `source`) as this
                                    hunk's resolution. The server uses the
                                    already-materialized side bytes for this
                                    specific conflict span. Mutually exclusive
                                    with `content`.
                                  type: string
                                  enum:
                                    - target
                                    - source
                                encoding:
                                  default: base64
                                  type: string
                                  const: base64
                              required:
                                - hunk_id
                            description: >-
                              Per-hunk replacements. The set must cover every
                              hunk returned for this path in the prior
                              MERGE_CONFLICT error, otherwise the merge
                              re-raises the conflict.
                        required:
                          - path
                          - hunks
                    description: >-
                      A single caller-supplied resolution. Whole-file variants
                      carry `content` OR `take` (not both); per-hunk variants
                      carry `hunks`. Whole-file replaces the merged content at
                      `path`. Per-hunk requires all hunks for the path to be
                      resolved.
      responses:
        '200':
          description: Change updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    pattern: ^[zyxwvutsrqponmlk]{32}$
                  current_commit_oid:
                    type: string
                    pattern: ^[0-9a-f]{40}$
                  is_conflicted:
                    type: boolean
                    description: >-
                      True when the change current commit still contains
                      unresolved conflicts
                  message:
                    type: string
                    description: >-
                      Current change description. Empty string means the change
                      has no description.
                  author:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                      email:
                        type: string
                        format: email
                      date:
                        type: string
                        format: date-time
                    required:
                      - name
                      - email
                  committer:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                      email:
                        type: string
                        format: email
                      date:
                        type: string
                        format: date-time
                    required:
                      - name
                      - email
                  parents:
                    type: array
                    items:
                      type: string
                    description: Parent change IDs for this change
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
                required:
                  - id
                  - current_commit_oid
                  - is_conflicted
                  - message
                  - author
                  - committer
                  - parents
                  - created_at
                  - updated_at
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '406':
          description: Not acceptable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key

````