From 38a979bb23129e9978b2e1c1ee2c24c8c728dd16 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 10:47:30 +0000 Subject: [PATCH 1/2] Document household counts and a Contact's household CP-9067: GET /organisations/{organisation_id}/household_counts and the household field on Contacts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xnLgs5o5gPCckn5x8V --- openapi.yaml | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 9 ++++++ 2 files changed, 100 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index d24e58e..3e0aee1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -21516,6 +21516,80 @@ paths: "404": $ref: '#/components/responses/NotFound' + /organisations/{organisation_id}/household_counts: + parameters: + - $ref: '#/components/parameters/OrganisationId' + get: + tags: [Beneficiaries] + summary: Count the households an Organisation's Contacts are in + description: | + What the households panel on Manage Contacts shows: how many households (families) the + Organisation's Contacts are in, and what those households are made up of. A household is a + group of Contacts linked, directly or through other Contacts, by Relationships in Relationship + Categories that count as a household (`counts_as_household`). Households reflect the + relationships ongoing today. + + Send `filter_data` (the same filters as Manage Contacts) or `project_id` to count only those + Contacts' households, e.g. `filter_data[created_at_from]=01/01/2026 - 31/03/2026` for Contacts + added in a date range, or `filter_data[stories_created_at_from]=…` for Contacts with activity in + it. A household counts when at least one of its members matches. Only Contacts you may see are + counted, in the matches and in each household's make-up. + operationId: countHouseholds + security: [{tokenAuth: []}] + parameters: + - name: filter_data + in: query + style: deepObject + explode: true + schema: + type: object + additionalProperties: true + description: Manage Contacts filters choosing the Contacts, e.g. `filter_data[project_ids][]=572` + - name: project_id + in: query + schema: + type: integer + description: Count only this Project's Contacts + responses: + "200": + description: Households and their make-up, most common make-up first + content: + application/json: + schema: + type: object + properties: + total_households: { type: integer } + contacts_in_households: + type: integer + description: How many of the matching Contacts are in a household + data: + type: array + items: + type: object + properties: + make_up: + type: string + example: 1 Child + 2 Parents + roles: + type: object + additionalProperties: { type: integer } + example: { Child: 1, Parent: 2 } + households: { type: integer } + example: + total_households: 9 + contacts_in_households: 27 + data: + - make_up: 1 Child + 1 Parent + roles: { Child: 1, Parent: 1 } + households: 6 + - make_up: 2 Children + 2 Parents + roles: { Child: 2, Parent: 2 } + households: 3 + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + /albums/{album_id}/age_bands: parameters: - name: album_id @@ -29455,6 +29529,23 @@ components: type: array description: What the Contact needs a specialist in, each Essential or Desirable, added by hand or from a form answer items: { $ref: '#/components/schemas/RequiredSkill' } + household: + description: | + The household (family) the Contact is in, from Relationships in Relationship Categories that + count as a household, or null when they are in none + nullable: true + type: object + properties: + id: { type: integer } + reference: + type: string + description: As shown on Manage Contacts, e.g. H123 + example: H123 + role: + type: string + description: The titles the Contact holds in their family relationships, e.g. Parent, or Child / Parent + example: Parent + members_count: { type: integer, example: 4 } BeneficiaryDetail: description: A Contact (Beneficiary) as returned by `GET /beneficiaries/{id}` and `POST /beneficiaries`. The list endpoint leaves out `weekly_availability`. diff --git a/server.js b/server.js index 51e0a54..3940bfc 100644 --- a/server.js +++ b/server.js @@ -6181,6 +6181,15 @@ function buildDocsPage() { { code: "200", cls: "response-2xx", desc: "source, total_count and data: [{band, contacts}], with \"Under X\", \"Date of birth in the future\" and \"No date of birth\" only when someone is in them" }, { code: "404", cls: "response-4xx", desc: "Not in this Organisation, or the Album or Project isn't one of its own" } ])} + ${endpointCard("GET", "/organisations/{organisation_id}/household_counts", "Count the households an Organisation's Contacts are in", true, [ + { name: "organisation_id", in: "path", type: "integer", required: true, desc: "The Organisation (Charity) ID" }, + { name: "filter_data", type: "object", required: false, desc: "Manage Contacts filters choosing the Contacts, e.g. filter_data[created_at_from]=01/01/2026 - 31/03/2026" }, + { name: "project_id", type: "integer", required: false, desc: "Count only this Project's Contacts" } + ], [ + { code: "200", cls: "response-2xx", desc: "total_households, contacts_in_households and data: [{make_up, roles, households}], most common make-up first" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "404", cls: "response-4xx", desc: "Not in this Organisation" } + ], "The households panel on Manage Contacts. Contacts linked by Relationships in categories that count as a household, directly or through other Contacts, are one household. A household counts when one of its members matches the filters; only Contacts you may see are counted.")} ${endpointCard("GET", "/albums/{album_id}/age_bands", "Get an Album's age bands", true, [ { name: "album_id", in: "path", type: "integer", required: true, desc: "The Album's (Bundle's) ID" } ], [ From db2331645c629567cfe520aec207abfbf250f269 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 11:51:01 +0000 Subject: [PATCH 2/2] Document hidden_contacts on household counts CP-9067: each make-up counts every member, and hidden_contacts says how many the user doesn't have permission to see. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xnLgs5o5gPCckn5x8V --- openapi.yaml | 16 ++++++++++++++-- server.js | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 3e0aee1..6315ad2 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -21532,8 +21532,9 @@ paths: Send `filter_data` (the same filters as Manage Contacts) or `project_id` to count only those Contacts' households, e.g. `filter_data[created_at_from]=01/01/2026 - 31/03/2026` for Contacts added in a date range, or `filter_data[stories_created_at_from]=…` for Contacts with activity in - it. A household counts when at least one of its members matches. Only Contacts you may see are - counted, in the matches and in each household's make-up. + it. A household counts when at least one of its members matches, and only Contacts you may see + are matched. Each make-up counts every member, so the numbers are right; `hidden_contacts` + says how many of them you don't have permission to see. operationId: countHouseholds security: [{tokenAuth: []}] parameters: @@ -21562,6 +21563,11 @@ paths: contacts_in_households: type: integer description: How many of the matching Contacts are in a household + hidden_contacts: + type: integer + description: | + How many members of the counted households you don't have permission to see. They + are included in each make-up, so the numbers are right, but never named. data: type: array items: @@ -21575,16 +21581,22 @@ paths: additionalProperties: { type: integer } example: { Child: 1, Parent: 2 } households: { type: integer } + hidden_contacts: + type: integer + description: Members of these households you don't have permission to see example: total_households: 9 contacts_in_households: 27 + hidden_contacts: 1 data: - make_up: 1 Child + 1 Parent roles: { Child: 1, Parent: 1 } households: 6 + hidden_contacts: 0 - make_up: 2 Children + 2 Parents roles: { Child: 2, Parent: 2 } households: 3 + hidden_contacts: 1 "401": $ref: '#/components/responses/Unauthorized' "404": diff --git a/server.js b/server.js index 3940bfc..0744594 100644 --- a/server.js +++ b/server.js @@ -6186,10 +6186,10 @@ function buildDocsPage() { { name: "filter_data", type: "object", required: false, desc: "Manage Contacts filters choosing the Contacts, e.g. filter_data[created_at_from]=01/01/2026 - 31/03/2026" }, { name: "project_id", type: "integer", required: false, desc: "Count only this Project's Contacts" } ], [ - { code: "200", cls: "response-2xx", desc: "total_households, contacts_in_households and data: [{make_up, roles, households}], most common make-up first" }, + { code: "200", cls: "response-2xx", desc: "total_households, contacts_in_households, hidden_contacts and data: [{make_up, roles, households, hidden_contacts}], most common make-up first" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "404", cls: "response-4xx", desc: "Not in this Organisation" } - ], "The households panel on Manage Contacts. Contacts linked by Relationships in categories that count as a household, directly or through other Contacts, are one household. A household counts when one of its members matches the filters; only Contacts you may see are counted.")} + ], "The households panel on Manage Contacts. Contacts linked by Relationships in categories that count as a household, directly or through other Contacts, are one household. A household counts when one of its members matches the filters. Each make-up counts every member; hidden_contacts says how many you don't have permission to see.")} ${endpointCard("GET", "/albums/{album_id}/age_bands", "Get an Album's age bands", true, [ { name: "album_id", in: "path", type: "integer", required: true, desc: "The Album's (Bundle's) ID" } ], [