curl -X POST https://api.podflare.ai/v1/sandboxes/$PARENT/merge_into/$WINNER
parent.merge_into(winner)
# parent.id still works, now drives winner's VM.
# winner.close() is a no-op afterward (marked defunct).
await parent.mergeInto(winner);
// parent.id still works; winner is defunct.
Reference
Merge into
Commit a fork child as the new state of its parent.
POST
/
v1
/
sandboxes
/
{parent}
/
merge_into
/
{winner}
curl -X POST https://api.podflare.ai/v1/sandboxes/$PARENT/merge_into/$WINNER
parent.merge_into(winner)
# parent.id still works, now drives winner's VM.
# winner.close() is a no-op afterward (marked defunct).
await parent.mergeInto(winner);
// parent.id still works; winner is defunct.
string
required
The parent sandbox id.
string
required
A child sandbox id (typically a fork of
parent) whose state should
replace parent’s.curl -X POST https://api.podflare.ai/v1/sandboxes/$PARENT/merge_into/$WINNER
parent.merge_into(winner)
# parent.id still works, now drives winner's VM.
# winner.close() is a no-op afterward (marked defunct).
await parent.mergeInto(winner);
// parent.id still works; winner is defunct.
What actually happens
Atomically swap: parent’s microVM is destroyed and the winner’s microVM takes over parent’s id. After the call:parent.idis still a valid sandbox id, but it now drives the winner’s underlying VM.winner.idis no longer a live sandbox. The SDK flags thewinnerobject so itsclose()becomes a no-op (prevents double-destroy).- Siblings are NOT touched. If you forked
n=5and one is the winner, the other 4 are still alive — the caller destroys them explicitly.
Idempotency
- Merging the same winner twice: second call returns 404 (winner id gone after first merge).
- Merging a sandbox into itself: 400.
Typical pattern
children = parent.fork(n=5)
try:
results = [c.run_code(plan) for c, plan in zip(children, plans)]
winner = children[pick_best_index(results)]
parent.merge_into(winner)
finally:
for c in children:
if c is not winner:
c.close()

