Release Allocation
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 |
The method sends the identifier as the allocation resource path. It has no request body and no customer-supplied headers.
Examples
client.allocations().delete("allocation-123");Release is final for that reservation. Stop every session first and release only after the last planned session.
Result
The method returns void/Promise<void> when deletion succeeds. There is no response model to persist.
After success:
- the allocation cannot be used to start another session
- the reserved device can return to Device Park capacity
- the previous allocationId should be removed from runner state
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)
.userId(42)
.userEmail("[email protected]")
.companyId(7)
.companyName("Example Company")
.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.