From d9ec1ae84fbe0947fe3a60009c5108d5c5fd72a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 09:06:57 +0000 Subject: [PATCH] CP-8987 Document an organisation's usage endpoints GET /organisations/{organisation_id}/usage and .../usage/history, the Our Account > Usage page over API v2: usage against each allowance this month with charges so far and expected, and the previous 12 months. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xo9M1eCaEb77Ww9z3K --- openapi.yaml | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 26 +++++++ 2 files changed, 231 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 07f9753..870598a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -308,6 +308,13 @@ tags: Seats per Colleague: which seat each colleague holds on each of an Organisation's current Contracts, and changing one. A colleague's roles decide the lowest seat (Billing Role) they need on Role-based Pricing. Only the Organisation's admins can change seats. + - name: Usage + description: | + An Organisation's usage against the allowances in its plan: Contacts, Stories (survey + responses), automation runs, API and integration runs, file storage uploaded, SMS and email. + Shows the charge so far this month, the charge expected by the end of the month if usage + carries on at the same rate, and the 12 months before. Prices are the Organisation's own. + This is the Usage page under Our Account › Usage. Organisation Admins and Makerble staff can read it. - name: Guidance Panels description: | The Show/Hide Guidance introduction at the top of each Manage page. Makerble staff with System @@ -12334,6 +12341,91 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /organisations/{organisation_id}/usage: + parameters: + - $ref: '#/components/parameters/OrganisationId' + get: + tags: [Usage] + summary: Get an Organisation's usage this month + description: | + This calendar month's usage (UK time) of each thing an Organisation (Charity) is charged for + when it goes over an allowance, with the allowance, how much of it is used, the usage expected + by the end of the month if it carries on at the same rate, the price over the allowance, and the + charge so far and expected. Amounts are in the currency the Organisation is billed in, before VAT. + + A usage type is listed when the Organisation used it this month or has an allowance for it. + `status` is `within`, `near` (80% or more of the allowance), `over`, `waived` (a waiver means it + isn't charged this month), or null when there is no allowance (charged from the first one). + File storage is what was uploaded this month, in GB, not what is stored. Contacts are the + current total, archived ones included; while it is over the allowance the bundle is charged + every month. A charge is null when no price is set for usage over the allowance, and then + `unpriced` is true and the totals leave it out. + + This is the Usage page under Our Account › Usage. Organisation Admins and Makerble staff can + read it. Going over an allowance never stops anyone working. + operationId: getOrganisationUsage + security: [{tokenAuth: []}] + responses: + "200": + description: This month's usage + content: + application/json: + schema: + $ref: '#/components/schemas/OrganisationUsage' + example: + organisation_id: 42 + month: "2026-11" + currency: GBP + charge_so_far: 50 + expected_charge: 1060 + unpriced: false + data: + - usage_type: story_created + name: Stories (survey responses) + unit: Stories + quantity: 5000 + allowance: 6000 + percent_used: 83 + status: near + expected_quantity: 15000 + unit_price: 0.1 + per_quantity: 1 + tier_min: null + tier_max: null + charge_so_far: 0 + expected_charge: 900 + note: null + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + + /organisations/{organisation_id}/usage/history: + parameters: + - $ref: '#/components/parameters/OrganisationId' + get: + tags: [Usage] + summary: Get an Organisation's usage in the previous 12 months + description: | + The 12 calendar months before this one, newest first, from the usage charges worked out at the + end of each month: each usage type the Organisation was charged for, its usage, allowance and + charge, after any waivers. A month with no usage charges has an empty `usage` list. Amounts are + in the currency the Organisation is billed in, before VAT; the usage bills show what was invoiced. + Organisation Admins and Makerble staff can read it. + operationId: getOrganisationUsageHistory + security: [{tokenAuth: []}] + responses: + "200": + description: The previous 12 months + content: + application/json: + schema: + $ref: '#/components/schemas/OrganisationUsageHistory' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + /organisations/{organisation_id}/age_bands: parameters: - $ref: '#/components/parameters/OrganisationId' @@ -21384,6 +21476,119 @@ components: items: $ref: '#/components/schemas/SeatColleague' + OrganisationUsage: + type: object + properties: + organisation_id: + type: integer + month: + type: string + description: The calendar month, YYYY-MM. + currency: + type: string + description: The currency the Organisation is billed in (GBP when no exchange rate is stored). + charge_so_far: + type: number + expected_charge: + type: number + description: The charge by the end of the month if usage carries on at the rate so far. + unpriced: + type: boolean + description: True when some usage over an allowance has no price set, so the totals leave it out. + data: + type: array + items: + $ref: '#/components/schemas/OrganisationUsageType' + + OrganisationUsageType: + type: object + properties: + usage_type: + type: string + enum: [sms_sent, sms_received, sms_line_rental, email_sent, email_received, file_upload_bytes, automation_run, story_created, api_integration_run, contacts_snapshot] + name: + type: string + description: The name shown on the Usage page, e.g. "Stories (survey responses)". + unit: + type: string + description: The unit of quantity, allowance and per_quantity, e.g. Stories, segments, GB. + quantity: + type: number + allowance: + type: number + nullable: true + description: How much can be used before being charged; 0 means charged from the first one, null means not set. + percent_used: + type: integer + nullable: true + status: + type: string + nullable: true + enum: [within, near, over, waived, null] + expected_quantity: + type: number + unit_price: + type: number + nullable: true + description: The price of each per_quantity over the allowance, or of the bundle (tier_min to tier_max) the expected quantity falls in. + per_quantity: + type: number + nullable: true + tier_min: + type: integer + nullable: true + tier_max: + type: integer + nullable: true + charge_so_far: + type: number + nullable: true + expected_charge: + type: number + nullable: true + note: + type: string + nullable: true + description: How the usage type is counted, for file storage and Contacts. + + OrganisationUsageHistory: + type: object + properties: + organisation_id: + type: integer + data: + type: array + items: + type: object + properties: + month: + type: string + currency: + type: string + charge: + type: number + usage: + type: array + items: + type: object + properties: + usage_type: + type: string + name: + type: string + unit: + type: string + quantity: + type: number + allowance: + type: number + nullable: true + charge: + type: number + nullable: true + waived: + type: boolean + ApiKey: type: object properties: diff --git a/server.js b/server.js index 8657f2b..0788c70 100644 --- a/server.js +++ b/server.js @@ -975,6 +975,7 @@ function buildDocsPage() { GETEventbrite POSTAPI keys GETSeats + GETUsage POSTAnnouncements POSTWelcome Tours @@ -3950,6 +3951,31 @@ function buildDocsPage() { + +
+
Billing
+

Usage

+
+

An Organisation's usage against the allowances in its plan: Contacts, Stories (survey responses), automation runs, API and integration runs, file storage uploaded, SMS and email. This is the Our Account › Usage page. For this calendar month it gives each usage type's quantity so far, allowance, percent_used, status (within, near at 80% or more, over or waived), the quantity expected by the end of the month at the current rate, the price over the allowance, and the charge so far and expected. Amounts are in the Organisation's billing currency, before VAT, and use its own prices.

+

File storage is what was uploaded this month, in GB, not what is stored. Contacts are the current total, archived ones included, and their bundle is charged every month the total is over the allowance. A charge is null when no price is set, and unpriced is then true. Going over an allowance never stops anyone working.

+

Only the Organisation's admins (and Makerble staff) can read it; anyone else gets 404.

+
+
+ ${endpointCard("GET", "/organisations/{organisation_id}/usage", "Get an Organisation's usage this month", true, [ + { name: "organisation_id", in: "path", type: "integer", required: true, desc: "The Organisation (Charity) ID" } + ], [ + { code: "200", cls: "response-2xx", desc: "month, currency, charge_so_far, expected_charge, unpriced, and data: one entry per usage type used or allowed, with quantity, allowance, percent_used, status, expected_quantity, price, charge_so_far and expected_charge" }, + { code: "404", cls: "response-4xx", desc: "Not an admin of this Organisation" } + ])} + ${endpointCard("GET", "/organisations/{organisation_id}/usage/history", "Get an Organisation's usage in the previous 12 months", true, [ + { name: "organisation_id", in: "path", type: "integer", required: true, desc: "The Organisation (Charity) ID" } + ], [ + { code: "200", cls: "response-2xx", desc: "data: the 12 months before this one, newest first, each with its currency, charge and usage (quantity, allowance, charge and waived per usage type)" }, + { code: "404", cls: "response-4xx", desc: "Not an admin of this Organisation" } + ])} +
+
+
Integrations