Skip to main content
POST
/
v1
/
sandboxes
/
{parent}
/
merge_into
/
{winner}
curl -X POST https://api.podflare.ai/v1/sandboxes/$PARENT/merge_into/$WINNER

Documentation Index

Fetch the complete documentation index at: https://docs.podflare.ai/llms.txt

Use this file to discover all available pages before exploring further.

parent
string
required
The parent sandbox id.
winner
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

What actually happens

Atomically swap: parent’s microVM is destroyed and the winner’s microVM takes over parent’s id. After the call:
  • parent.id is still a valid sandbox id, but it now drives the winner’s underlying VM.
  • winner.id is no longer a live sandbox. The SDK flags the winner object so its close() becomes a no-op (prevents double-destroy).
  • Siblings are NOT touched. If you forked n=5 and 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()