# storage

Canonical URL: https://developers.iagenify.com/sdk/agent/permissions/categories/storage/
Language: en

Changing a connected database or bucket. Asked even in auto, because none of it can be undone — and « always » is remembered per storage, never for all of them.

Status: asked even in auto · always is per storage · no undo

| ask | auto | plan | full |
| --- | --- | --- | --- |
| asked | asked | refused | allowed |

## The tools {#tools}

| Tool | When |
| --- | --- |
| `write_storage` | Always — insert, update, delete, SQL writes, object put and remove. |
| `workflow` | Its write actions: create, update, run, delete. |
| `mail` | Its write actions — reading a mailbox is `read`. |
| `cloud` | Its write actions, except buying space, which is [money](/sdk/agent/permissions/categories/money). |

## There is no previous version for a row {#no-undo}

A file the engine replaces keeps a copy. A deleted document, a dropped collection and an overwritten object keep nothing — the storage is someone else's and the engine has no store of its own in it. That asymmetry is the whole reason auto stops here.

## « always » is for that storage {#per-storage}

```javascript
onPermission: async ({ category, args }) => {
  if (category !== "storage") return "once";
  if (args.storage === "Staging") return "always";   // this storage only
  return "deny";                                      // production stays asked
}
```

The key is built from the storage named in the arguments, so approving *Staging* leaves *Production* asked. It lasts for the session and is never written to disk.

## Guards run before the prompt {#guards}

| Refused before you are asked | Why |
| --- | --- |
| An update or delete with an empty filter, without `all: true` | It would touch every document. |
| More than one SQL statement in a call | What is approved must be what runs. |
| `DROP` outside full mode | The one statement with no partial recovery. |

> **A guard that fires costs no prompt**
>
> The call fails with an explanation the model can act on, and the user is never asked about something that was going to be refused anyway.

## What arrives in args {#arguments}

Object-shaped arguments — filter, pipeline, update, documents — travel as JSON **text**, because a free-form object loses the keys beginning with `$`. Parse them in your callback if you want to inspect what is about to change.

```javascript
const change = JSON.parse(args.request || "{}");
if (change.action === "delete" && change.all) return "deny";
```

- [write_storage](/sdk/agent/tools/write-storage): The tool and its actions.
- [run()](/sdk/ref/connected-storage/run): Doing it yourself instead.

```python
def on_permission(request):
    if request["category"] != "storage":
        return "once"
    if request["args"].get("storage") == "Staging":
        return "always"   # this storage only
    return "deny"         # production stays asked
```

```python
args = request["args"]
if args.get("action") == "delete" and args.get("all"):
    return "deny"
```
