api.cloud

addons.buy()

api.cloud.addons.buy({ service, gb }) → Promise<{ charged, usage }>

Adds gigabytes to the account, paid in credits for a 30-day period. Full price on the first purchase, prorated for the days left on the next.

POST /api/cloud/addonscharged immediatelyrenews monthly
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

servicestringrequired

database — one pool for NoSQL and SQL — or object.

gbintegerrequired

Whole gigabytes, 1 or more. 100 at most per add-on, held together.

The price

serviceCoversCredits per GB per period
databaseNoSQL and SQL, as one pool100
objectObject Storage200

The live figures are in usage().addons.pricePerGb, so an interface can read them rather than carry a copy.

What is charged, and when

SituationCharged now
No add-on yet, or the period has endedThe full monthly price. A new 30-day period starts.
A period is runningProrated over the days left. The period does not move.
The add-ons are suspendedThe 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

chargedinteger

Credits taken for this purchase.

usageobject

The 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.

database is one pool for two services

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

CodeStatusWhen
invalid_addon400service is not database or object.
invalid_gb400Not a whole number of at least 1, or the 100 GB limit for that add-on would be passed.
insufficient_credits402The balance will not cover this purchase. The message says the price and the balance.
user_not_found404The 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.