# usage()

Canonical URL: https://developers.iagenify.com/sdk/ref/cloud/usage/
Language: en

`api.cloud.usage() → Promise<Usage>`

Everything the account holds in IaGenify Cloud, in one object: the plan, the three services, each storage with its own ceiling, and the add-ons.

Status: GET /api/cloud/usage · free · computed on read

Nothing here is cached: the sizes are the ones recorded for each storage, and the ceilings are recomputed from the plan and the add-ons at the moment you ask. Two calls either side of a large write give two different answers.

## Returns {#returns}

```javascript
{
  pack: "go",                              // "free" | "go" | "starter"

  nosql: {
    usedBytes: 8_720_384,
    includedBytes: 1_048_576_000,          // ceiling × how many the plan allows
    quotaBytes: 1_048_576_000,             // included + the add-on pool
    perBaseBytes: 524_288_000,             // the ceiling of ONE storage
    bases: 2,
    maxBases: 2,
    overQuota: false,
    available: true,
    storages: [
      { id: "…", label: "App data",  usedBytes: 8_716_288, quotaBytes: 524_288_000, overQuota: false },
      { id: "…", label: "Reporting", usedBytes: 4_096,     quotaBytes: 524_288_000, overQuota: false }
    ]
  },

  sql:    { /* same shape */ },
  object: { /* same shape */ , hostingBytes: 2_310_144 },

  addons: {
    databaseGb: 0,
    objectGb: 1,
    renewsAt: "2026-11-02T10:14:00.000Z",
    lapsed: false,
    monthlyCredits: 200,
    pricePerGb: { database: 100, object: 200 }
  }
}
```

## A service block, field by field {#service}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `usedBytes` | integer |  | Everything that service holds. On `object` it **includes** `hostingBytes`. |
| `includedBytes` | integer |  | `perBaseBytes × maxBases` — what the plan gives before any add-on. |
| `quotaBytes` | integer |  | `includedBytes` plus the add-on pool available to this service. |
| `perBaseBytes` | integer |  | The ceiling of a single storage. **The figure a write is judged against.** |
| `bases` | integer |  | How many storages of this service exist. |
| `maxBases` | integer |  | How many the plan allows. Equal to `bases` means another one is refused. |
| `overQuota` | boolean |  | True when the total passes `quotaBytes` *or* any one storage passes its own ceiling. |
| `available` | boolean |  | Whether the service can be used right now. |
| `storages` | array |  | One entry per storage: `id`, `label`, `usedBytes`, `quotaBytes`, `overQuota`. |

## Which number to show, and which to act on {#which-number}

> **quotaBytes is the account; storages[].quotaBytes is the place you write**
>
> A progress bar on the service total can sit at 40% while an insert is refused, because one storage is full. Show the per-storage figure wherever the user is about to write, and keep the total for a summary.

```javascript
function roomFor(usage, storage) {
  const service = usage[storage.service];                       // "nosql" | "sql" | "object"
  const base = service.storages.find((s) => s.id === storage.id);
  return base ? Math.max(0, base.quotaBytes - base.usedBytes) : null;
}
```

## overQuota has two causes {#overquota}

It is true when the service total passes what the account has, **and** when a single storage passes its own ceiling — the second being the case a total can never reveal. Reading the per-storage flag tells you which.

## hostingBytes, on object only {#hosting}

What the account's hosts keep online. It is taken out of the object ceiling before the per-storage figure is computed, so a deploy visibly reduces the room left for files — one number for everything IaGenify keeps for the account.

## The add-on block {#addons}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `databaseGb · objectGb` | integer |  | Gigabytes currently held, per add-on. |
| `renewsAt` | string|null |  | When the period ends. A purchase before then is prorated. |
| `lapsed` | boolean |  | The renewal could not be paid: the pool is suspended and the ceilings are back to the plan's. |
| `monthlyCredits` | integer |  | What the add-ons cost per period, all together. |
| `pricePerGb` | object |  | `{ database: 100, object: 200 }` — credits per gigabyte per period. |

> **lapsed is worth showing**
>
> A suspended add-on takes the ceilings back down, so a storage that was comfortable becomes full without anything being written. The pool is retried, and it comes back as soon as the credits are there.

## Two things worth doing with it {#patterns}

```javascript
// 1. Before creating a storage — is one allowed at all?
const usage = await api.cloud.usage();
if (usage.nosql.bases >= usage.nosql.maxBases) {
  // api.storage.create() would answer cloud_storage_limit
}

// 2. Before a large write — will it fit?
const bytes = Buffer.byteLength(payload);
const left = usage.object.storages[0].quotaBytes - usage.object.storages[0].usedBytes;
if (bytes > left) {
  // Free something, or api.cloud.addons.buy({ service: "object", gb: 1 })
}
```

- [addons.buy()](/sdk/ref/cloud/addons-buy): Raising the ceiling, and what it costs.
- [Quotas and plans](/sdk/ref/cloud/quotas): What each plan includes, per storage.
- [IaGenify Cloud](/sdk/ref/providers/iagenify-cloud): The storages this measures.

```python
{
    "pack": "go",                              # "free" | "go" | "starter"

    "nosql": {
        "usedBytes": 8_720_384,
        "includedBytes": 1_048_576_000,        # ceiling × how many the plan allows
        "quotaBytes": 1_048_576_000,           # included + the add-on pool
        "perBaseBytes": 524_288_000,           # the ceiling of ONE storage
        "bases": 2,
        "maxBases": 2,
        "overQuota": False,
        "available": True,
        "storages": [
            {"id": "…", "label": "App data",  "usedBytes": 8_716_288, "quotaBytes": 524_288_000, "overQuota": False},
            {"id": "…", "label": "Reporting", "usedBytes": 4_096,     "quotaBytes": 524_288_000, "overQuota": False},
        ],
    },

    "sql": {},                                 # same shape as nosql
    "object": {"hostingBytes": 2_310_144},     # same shape as nosql, plus hostingBytes

    "addons": {
        "databaseGb": 0,
        "objectGb": 1,
        "renewsAt": "2026-11-02T10:14:00.000Z",
        "lapsed": False,
        "monthlyCredits": 200,
        "pricePerGb": {"database": 100, "object": 200},
    },
}
```

```python
def room_for(usage, storage):
    service = usage[storage.service]                    # "nosql" | "sql" | "object"
    base = next((s for s in service["storages"] if s["id"] == storage.id), None)
    return max(0, base["quotaBytes"] - base["usedBytes"]) if base else None
```

```python
# 1. Before creating a storage — is one allowed at all?
usage = api.cloud.usage()
if usage["nosql"]["bases"] >= usage["nosql"]["maxBases"]:
    pass  # api.storage.create() would answer cloud_storage_limit

# 2. Before a large write — will it fit?
size = len(payload)
first = usage["object"]["storages"][0]
if size > first["quotaBytes"] - first["usedBytes"]:
    pass  # Free something, or api.cloud.addons.buy(service="object", gb=1)
```
