# remove()

Canonical URL: https://developers.iagenify.com/sdk/ref/storage/remove/
Language: en

`api.storage.remove(id) → Promise<Result>`

Disconnects a storage. For one of ours, that also erases what was in it — and the response says which happened.

Status: DELETE /api/storage/:id · free · disconnect or delete

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string | required | From [list()](/sdk/ref/storage/list). Missing → the SDK throws. |

## Two very different outcomes {#two}

| Storage | What happens | Response |
| --- | --- | --- |
| Connected (yours) | We forget the connection. Your data is untouched. | { ok: true } |
| IaGenify Cloud (ours) | The data is erased with it. | { ok: true, deleted: true } |
| A computer or a phone | We forget the device. Its files stay on it. | { ok: true } |

> **deleted: true means the data is gone**
>
> For a storage we host there is nowhere else for it to be. Read what matters out first — reading is free — because nothing here is recoverable.

```javascript
const result = await api.storage.remove(id);

if (result.deleted) {
  // What was in it no longer exists anywhere.
}
```

## Removing the default is allowed {#default}

It is not refused: the flag is handed to another active storage, in a deliberate order rather than whatever sorts first.

| Preferred heir | Why |
| --- | --- |
| An IaGenify Cloud storage | It can actually hold bytes for you. |
| Another connected storage | Same, through your own provider. |
| A computer or a phone, last | A save with no target cannot write there at all. |
| The most recent, on a tie | The one most likely to be in use. |

That order is the point: a default pointing at a device is a default that refuses every untargeted save. Read [list()](/sdk/ref/storage/list) afterwards to see who took it.

```javascript
await api.storage.remove(previousDefault);

const now = (await api.storage.list()).find((s) => s.isDefault);
console.log(`the default is now ${now.label} (${now.type})`);
```

## Before you remove a connected storage {#before}

- Files saved to it through [api.files](/sdk/ref/files) lose the place they point at — list them first.
- Anything indexed from it stops being findable by meaning.
- An agent that was given it will no longer find it, and will say so rather than guess.

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| — (thrown locally) | — | No id passed. |
| storage_not_found | 404 | No active storage of this account with that id. |

Removing twice answers `404` the second time. Note what is *not* here: there is no refusal for « this one is the default ». Every storage can be removed, the flag simply moves — otherwise the storage an account is born with could never be removed at all.

- [list()](/sdk/ref/storage/list): Seeing what is left, and who holds the default.
- [api.cloud.usage()](/sdk/ref/cloud/usage): What a removal gave back.

```python
result = api.storage.remove(storage_id)

if result.get("deleted"):
    pass  # What was in it no longer exists anywhere.
```

```python
api.storage.remove(previous_default)

now = next(s for s in api.storage.list() if s.is_default)
print(f"the default is now {now.label} ({now.type})")
```
