Français
Budget
Les routes sont relatives à <PUBLIC_BASE_URL> ; les corps de requête et de réponse sont en JSON sauf mention contraire. L’authentification, les portées, la pagination et le format des erreurs sont décrits dans les guides de l’API REST.
GET /api/v1/billing
Lire le budget
La formule, les soldes du mois, la recharge automatique, les relevés en cours et clos, et le catalogue réel, tels que le control plane les sert. Une instance autonome répond linked: false ; un control plane injoignable répond reachable: false, avec le dernier budget connu.
Accès — Session de membre ou clé d’API portant admin:read (rôle administrateur requis).
Réponses
200 — Le budget.
| Champ | Type | Requis |
|---|---|---|
linked | boolean | oui |
reachable | boolean | oui |
fetchedAt | string | null | oui |
billing | object | null | oui |
Schéma JSON
json
{
"type": "object",
"properties": {
"linked": { "type": "boolean" },
"reachable": { "type": "boolean" },
"fetchedAt": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"billing": {
"anyOf": [
{
"type": "object",
"properties": {
"exemption": {
"anyOf": [
{ "type": "string", "enum": [ "internal", "demo" ] },
{ "type": "null" }
]
},
"currency": { "type": "string" },
"period": { "type": "string" },
"plan": {
"anyOf": [
{
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedLoops": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"includedAiCredits": { "type": "string" },
"includedSupportMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"negotiated": { "type": "boolean" },
"since": { "type": "string" }
},
"required": [
"key",
"name",
"monthlyPrice",
"includedLoops",
"includedAiCredits",
"includedSupportMinutes",
"negotiated",
"since"
],
"additionalProperties": false
},
{ "type": "null" }
]
},
"pendingPlan": {
"anyOf": [
{
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"effectiveOn": { "type": "string" }
},
"required": [ "key", "name", "monthlyPrice", "effectiveOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
},
"loops": {
"type": "object",
"properties": {
"included": { "type": "number", "minimum": 0 },
"reserveRemaining": { "type": "number", "minimum": 0 },
"consumed": { "type": "number", "minimum": 0 },
"remaining": { "type": "number", "minimum": 0 },
"overage": { "type": "number", "minimum": 0 },
"percentUsed": { "type": "number", "minimum": 0 },
"projection": {
"anyOf": [
{
"type": "object",
"properties": {
"percentAtMonthEnd": { "type": "number", "minimum": 0 },
"exhaustedOn": {
"anyOf": [ { "type": "string" }, { "type": "null" } ]
}
},
"required": [ "percentAtMonthEnd", "exhaustedOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
}
},
"required": [
"included",
"reserveRemaining",
"consumed",
"remaining",
"overage",
"percentUsed",
"projection"
],
"additionalProperties": false
},
"aiCredits": {
"type": "object",
"properties": {
"included": { "type": "number", "minimum": 0 },
"reserveRemaining": { "type": "number", "minimum": 0 },
"consumed": { "type": "number", "minimum": 0 },
"remaining": { "type": "number", "minimum": 0 },
"overage": { "type": "number", "minimum": 0 },
"percentUsed": { "type": "number", "minimum": 0 },
"projection": {
"anyOf": [
{
"type": "object",
"properties": {
"percentAtMonthEnd": { "type": "number", "minimum": 0 },
"exhaustedOn": {
"anyOf": [ { "type": "string" }, { "type": "null" } ]
}
},
"required": [ "percentAtMonthEnd", "exhaustedOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
}
},
"required": [
"included",
"reserveRemaining",
"consumed",
"remaining",
"overage",
"percentUsed",
"projection"
],
"additionalProperties": false
},
"service": {
"type": "object",
"properties": {
"stopped": { "type": "boolean" },
"stoppedAt": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }
},
"required": [ "stopped", "stoppedAt" ],
"additionalProperties": false
},
"autoRecharge": {
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"packKey": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"monthlyCap": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"usedThisMonth": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [ "enabled", "packKey", "monthlyCap", "usedThisMonth" ],
"additionalProperties": false
},
"support": {
"type": "object",
"properties": {
"includedMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"usedMinutes": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"responseHours": {
"type": "array",
"items": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
}
},
"required": [ "includedMinutes", "usedMinutes", "responseHours" ],
"additionalProperties": false
},
"currentStatement": {
"type": "object",
"properties": {
"issuedOn": { "type": "string" },
"total": { "type": "string" },
"lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"kind": { "type": "string" },
"label": { "type": "string" },
"amount": { "type": "string" }
},
"required": [ "kind", "label", "amount" ],
"additionalProperties": false
}
}
},
"required": [ "issuedOn", "total", "lines" ],
"additionalProperties": false
},
"statements": {
"type": "array",
"items": {
"type": "object",
"properties": {
"period": { "type": "string" },
"total": { "type": "string" },
"currency": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"kind": { "type": "string" },
"label": { "type": "string" },
"amount": { "type": "string" }
},
"required": [ "kind", "label", "amount" ],
"additionalProperties": false
}
}
},
"required": [ "period", "total", "currency", "lines" ],
"additionalProperties": false
}
},
"catalog": {
"type": "object",
"properties": {
"plans": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"tagline": {
"type": "object",
"propertyNames": { "type": "string" },
"additionalProperties": { "type": "string" }
},
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedLoops": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"includedAiCredits": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedSupportMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"onQuote": { "type": "boolean" },
"highlighted": { "type": "boolean" }
},
"required": [
"key",
"name",
"tagline",
"monthlyPrice",
"includedLoops",
"includedAiCredits",
"includedSupportMinutes",
"onQuote",
"highlighted"
],
"additionalProperties": false
}
},
"packs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"credit": { "type": "string", "enum": [ "loops", "ai_credits" ] },
"quantity": { "type": "string" },
"price": { "type": "string" }
},
"required": [ "key", "credit", "quantity", "price" ],
"additionalProperties": false
}
}
},
"required": [ "plans", "packs" ],
"additionalProperties": false
},
"alerts": {
"type": "object",
"properties": {
"loops": { "type": "boolean" },
"ai": { "type": "boolean" },
"recharge": { "type": "boolean" },
"recipients": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"email": { "type": "string" }
},
"required": [ "name", "email" ],
"additionalProperties": false
}
},
"firstThresholdPercent": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [
"loops",
"ai",
"recharge",
"recipients",
"firstThresholdPercent"
],
"additionalProperties": false
}
},
"required": [
"exemption",
"currency",
"period",
"plan",
"pendingPlan",
"loops",
"aiCredits",
"service",
"autoRecharge",
"support",
"currentStatement",
"statements",
"catalog",
"alerts"
],
"additionalProperties": false
},
{ "type": "null" }
]
}
},
"required": [ "linked", "reachable", "fetchedAt", "billing" ],
"additionalProperties": false
}401 — Aucune session ni clé d’API valide (auth.unauthenticated).
403 — Refusé : rôle insuffisant (auth.forbidden), portée manquante (api_key.scope_missing, details.required la nomme) ou route fermée aux clés (api_key.session_required).
429 — La clé d’API dépasse son débit (api_key.rate_limited) ; Retry-After dit quand réessayer.
POST /api/v1/billing/orders
Passer un ordre de facturation
Acheter un pack, changer de formule (effet le 1er du mois suivant), régler la recharge automatique ou les alertes. Pas de paiement en ligne : un achat va au relevé. Idempotent par ref. Refusé à une clé d’API : acheter est le geste d’une personne. Journalisé dans l’audit.
Accès — Session de membre ou clé d’API portant admin:write (rôle administrateur requis).
Corps de la requête (application/json)
Type : object
Schéma JSON
json
{
"oneOf": [
{
"type": "object",
"properties": {
"ref": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"type": { "type": "string", "const": "buy_pack" },
"packKey": { "type": "string", "minLength": 1, "maxLength": 60 },
"count": { "type": "integer", "minimum": 1, "maximum": 20 }
},
"required": [ "ref", "type", "packKey" ]
},
{
"type": "object",
"properties": {
"ref": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"type": { "type": "string", "const": "change_plan" },
"planKey": { "type": "string", "minLength": 1, "maxLength": 60 }
},
"required": [ "ref", "type", "planKey" ]
},
{
"type": "object",
"properties": {
"ref": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"type": { "type": "string", "const": "set_auto_recharge" },
"enabled": { "type": "boolean" },
"packKey": { "type": "string", "minLength": 1, "maxLength": 60 }
},
"required": [ "ref", "type", "enabled" ]
},
{
"type": "object",
"properties": {
"ref": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"type": { "type": "string", "const": "set_alerts" },
"loops": { "type": "boolean" },
"ai": { "type": "boolean" },
"recharge": { "type": "boolean" },
"recipientMemberIds": { "maxItems": 20, "type": "array", "items": { "type": "string" } }
},
"required": [ "ref", "type", "loops", "ai", "recharge" ]
}
]
}Réponses
200 — L’ordre, et le budget qu’il laisse.
| Champ | Type | Requis |
|---|---|---|
ref | string | oui |
type | string | oui |
effectiveOn | string | null | oui |
duplicate | boolean | oui |
billing | object | oui |
Schéma JSON
json
{
"type": "object",
"properties": {
"ref": { "type": "string" },
"type": { "type": "string" },
"effectiveOn": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"duplicate": { "type": "boolean" },
"billing": {
"type": "object",
"properties": {
"exemption": {
"anyOf": [
{ "type": "string", "enum": [ "internal", "demo" ] },
{ "type": "null" }
]
},
"currency": { "type": "string" },
"period": { "type": "string" },
"plan": {
"anyOf": [
{
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedLoops": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"includedAiCredits": { "type": "string" },
"includedSupportMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"negotiated": { "type": "boolean" },
"since": { "type": "string" }
},
"required": [
"key",
"name",
"monthlyPrice",
"includedLoops",
"includedAiCredits",
"includedSupportMinutes",
"negotiated",
"since"
],
"additionalProperties": false
},
{ "type": "null" }
]
},
"pendingPlan": {
"anyOf": [
{
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"effectiveOn": { "type": "string" }
},
"required": [ "key", "name", "monthlyPrice", "effectiveOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
},
"loops": {
"type": "object",
"properties": {
"included": { "type": "number", "minimum": 0 },
"reserveRemaining": { "type": "number", "minimum": 0 },
"consumed": { "type": "number", "minimum": 0 },
"remaining": { "type": "number", "minimum": 0 },
"overage": { "type": "number", "minimum": 0 },
"percentUsed": { "type": "number", "minimum": 0 },
"projection": {
"anyOf": [
{
"type": "object",
"properties": {
"percentAtMonthEnd": { "type": "number", "minimum": 0 },
"exhaustedOn": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }
},
"required": [ "percentAtMonthEnd", "exhaustedOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
}
},
"required": [
"included",
"reserveRemaining",
"consumed",
"remaining",
"overage",
"percentUsed",
"projection"
],
"additionalProperties": false
},
"aiCredits": {
"type": "object",
"properties": {
"included": { "type": "number", "minimum": 0 },
"reserveRemaining": { "type": "number", "minimum": 0 },
"consumed": { "type": "number", "minimum": 0 },
"remaining": { "type": "number", "minimum": 0 },
"overage": { "type": "number", "minimum": 0 },
"percentUsed": { "type": "number", "minimum": 0 },
"projection": {
"anyOf": [
{
"type": "object",
"properties": {
"percentAtMonthEnd": { "type": "number", "minimum": 0 },
"exhaustedOn": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }
},
"required": [ "percentAtMonthEnd", "exhaustedOn" ],
"additionalProperties": false
},
{ "type": "null" }
]
}
},
"required": [
"included",
"reserveRemaining",
"consumed",
"remaining",
"overage",
"percentUsed",
"projection"
],
"additionalProperties": false
},
"service": {
"type": "object",
"properties": {
"stopped": { "type": "boolean" },
"stoppedAt": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }
},
"required": [ "stopped", "stoppedAt" ],
"additionalProperties": false
},
"autoRecharge": {
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"packKey": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"monthlyCap": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"usedThisMonth": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [ "enabled", "packKey", "monthlyCap", "usedThisMonth" ],
"additionalProperties": false
},
"support": {
"type": "object",
"properties": {
"includedMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"usedMinutes": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"responseHours": {
"type": "array",
"items": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
}
},
"required": [ "includedMinutes", "usedMinutes", "responseHours" ],
"additionalProperties": false
},
"currentStatement": {
"type": "object",
"properties": {
"issuedOn": { "type": "string" },
"total": { "type": "string" },
"lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"kind": { "type": "string" },
"label": { "type": "string" },
"amount": { "type": "string" }
},
"required": [ "kind", "label", "amount" ],
"additionalProperties": false
}
}
},
"required": [ "issuedOn", "total", "lines" ],
"additionalProperties": false
},
"statements": {
"type": "array",
"items": {
"type": "object",
"properties": {
"period": { "type": "string" },
"total": { "type": "string" },
"currency": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"kind": { "type": "string" },
"label": { "type": "string" },
"amount": { "type": "string" }
},
"required": [ "kind", "label", "amount" ],
"additionalProperties": false
}
}
},
"required": [ "period", "total", "currency", "lines" ],
"additionalProperties": false
}
},
"catalog": {
"type": "object",
"properties": {
"plans": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"name": { "type": "string" },
"tagline": {
"type": "object",
"propertyNames": { "type": "string" },
"additionalProperties": { "type": "string" }
},
"monthlyPrice": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedLoops": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"includedAiCredits": { "anyOf": [ { "type": "string" }, { "type": "null" } ] },
"includedSupportMinutes": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{ "type": "null" }
]
},
"onQuote": { "type": "boolean" },
"highlighted": { "type": "boolean" }
},
"required": [
"key",
"name",
"tagline",
"monthlyPrice",
"includedLoops",
"includedAiCredits",
"includedSupportMinutes",
"onQuote",
"highlighted"
],
"additionalProperties": false
}
},
"packs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"credit": { "type": "string", "enum": [ "loops", "ai_credits" ] },
"quantity": { "type": "string" },
"price": { "type": "string" }
},
"required": [ "key", "credit", "quantity", "price" ],
"additionalProperties": false
}
}
},
"required": [ "plans", "packs" ],
"additionalProperties": false
},
"alerts": {
"type": "object",
"properties": {
"loops": { "type": "boolean" },
"ai": { "type": "boolean" },
"recharge": { "type": "boolean" },
"recipients": {
"type": "array",
"items": {
"type": "object",
"properties": { "name": { "type": "string" }, "email": { "type": "string" } },
"required": [ "name", "email" ],
"additionalProperties": false
}
},
"firstThresholdPercent": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [ "loops", "ai", "recharge", "recipients", "firstThresholdPercent" ],
"additionalProperties": false
}
},
"required": [
"exemption",
"currency",
"period",
"plan",
"pendingPlan",
"loops",
"aiCredits",
"service",
"autoRecharge",
"support",
"currentStatement",
"statements",
"catalog",
"alerts"
],
"additionalProperties": false
}
},
"required": [ "ref", "type", "effectiveOn", "duplicate", "billing" ],
"additionalProperties": false
}400 — La requête ne respecte pas son schéma.
401 — Aucune session ni clé d’API valide (auth.unauthenticated).
403 — Refusé : rôle insuffisant (auth.forbidden), portée manquante (api_key.scope_missing, details.required la nomme) ou route fermée aux clés (api_key.session_required).
429 — La clé d’API dépasse son débit (api_key.rate_limited) ; Retry-After dit quand réessayer.
Codes d’erreur — request.bad_request, api_key.session_required, billing.not_linked, billing.unreachable, billing.invalid_order, billing.order_conflict, billing.pack_unavailable, billing.plan_unavailable, billing.plan_on_quote, billing.plan_negotiated, billing.plan_unchanged, billing.not_billable, billing.instance_unavailable. Les codes communs (request.bad_request, auth.unauthenticated, api_key.scope_missing, api_key.rate_limited…) s’appliquent à toutes les routes ; voir Erreurs.