Skip to content

Budget ​

Routes are relative to <PUBLIC_BASE_URL>; request and response bodies are JSON unless stated otherwise. Authentication, scopes, pagination and the error format are described in the REST API guides.

GET /api/v1/billing ​

Read the budget

The plan, the balances of the month, the automatic top-up, the current and closed statements, and the real catalog, as the control plane serves them. A standalone instance answers linked: false; an unreachable control plane answers reachable: false, with the last known budget.

Access — Member session or API key with scope admin:read (administrator role required).

Responses

200 — The budget.

FieldTypeRequired
linkedbooleanyes
reachablebooleanyes
fetchedAtstring | nullyes
billingobject | nullyes
JSON Schema
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 — No valid session or API key (auth.unauthenticated).

403 — Refused: insufficient role (auth.forbidden), missing scope (api_key.scope_missing, details.required names it) or a route closed to API keys (api_key.session_required).

429 — The API key exceeded its rate limit (api_key.rate_limited); Retry-After says when to retry.

POST /api/v1/billing/orders ​

Place a billing order

Buy a pack, change plan (effective on the 1st of next month), set the automatic top-up or the alerts. No online payment: a purchase goes on the statement. Idempotent by ref. Refused to an API key: buying is a person’s act. Recorded in the audit log.

Access — Member session or API key with scope admin:write (administrator role required).

Request body (application/json)

Type : object

JSON Schema
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" ]
    }
  ]
}

Responses

200 — The order, and the budget it leaves.

FieldTypeRequired
refstringyes
typestringyes
effectiveOnstring | nullyes
duplicatebooleanyes
billingobjectyes
JSON Schema
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 — The request does not match its schema.

401 — No valid session or API key (auth.unauthenticated).

403 — Refused: insufficient role (auth.forbidden), missing scope (api_key.scope_missing, details.required names it) or a route closed to API keys (api_key.session_required).

429 — The API key exceeded its rate limit (api_key.rate_limited); Retry-After says when to retry.

Error codes — 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. The common codes (request.bad_request, auth.unauthenticated, api_key.scope_missing, api_key.rate_limited…) apply to every route; see Errors.

Loop & Roll — the workflow builder for email.