Promote a whole branch into another
POST /Platform/entities/merge-branch
Promote a whole branch into another. Merges every entity on the branch in one call.
The branch-level counterpart to per-entity merge. Discovers what
the branch touched itself, so you don't need to know every entity id
up front.
Standard entity-change workflow:
-
Create or select a feature branch.
-
Edit the existing ids on that branch.
-
Test the changed behavior on the feature branch.
-
Open a changeset with test evidence. A human reviews and approves it, then the merge executes the approved plan.
dry_run=true (the default) previews the promote plan for any
caller. Applying it directly with dry_run=false is the
one-command path for low-risk solo work: in an org where main
is protected it requires the bypass_branch_protection
permission (see docs_api(page='changesets')); everyone else
promotes through changeset_open -> review -> changeset_merge.
Every real promotion, reviewed or not, is recorded as a changeset;
changeset_id in the response links to the ledger entry.
Semantics that matter:
- All-or-nothing by default. Every entity is merged with
dry_runfirst; if ANY entity conflicts or errors, NOTHING is written and the full report comes back. Passpartial=truefor best-effort instead. - Children before parents. An entity can't be stored on
to_branchwhile a child it references exists only onfrom_branch, so the work list is ordered by the reference graph. - New entities are included, not just diverged ones: an entity created on the branch is promoted as a fast-forward.
- Runtime-only entities are excluded. Transactional entities and
other classes marked
branch_promotable = Falseremain on the source branch. Use the explicit single-entitymergeroute for exceptional recovery. dry_run=true(the default) is a reviewable promote plan and the exact same computation the real run does first.
Conflicts come back keyed by entity; resolve by re-calling with
resolutions={"EntityType/entity_id": {conflict_path: "ours" | "theirs" | "base" | {"value": X}}}.
Body parameters
from_branch: str. Branch to promote FROM (the feature branch).to_branch: optional str. Branch to promote INTO (defaultmain).entity_types: optional str. Restrict the promote to these types.ids: optional str. Restrict the promote to these entity ids.dry_run: optional bool. True (default) computes and reports without writing.resolutions: optional dict. Per-entity conflict resolutions (see above).commit_message: optional str. Commit message for each merge commit.include_diff: optional bool. Include a unified diff per merged entity.partial: optional bool. Best-effort — write what can be written, report the rest.
Returns
MergeBranchResponse
from_branch: optional str or null. Branch promoted from.to_branch: optional str or null. Branch promoted into.dry_run: optional bool. True when nothing was written; the response is the plan.partial: optional bool. True when best-effort mode was requested.results: optional List[dict]. One per entity, children before parents: entity_type, entity_id, status, commit_id, conflicts, diff, failure.merged: optional int. Entities merged (or that would be).conflicted: optional int. Entities with conflicts.failed: optional int. Entities that failed.code: optional List[dict]. Per repository merged with the entities: repo_id, repo_name, head_sha, merged_sha (empty on a dry run).up_to_date: optional int. Entities already identical on to_branch.deleted: optional int. Entities the branch deleted, deleted (or that would be) on to_branch.skipped: optional List[dict]. Runtime-only entities (calls, conversations, ...) left on the source branch.skipped_count: optional int. Number of skipped entities.written: optional List[dict]. Entities actually written; non-empty with a failure means the promotion stopped midway.changeset_id: optional str or null. The merged changeset that records this promotion; None on a dry run.failure: optional str or null. Why the promotion was blocked or stopped; None when it completed.
Example request
curl -X POST "https://api.hilus.ai/Platform/entities/merge-branch" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'