Release Allocation
6 min
release an allocation when no more sessions will use its device this returns the device to device park for other users releasing an allocation is the final step, not the same as stopping a session one allocation can contain multiple sessions, so only release it after all sessions using it have stopped before you begin keep the allocationid returned by create allocation confirm that no active or planned session still needs the allocated device sdk method java node js client allocations() delete(allocationid) await client allocations() delete(allocationid) parameter parameter required description allocationid yes identifier returned by create allocation examples client allocations() delete("allocation 123");await client allocations() delete("allocation 123"); release is final for that reservation stop every session first and release only after the last planned session cleanup order stop every active session using the allocation download logs or inspect recordings when needed release the allocation close the sdk client put cleanup in finally so failed tests do not leave devices reserved cleanup example let allocationid string | undefined; let sessionid string | undefined; try { const allocation = await client allocations() create(allocationrequest); allocationid = allocation allocationid ?? undefined; if (!allocationid) { throw new error("allocation is not ready"); } const session = await client sessions() start( new devicestartsessionrequestbuilder() allocationid(allocationid) build() ); sessionid = session sessionid ?? undefined; // run the appium test } finally { if (sessionid) { await client sessions() stop(sessionid); } if (allocationid) { await client allocations() delete(allocationid); } await client close(); } when an allocation is intentionally reused for another session, keep it active and release it only after the final session
