Merge branch

http
POST /projects/{project_reference}/branches/{branch_id}/merge

Merge a branch into main or another branch, applying its file changes, deletions and the merge message to the target. Requires project.files.write.

Servers

JSON
[  {    "url": "https://api.veryfront.com"  }]

Authentication

JSON
[  {    "bearerAuth": []  },  {    "apiKeyAuth": []  }]
JSON
{  "bearerAuth": {    "type": "http",    "scheme": "bearer",    "bearerFormat": "JWT or API Key",    "description": "Use a JWT bearer token or a Veryfront API key in the `Authorization` header."  },  "apiKeyAuth": {    "type": "apiKey",    "in": "header",    "name": "X-API-Key",    "description": "Alternative API key header for `vf_<prefix>_<secret>` tokens."  }}

Parameters

NameLocationRequiredDescription
project_referencepathYesProject slug, UUID, or domain that identifies the project.
branch_idpathYes

Parameter contracts

JSON
[  {    "schema": {      "$ref": "#/components/schemas/ProjectReference"    },    "required": true,    "description": "Project slug, UUID, or domain that identifies the project.",    "name": "project_reference",    "in": "path"  },  {    "schema": {      "type": "string",      "format": "uuid",      "description": "Branch UUID belonging to the selected project. Missing or foreign branches return 404."    },    "required": true,    "name": "branch_id",    "in": "path"  }]

Request body

JSON
{  "content": {    "application/json": {      "schema": {        "type": "object",        "properties": {          "expected_version": {            "type": [              "integer",              "null"            ],            "minimum": 0,            "description": "Optional optimistic-concurrency precondition against the persisted source branch version. A stale value returns 412 before merge writes.",            "example": 3          },          "target_branch_id": {            "type": [              "string",              "null"            ],            "format": "uuid",            "description": "Target branch ID; omit for main. An unknown target returns not found. Merge eligibility and conflicts are checked again when the merge commits."          },          "merge_message": {            "type": "string",            "description": "Message stored on the merge audit record.",            "example": "Ship header"          }        }      },      "example": {        "expected_version": 4,        "merge_message": "Ship header"      }    }  }}

Responses

200

Branch merged successfully.

JSON
{  "description": "Branch merged successfully.",  "content": {    "application/json": {      "schema": {        "type": "object",        "properties": {          "success": {            "type": "boolean"          },          "branch": {            "type": "object",            "properties": {              "id": {                "type": "string",                "format": "uuid"              },              "name": {                "type": "string"              },              "project_id": {                "type": "string",                "format": "uuid"              },              "base_branch_id": {                "type": [                  "string",                  "null"                ],                "format": "uuid"              },              "created_at": {                "type": [                  "string",                  "null"                ],                "description": "Persisted branch creation time.",                "example": "2026-09-14T10:00:00.000Z"              },              "created_by": {                "type": [                  "string",                  "null"                ],                "format": "uuid"              },              "merged_at": {                "type": [                  "string",                  "null"                ],                "description": "Persisted merge time; null before a merge."              },              "merged_by": {                "type": [                  "string",                  "null"                ],                "format": "uuid"              },              "status": {                "type": "string",                "enum": [                  "active",                  "merged",                  "closed"                ],                "description": "Stored lifecycle state; closed is distinct from merged.",                "example": "active"              },              "updated_at": {                "type": [                  "string",                  "null"                ]              },              "version": {                "type": "integer",                "minimum": 0,                "description": "Persisted optimistic-concurrency version for expected_version on merge.",                "example": 3              },              "description": {                "type": [                  "string",                  "null"                ]              },              "auto_delete_on_merge": {                "type": "boolean"              }            },            "required": [              "id",              "name",              "project_id"            ]          },          "merged_documents": {            "type": "number"          },          "added_documents": {            "type": "number"          },          "deleted_documents": {            "type": "number"          },          "auto_merged_documents": {            "type": "number"          }        },        "required": [          "success",          "branch",          "merged_documents",          "added_documents",          "deleted_documents",          "auto_merged_documents"        ]      },      "example": {        "success": true,        "branch": {          "id": "0f6d3c1e-2a4b-4c8d-9e7f-1a2b3c4d5e6f",          "name": "feature-header",          "project_id": "3b9e2c7a-5d41-4f8e-9a6b-2c1d0e9f8a7b",          "base_branch_id": "7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",          "created_at": "2026-10-10T12:00:00.000Z",          "created_by": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",          "merged_at": "2026-10-10T12:00:00.000Z",          "merged_by": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",          "status": "merged",          "updated_at": "2026-10-10T12:00:00.000Z",          "version": 5,          "description": null,          "auto_delete_on_merge": false        },        "merged_documents": 3,        "added_documents": 1,        "deleted_documents": 0,        "auto_merged_documents": 1      }    }  }}

400

Bad request

JSON
{  "description": "Bad request",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

401

Unauthorized

JSON
{  "description": "Unauthorized",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

403

Forbidden

JSON
{  "description": "Forbidden",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

404

Not found

JSON
{  "description": "Not found",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

409

Conflict

JSON
{  "description": "Conflict",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

412

Precondition failed

JSON
{  "description": "Precondition failed",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

413

Payload too large

JSON
{  "description": "Payload too large",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

500

Server error

JSON
{  "description": "Server error",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

503

internal: authentication state is temporarily unavailable and the request was not processed; retry shortly.

JSON
{  "description": "internal: authentication state is temporarily unavailable and the request was not processed; retry shortly.",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

Referenced contracts

components/parameters/ProjectReference

JSON
{  "schema": {    "$ref": "#/components/schemas/ProjectReference"  },  "required": true,  "description": "Project slug, UUID, or domain that identifies the project.",  "name": "project_reference",  "in": "path"}

components/schemas/ProjectReference

JSON
{  "type": "string"}

components/schemas/Problem

JSON
{  "type": "object",  "properties": {    "cause": {      "type": "string",      "enum": [        "schedule_concurrency_forbidden",        "schedule_fire_in_progress",        "schedule_run_limit_reached"      ],      "description": "Schedule admission refusal."    },    "idempotency": {      "type": "object",      "properties": {        "state": {          "type": "string",          "enum": [            "in_progress",            "payload_mismatch",            "outcome_unknown"          ]        },        "operation": {          "type": "string",          "minLength": 1        },        "retryable": {          "type": "boolean"        },        "retry_after_seconds": {          "type": [            "integer",            "null"          ],          "minimum": 0        },        "expires_at": {          "type": [            "string",            "null"          ]        },        "recovery": {          "type": "object",          "properties": {            "available": {              "type": "boolean"            },            "description": {              "type": "string"            },            "resource_url": {              "type": "string"            }          },          "required": [            "available",            "description"          ]        }      },      "required": [        "state",        "operation",        "retryable",        "retry_after_seconds",        "expires_at"      ],      "description": "Replay status, retry timing, and recovery lookup."    },    "type": {      "type": "string",      "description": "URI reference identifying the problem type",      "example": "https://api.veryfront.com/errors/validation-failed"    },    "title": {      "type": "string",      "description": "Short human-readable summary of the problem",      "example": "Validation Failed"    },    "status": {      "type": "integer",      "minimum": 100,      "maximum": 599,      "description": "HTTP status code",      "example": 400    },    "code": {      "type": "string",      "description": "Stable machine-readable error code",      "example": "RUN_INVALID_INPUT"    },    "detail": {      "type": "string",      "description": "Human-readable explanation specific to this occurrence",      "example": "The 'email' field must be a valid email address"    },    "instance": {      "type": "string",      "description": "URI reference identifying the specific occurrence",      "example": "/projects/my-project/members"    },    "slug": {      "type": "string",      "description": "Stable identifier for the problem type",      "example": "validation-failed"    },    "category": {      "type": "string",      "enum": [        "AUTH",        "RESOURCE",        "VALIDATION",        "DATABASE",        "SUBSCRIPTION",        "INTEGRATION",        "INTERNAL"      ],      "description": "API error category",      "example": "VALIDATION"    },    "suggestion": {      "type": "string",      "description": "Suggested action to resolve the problem",      "example": "Check the request body and query parameters against the API documentation."    },    "errors": {      "type": "array",      "items": {        "type": "object",        "properties": {          "field": {            "type": "string",            "description": "Field path that caused the error",            "example": "email"          },          "message": {            "type": "string",            "description": "Error message for this field",            "example": "Invalid email format"          },          "code": {            "type": "string",            "description": "Error code for this field",            "example": "INVALID_FORMAT"          }        },        "required": [          "field",          "message"        ]      },      "description": "Detailed field-level errors for validation failures"    }  },  "required": [    "type",    "title",    "status"  ]}

Operation contract

JSON
{  "operationId": "mergeBranch",  "tags": [    "projects/Branches/Branches"  ],  "summary": "Merge branch",  "description": "Merge a branch into main or another branch, applying its file changes, deletions and the merge message to the target. Requires project.files.write.",  "parameters": [    {      "$ref": "#/components/parameters/ProjectReference"    },    {      "schema": {        "type": "string",        "format": "uuid",        "description": "Branch UUID belonging to the selected project. Missing or foreign branches return 404."      },      "required": true,      "name": "branch_id",      "in": "path"    }  ],  "requestBody": {    "content": {      "application/json": {        "schema": {          "type": "object",          "properties": {            "expected_version": {              "type": [                "integer",                "null"              ],              "minimum": 0,              "description": "Optional optimistic-concurrency precondition against the persisted source branch version. A stale value returns 412 before merge writes.",              "example": 3            },            "target_branch_id": {              "type": [                "string",                "null"              ],              "format": "uuid",              "description": "Target branch ID; omit for main. An unknown target returns not found. Merge eligibility and conflicts are checked again when the merge commits."            },            "merge_message": {              "type": "string",              "description": "Message stored on the merge audit record.",              "example": "Ship header"            }          }        },        "example": {          "expected_version": 4,          "merge_message": "Ship header"        }      }    }  },  "responses": {    "200": {      "description": "Branch merged successfully.",      "content": {        "application/json": {          "schema": {            "type": "object",            "properties": {              "success": {                "type": "boolean"              },              "branch": {                "type": "object",                "properties": {                  "id": {                    "type": "string",                    "format": "uuid"                  },                  "name": {                    "type": "string"                  },                  "project_id": {                    "type": "string",                    "format": "uuid"                  },                  "base_branch_id": {                    "type": [                      "string",                      "null"                    ],                    "format": "uuid"                  },                  "created_at": {                    "type": [                      "string",                      "null"                    ],                    "description": "Persisted branch creation time.",                    "example": "2026-09-14T10:00:00.000Z"                  },                  "created_by": {                    "type": [                      "string",                      "null"                    ],                    "format": "uuid"                  },                  "merged_at": {                    "type": [                      "string",                      "null"                    ],                    "description": "Persisted merge time; null before a merge."                  },                  "merged_by": {                    "type": [                      "string",                      "null"                    ],                    "format": "uuid"                  },                  "status": {                    "type": "string",                    "enum": [                      "active",                      "merged",                      "closed"                    ],                    "description": "Stored lifecycle state; closed is distinct from merged.",                    "example": "active"                  },                  "updated_at": {                    "type": [                      "string",                      "null"                    ]                  },                  "version": {                    "type": "integer",                    "minimum": 0,                    "description": "Persisted optimistic-concurrency version for expected_version on merge.",                    "example": 3                  },                  "description": {                    "type": [                      "string",                      "null"                    ]                  },                  "auto_delete_on_merge": {                    "type": "boolean"                  }                },                "required": [                  "id",                  "name",                  "project_id"                ]              },              "merged_documents": {                "type": "number"              },              "added_documents": {                "type": "number"              },              "deleted_documents": {                "type": "number"              },              "auto_merged_documents": {                "type": "number"              }            },            "required": [              "success",              "branch",              "merged_documents",              "added_documents",              "deleted_documents",              "auto_merged_documents"            ]          },          "example": {            "success": true,            "branch": {              "id": "0f6d3c1e-2a4b-4c8d-9e7f-1a2b3c4d5e6f",              "name": "feature-header",              "project_id": "3b9e2c7a-5d41-4f8e-9a6b-2c1d0e9f8a7b",              "base_branch_id": "7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",              "created_at": "2026-10-10T12:00:00.000Z",              "created_by": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",              "merged_at": "2026-10-10T12:00:00.000Z",              "merged_by": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",              "status": "merged",              "updated_at": "2026-10-10T12:00:00.000Z",              "version": 5,              "description": null,              "auto_delete_on_merge": false            },            "merged_documents": 3,            "added_documents": 1,            "deleted_documents": 0,            "auto_merged_documents": 1          }        }      }    },    "400": {      "description": "Bad request",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "401": {      "description": "Unauthorized",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "403": {      "description": "Forbidden",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "404": {      "description": "Not found",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "409": {      "description": "Conflict",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "412": {      "description": "Precondition failed",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "413": {      "description": "Payload too large",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "500": {      "description": "Server error",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "503": {      "description": "internal: authentication state is temporarily unavailable and the request was not processed; retry shortly.",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    }  },  "x-documentation-source-tag": "Branches",  "x-canonical-documentation": {    "domain": "projects",    "resource": "Branches",    "subgroup": "Branches",    "name": "Merge branch",    "description": "Merge a branch into main or another branch, applying its file changes, deletions and the merge message to the target. Requires project.files.write.",    "operationId": "mergeBranch"  },  "x-mint": {    "href": "/cloud/rest/api-reference/projects-branches-branches/merge-branch"  }}