Files
mesh/testdata/storage_plan_paths.json

79 lines
3.8 KiB
JSON

{
"/api/v1/storage/plan": {
"get": {
"summary": "Read Dew balance and prepaid storage allowance",
"description": "Requires the account bearer. Returns account_id, asset_id, enabled, used_bytes, free_bytes (the node's free allowance, MESH_ACCOUNT_STORAGE_LIMIT_BYTES; 0 means unlimited), units_per_dew (1000000), plans [{size,limit_bytes,monthly_units,yearly_units,monthly_xmr_atomic_units,yearly_xmr_atomic_units}] for size 1gb (1073741824 bytes; 20 Dew a month, 200 Dew a year) and 5gb (5368709120 bytes; 60 Dew a month, 600 Dew a year), and plan {period,size,expires_at,limit_bytes,balance}. The top-level monthly_units, yearly_units, monthly_xmr_atomic_units and yearly_xmr_atomic_units repeat the 1gb plan for older apps. Balance and prices are integer millionths of Dew. XMR prices use integer atomic units (1 XMR = 1000000000000 atomic units), derived from the fixed node funding ratio, rounded up to fund the complete purchase. No fiat prices or external exchange-rate feed are used. Missing or unrepresentable XMR prices disable upgrades. The enabled node grants free_bytes free, or the plan size until expires_at. Expiry blocks growth while preserving reads and deletions.",
"responses": {
"200": {
"description": "Account-scoped Dew balance and storage allowance; no-store"
},
"401": {
"description": "Account authentication required"
},
"503": {
"description": "Storage balance unavailable"
}
}
},
"post": {
"summary": "Buy one month or one year of 1 GB or 5 GB storage with Dew",
"description": "Explicit prepaid purchase of a plan from GET: 1gb costs 20 Dew a month or 200 Dew a year, 5gb costs 60 Dew a month or 600 Dew a year. A missing size means 1gb. Display the plan's Dew price returned by GET before purchase. A configured fixed XMR funding ratio is required. The same size extends unexpired time or starts now; another size starts now with the unexpired time converted at the monthly price ratio (remaining x old / new, rounded down). Does not auto-renew. The debit and allowance commit atomically. Preserve request_id on uncertain results: repeating it never charges or extends twice; changing the period or size for the same ID is rejected. Monero funding uses the existing account subaddress and confirmed deposit reconciliation.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"period",
"request_id"
],
"properties": {
"period": {
"type": "string",
"enum": [
"monthly",
"yearly"
]
},
"size": {
"type": "string",
"enum": [
"1gb",
"5gb"
],
"default": "1gb"
},
"request_id": {
"type": "string",
"maxLength": 128
}
}
}
}
}
},
"responses": {
"200": {
"description": "Confirmed upgrade and current balance"
},
"400": {
"description": "Invalid period, size or request ID"
},
"401": {
"description": "Account authentication required"
},
"402": {
"description": "Not enough Dew"
},
"409": {
"description": "Request ID reused for another period or size"
},
"503": {
"description": "Upgrades disabled or unavailable; retain the request ID"
}
}
}
}
}