Parameters
servicestringrequireddatabase — one pool for NoSQL and SQL — or object.
gbintegerrequiredWhole gigabytes, 1 or more. 100 at most per add-on, held together.
The price
| service | Covers | Credits per GB per period |
|---|---|---|
database | NoSQL and SQL, as one pool | 100 |
object | Object Storage | 200 |
The live figures are in usage().addons.pricePerGb, so an interface can read them rather than carry a copy.
What is charged, and when
| Situation | Charged now |
|---|---|
| No add-on yet, or the period has ended | The full monthly price. A new 30-day period starts. |
| A period is running | Prorated over the days left. The period does not move. |
| The add-ons are suspended | The new price plus what was owed, and the pool resumes. |
// First purchase — a period opens
const first = await api.cloud.addons.buy({ service: "object", gb: 1 });
// { charged: 200, usage: { … addons: { objectGb: 1, renewsAt: "…", monthlyCredits: 200 } } }
// Ten days later, one more gigabyte: 20 days left of 30
const more = await api.cloud.addons.buy({ service: "object", gb: 1 });
// { charged: 134, usage: { … addons: { objectGb: 2, monthlyCredits: 400 } } }# First purchase — a period opens
first = api.cloud.addons.buy(service="object", gb=1)
# {"charged": 200, "usage": {… "addons": {"objectGb": 1, "renewsAt": "…", "monthlyCredits": 200}}}
# Ten days later, one more gigabyte: 20 days left of 30
more = api.cloud.addons.buy(service="object", gb=1)
# {"charged": 134, "usage": {… "addons": {"objectGb": 2, "monthlyCredits": 400}}}Proration rounds up, and the two gigabytes then renew together on the same date — one period per account, not one per purchase.
Returns
chargedintegerCredits taken for this purchase.
usageobjectThe fresh usage() report, ceilings already raised. No second call needed.
An add-on is a pool, not a bigger ceiling
Each storage keeps its guaranteed ceiling; the add-on sits above them and is drawn on by whichever storage has gone past its own. So a gigabyte bought while one database is full goes where it is needed, and the guarantee of the other one is never touched.
A gigabyte bought as database serves NoSQL and SQL alike. What one takes in overflow, the other cannot — which is the only way the two share anything.
Renewal, and what suspension does
At the end of a period the monthly price is taken again. If the balance will not cover it, the add-ons are suspended rather than removed: lapsed turns true, the ceilings go back to the plan's, and the renewal is retried — so topping up brings the space back without buying again.
const { addons } = await api.cloud.usage();
if (addons.lapsed) {
// The pool is suspended. Ceilings are the plan's until the renewal goes through.
console.log(`${addons.monthlyCredits} credits are needed to resume.`);
}addons = api.cloud.usage()["addons"]
if addons["lapsed"]:
# The pool is suspended. Ceilings are the plan's until the renewal goes through.
print(f"{addons['monthlyCredits']} credits are needed to resume.")Errors
| Code | Status | When |
|---|---|---|
| invalid_addon | 400 | service is not database or object. |
| invalid_gb | 400 | Not a whole number of at least 1, or the 100 GB limit for that add-on would be passed. |
| insufficient_credits | 402 | The balance will not cover this purchase. The message says the price and the balance. |
| user_not_found | 404 | The account behind the session is gone. |
import { IaGenifyError } from "iagenify";
try {
await api.cloud.addons.buy({ service: "object", gb: 1 });
} catch (err) {
if (err instanceof IaGenifyError && err.code === "insufficient_credits") {
// Nothing was charged and nothing was added.
}
}from iagenify import IaGenifyError
try:
api.cloud.addons.buy(service="object", gb=1)
except IaGenifyError as error:
if error.code != "insufficient_credits":
raise
# Nothing was charged and nothing was added.Credits are taken before the gigabytes are recorded, and a refusal records nothing — a failed purchase leaves the account exactly as it was.