> ## 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.

# Merge bookmarks

> Merge the source bookmark into the target bookmark. The target bookmark is advanced to the merge result.

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


## OpenAPI

````yaml /openapi.json post /{org}/{repo}/bookmarks/merge
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}/bookmarks/merge:
    post:
      tags:
        - Bookmark
      summary: Merge bookmarks
      description: >-
        Merge the source bookmark into the target bookmark. The target bookmark
        is advanced to the merge result.
      operationId: mergeBookmark
      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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                target:
                  type: string
                  minLength: 1
                  description: >-
                    The bookmark being merged into. Usually main. This bookmark
                    is updated to the resulting merge point.
                source:
                  type: string
                  minLength: 1
                  description: The bookmark that has changes to merge into target.
                delete_source:
                  default: false
                  description: >-
                    Whether to delete the source bookmark after a successful
                    merge
                  type: boolean
                allow_conflicted:
                  default: false
                  description: >-
                    When true, a merge that produces textual conflicts is
                    accepted and the target bookmark is moved to a conflicted
                    merge commit. When false (default), the merge is rejected
                    server-side with MERGE_CONFLICT and nothing is persisted.
                  type: boolean
                message:
                  description: >-
                    Description for the resulting merge change. Omit to use the
                    generated merge description; empty string is allowed and
                    means no description.
                  type: string
                resolutions:
                  default: []
                  description: >-
                    Caller-supplied conflict resolutions, applied before
                    conflict detection. Each resolution targets one path —
                    either the full file (`content`) or a set of per-hunk
                    replacements (`hunks`). A resolution set that covers every
                    otherwise-conflicting path lets an initially-rejected merge
                    succeed on retry without setting `allow_conflicted`.
                  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.
              required:
                - target
                - source
      responses:
        '200':
          description: Merge result
          content:
            application/json:
              schema:
                type: object
                properties:
                  merge_type:
                    type: string
                    enum:
                      - merge_commit
                      - no_op
                    description: >-
                      The type of merge that was performed. `no_op` when target
                      and source point to the same commit; `merge_commit`
                      otherwise — every divergent merge creates an explicit
                      merge commit (JJ model).
                  is_conflicted:
                    type: boolean
                  commit_oid:
                    type: string
                    pattern: ^[0-9a-f]{40}$
                    description: The commit OID the target bookmark now points to
                  change_id:
                    type: string
                    pattern: ^[zyxwvutsrqponmlk]{32}$
                    description: >-
                      The JJ change ID the target bookmark points to after the
                      merge.
                  target:
                    type: string
                    description: The target bookmark that was merged into
                  source:
                    type: string
                    description: The source bookmark that was merged from
                  source_deleted:
                    type: boolean
                    description: Whether the source bookmark was deleted after merge
                required:
                  - merge_type
                  - is_conflicted
                  - commit_oid
                  - change_id
                  - target
                  - source
                  - source_deleted
        '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

````