---
title: Release Allocation
slug: devicepark/sdk-documentation/allocations/release-allocation
description: Return a reserved device after the final session.
docTags: 
createdAt: 2026-08-10T08:03:44.631Z
---

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                                           | .NET                                                 |
| ------------------------------------------- | ------------------------------------------------- | ---------------------------------------------------- |
| `client.allocations().delete(allocationId)` | `await client.allocations().delete(allocationId)` | `await client.Allocations.DeleteAsync(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

:::CodeblockTabs
```java
client.allocations().delete("allocation-123");
```

```typescript
await client.allocations().delete("allocation-123");
```

```csharp
await client.Allocations.DeleteAsync("allocation-123");
```
:::

:::hint{type="warning"}
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>` / `Task` 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

1. Stop every active session using the allocation.
2. Download logs or inspect recordings when needed.
3. Release the allocation.
4. Close the SDK client. Java uses try-with-resources, Node.js `await client.close()`, and .NET a `using` declaration.

Put cleanup in `finally` so failed tests do not leave devices reserved.

## Cleanup Example

```typescript
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("qa@example.com")
      .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.
