# query_storage

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/query-storage/
Language: en

`query_storage({ storage?, action, … })`

Read any connected database or bucket. Twelve actions, never asked — and the first one to call is overview, which answers in one turn what three would otherwise take.

Status: category: read · free, except search · start with overview

## The actions {#actions}

| Action | On | Takes |
| --- | --- | --- |
| `overview` | any | — |
| `collections` · `schema` · `find` · `count` · `aggregate` | a document database | `collection`, and filters as JSON text |
| `tables` · `sql` | a relational database | `sql`, `params` |
| `objects` · `object` | a bucket | `prefix`, `key` |
| `usage` | an IaGenify Cloud storage | `storage`, or nothing for the account |
| `search` | any | `query`, `limit` — 1 credit |

## overview first {#overview}

> **It is the difference between two turns and twenty**
>
> It returns everything the storage holds — collections or tables with their fields and one real example each, or a bucket's folders with what they weigh — in a single call. Discovering the shape one call at a time is a turn each.

## Examples are masked {#masked}

In those examples a value that looks like a secret or personal data — a password, a token, a hash, a key, an address, a phone number — is replaced by a marker followed by its type. **The field is real, the value is not.** The agent is told never to filter on a marker, and to read the field with `find` if the task truly needs it.

## Filters travel as JSON text {#json-text}

```javascript
query_storage({
  action: "aggregate",
  collection: "orders",
  pipeline: '[{"$match":{"status":"paid"}},{"$group":{"_id":"$model","total":{"$sum":"$amount"}}}]',
})
```

As a free-form object the keys beginning with `$` are stripped, and a filter with no operator is a different query rather than a failed one. As text nothing is touched.

## One aggregate, never a series of finds {#aggregate}

For totals, averages and breakdowns the instruction is explicit: `$match`, then `$group`, then `$sort`. Paging through `find` to add numbers up costs a turn per page and gets them wrong.

## Name the storage when there are several {#naming}

`storage` takes the label as the system prompt lists it under « Connected storages ».

- [write_storage](/sdk/agent/tools/write-storage): Changing one.
- [run()](/sdk/ref/connected-storage/run): The same actions from your code.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
# The call the model makes:
query_storage = {
    "action": "aggregate",
    "collection": "orders",
    "pipeline": '[{"$match":{"status":"paid"}},{"$group":{"_id":"$model","total":{"$sum":"$amount"}}}]',
}
```
