The point is that the rest of your code does not change. A storage created here answers the same run() actions as a connected one of the matching shape — so the branch you wrote for a customer's database works on one of ours, and the other way round.
The three services
| service | type | Reads like | Actions |
|---|---|---|---|
nosql | database | A document database | the MongoDB set |
sql | database | A relational database | tables · overview · execute |
object | object | A bucket | the R2 set |
const base = await api.storage.create({ service: "nosql", label: "App data" });
await base.run({ action: "insert", collection: "events", documents: [{ at: new Date(), kind: "signup" }] });
await base.run({ action: "count", collection: "events" });
// base.service === "nosql" base.provider === "iagenify" base.managedBy === "iagenify"from datetime import datetime, timezone
base = api.storage.create(service="nosql", label="App data")
base.run(action="insert", collection="events",
documents=[{"at": datetime.now(timezone.utc).isoformat(), "kind": "signup"}])
base.run(action="count", collection="events")
# base.service == "nosql" base.provider == "iagenify" base.managed_by == "iagenify"service is how you tell them apart
type says what you can do; provider says iagenify; and service — null on every connected storage — says which of the three this is. It is the field to read when you need to know whose space is being consumed.
Every account is born with one
An account is created with its own Object Storage, and that storage is the account's default — so a save with no target lands there. Since the plans include one object storage, asking for a second is refused: the one you have is the one the plan gives.
Space is per storage, and it is enforced
Each storage has its own ceiling rather than a share of a common pool. A write that would pass it is refused with quota_exceeded (403) before anything is stored; reading and deleting keep working, which is what lets you free space without buying any.
import { IaGenifyError } from "iagenify";
try {
await base.run({ action: "insert", collection: "events", documents });
} catch (err) {
if (err instanceof IaGenifyError && err.code === "quota_exceeded") {
// Delete something, or add space: see api.cloud.addons.buy()
}
}from iagenify import IaGenifyError
try:
base.run(action="insert", collection="events", documents=documents)
except IaGenifyError as error:
if error.code != "quota_exceeded":
raise
# Delete something, or add space: see api.cloud.addons.buy()The SQL service, and what it does not have
sql answers tables, overview and execute, with params bound the same way as D1. Two things are its own: a statement has a time limit, and passing it raises query_timeout (408) rather than hanging; and execute reports sizeAfter, the size of the database once the statement has run.
const sql = await api.storage.create({ service: "sql", label: "Reporting" });
await sql.run({ action: "execute", sql: "CREATE TABLE visits (id INTEGER PRIMARY KEY, at TEXT)" });
await sql.run({ action: "execute", sql: "INSERT INTO visits (at) VALUES (?)", params: [new Date().toISOString()] });
// { rows: [], rowsRead: null, rowsWritten: null, sizeAfter: 12288 }from datetime import datetime, timezone
sql = api.storage.create(service="sql", label="Reporting")
sql.run(action="execute", sql="CREATE TABLE visits (id INTEGER PRIMARY KEY, at TEXT)")
sql.run(action="execute", sql="INSERT INTO visits (at) VALUES (?)",
params=[datetime.now(timezone.utc).isoformat()])
# {"rows": [], "rowsRead": None, "rowsWritten": None, "sizeAfter": 12288}The object service
Keys are yours, with no prefix added and none to strip. list, overview, object, upload and delete behave as on a connected bucket, and an invalid key is refused with invalid_key (400) rather than being cleaned into something you did not ask for.
Errors
| Code | Status | When |
|---|---|---|
| invalid_service | 400 | service is missing or is not one of the three. |
| cloud_storage_limit | 403 | The plan's count for that service is already used. |
| quota_exceeded | 403 | The write would pass this storage's ceiling. |
| query_timeout | 408 | A SQL statement ran too long. |
| invalid_key | 400 | An object key that cannot be stored. |
| object_not_found | 404 | No object at that key. |
What is behind it is not part of the contract
Nothing of the implementation is handed back: no address, no credentials, no internal identifier. What you get is the shape — and that is the part we keep stable.