From 44e8a2982e94ac73ce85eeaacd7c32d1c71ef052 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 06:38:22 +0000 Subject: [PATCH 1/3] Document the Field Visibility endpoints Adds GET, PATCH and PUT /field_visibility_rules to openapi.yaml under a new Field Visibility tag, with a matching section of endpoint cards and a nav link on the docs page. CP-8788. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xob9JFU7VBHYg7vQnM --- openapi.yaml | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 28 ++++++++ 2 files changed, 214 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index e412f74..ca05388 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -254,6 +254,11 @@ tags: description: | An Organisation's custom rules for finding duplicate Contacts: which fields must be identical, and whether matches are merged automatically or suggested for review. + - name: Field Visibility + description: | + Who can see each Contact field (Settings > Field Visibility). A field is either visible to + everyone who can view the Contact (default) or Restricted to users in chosen Teams or on + chosen Projects. Also sets whether external guest users see the field. - name: Checklists description: | An Organisation's lists of actions it expects to be done for each Contact (Beneficiary), @@ -7939,6 +7944,187 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /field_visibility_rules: + get: + tags: [Field Visibility] + summary: List who can see each Contact field + description: | + The Field Visibility settings page. Every Contact field comes back once, whichever Contact + forms it is on. `field_class_name` and `field_key` identify it: `CustomField` or `RatioSet` + with its id for a form field or dropdown, `BeneficiaryColumn` with the column name for a + built-in field such as `date_of_birth`, `CustomFieldDefinition` with its id for a Custom + Forms field. `visibility` is `default` (everyone who can view the Contact) or `restricted`: + only users in one of its `teams`, or colleagues in any role on one of its `projects`, see the + value; Organisation Admins get no exception. A restriction never gives anyone access to a + Contact they can't already view. `visible_to_guests` says whether external guest users added + through a Contact's Override see the field. Requires an Organisation Admin (editor). + `last_synced_datetime` isn't supported: a field returned to default has no record to sync. + operationId: listFieldVisibilityRules + security: [{tokenAuth: []}] + parameters: + - name: charity_id + in: query + required: true + schema: + type: integer + description: The Organisation (Charity) ID + - name: search + in: query + schema: + type: string + description: Part of the field name + - name: form + in: query + schema: + type: string + description: Only fields on this Contact form (its name) + - name: visibility + in: query + schema: + type: string + enum: [default, restricted] + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + responses: + "200": + description: Paginated list of Contact fields + content: + application/json: + example: + page: 1 + page_size: 1 + page_count: 1 + total_count: 1 + data: + - field_class_name: CustomField + field_key: "481" + name: NHS number + forms: [Person being referred] + visibility: restricted + teams: [{ id: 9, name: Beacons }] + projects: [{ id: 33, name: WAY Beacons CYP }] + visible_to_guests: false + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user isn't an Organisation Admin + "404": + $ref: '#/components/responses/NotFound' + patch: + tags: [Field Visibility] + summary: Change who can see Contact fields + description: | + Change the settings of one or more Contact fields, all together or not at all. For each + field, `visibility: restricted` needs at least one of `team_ids` or `project_ids` (Teams and + Projects of the same Organisation); `visibility: default` removes the restriction. + `visible_to_guests` shows or hides the field from external guest users. Leave a key out to + keep that setting. Errors name the field, e.g. "NHS number: Choose at least one Team or + project for a restricted field". Requires an Organisation Admin (editor). + operationId: updateFieldVisibilityRules + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [charity_id, rules] + properties: + charity_id: { type: integer } + rules: + type: array + items: + type: object + required: [field_class_name, field_key] + properties: + field_class_name: { type: string, enum: [CustomField, RatioSet, BeneficiaryColumn, CustomFieldDefinition] } + field_key: { type: string, description: The field id, or the column name for a BeneficiaryColumn } + visibility: { type: string, enum: [default, restricted] } + team_ids: { type: array, items: { type: integer } } + project_ids: { type: array, items: { type: integer } } + visible_to_guests: { type: boolean } + example: + charity_id: 12 + rules: + - { field_class_name: CustomField, field_key: "481", visibility: restricted, team_ids: [9], project_ids: [33], visible_to_guests: false } + responses: + "200": + description: The changed fields + content: + application/json: + example: + data: + - field_class_name: CustomField + field_key: "481" + name: NHS number + forms: [Person being referred] + visibility: restricted + teams: [{ id: 9, name: Beacons }] + projects: [{ id: 33, name: WAY Beacons CYP }] + visible_to_guests: false + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user isn't an Organisation Admin + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + put: + tags: [Field Visibility] + summary: Change who can see Contact fields (same as PATCH) + description: The same as PATCH /field_visibility_rules. + operationId: replaceFieldVisibilityRules + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [charity_id, rules] + properties: + charity_id: { type: integer } + rules: + type: array + items: + type: object + required: [field_class_name, field_key] + properties: + field_class_name: { type: string, enum: [CustomField, RatioSet, BeneficiaryColumn, CustomFieldDefinition] } + field_key: { type: string, description: The field id, or the column name for a BeneficiaryColumn } + visibility: { type: string, enum: [default, restricted] } + team_ids: { type: array, items: { type: integer } } + project_ids: { type: array, items: { type: integer } } + visible_to_guests: { type: boolean } + example: + charity_id: 12 + rules: + - { field_class_name: CustomField, field_key: "481", visibility: restricted, team_ids: [9], project_ids: [33], visible_to_guests: false } + responses: + "200": + description: The changed fields + content: + application/json: + example: + data: + - field_class_name: CustomField + field_key: "481" + name: NHS number + forms: [Person being referred] + visibility: restricted + teams: [{ id: 9, name: Beacons }] + projects: [{ id: 33, name: WAY Beacons CYP }] + visible_to_guests: false + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user isn't an Organisation Admin + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /merge_rules/{id}: get: tags: [Merge Rules] diff --git a/server.js b/server.js index e5e83e9..b3a4126 100644 --- a/server.js +++ b/server.js @@ -950,6 +950,7 @@ function buildDocsPage() { POSTFramework Sets POSTSuggested Merges GETDuplicate Contacts + GETField Visibility POSTChecklists POSTAdd Metric To POSTCohort Trackers @@ -2496,6 +2497,33 @@ function buildDocsPage() { + +
+
Contacts
+

Field Visibility

+
+

Who can see each Contact field, as the Field Visibility settings page shows it. A field is default (everyone who can view the Contact) or restricted: only users in one of its Teams, or colleagues in any role on one of its Projects, see the value. Organisation Admins get no exception, and a restriction never gives anyone access to a Contact they can't already view. visible_to_guests says whether external guest users added through a Contact's Override see the field. Only Organisation Admins can read or change these settings.

+
+
+ ${endpointCard("GET", "/field_visibility_rules", "List who can see each Contact field", true, [ + { name: "charity_id", type: "integer", required: true, desc: "The Organisation ID" }, + { name: "search", type: "string", required: false, desc: "Part of the field name" }, + { name: "form", type: "string", required: false, desc: "Only fields on this Contact form (its name)" }, + { name: "visibility", type: "string", required: false, desc: "default or restricted" }, + { name: "page", type: "integer", required: false, desc: "Page number" }, + { name: "per_page", type: "integer", required: false, desc: "Records per page (at most 200)" } + ], [ + { code: "200", cls: "response-2xx", desc: "Paginated list: field_class_name, field_key, name, forms, visibility, teams [{id, name}], projects [{id, name}], visible_to_guests" }, + { code: "403", cls: "response-4xx", desc: "Not an Organisation Admin" } + ])} + ${endpointCard("PATCH", "/field_visibility_rules", "Change who can see Contact fields", true, [], [ + { code: "200", cls: "response-2xx", desc: "data: the changed fields" }, + { code: "403", cls: "response-4xx", desc: "Not an Organisation Admin" }, + { code: "422", cls: "response-4xx", desc: "{errors}: a Restricted field with no Team or Project, a Team or Project from another Organisation, or an unknown field. Nothing is saved" } + ], "Body: charity_id and rules, a list of fields, each with field_class_name and field_key (from the list) and any of visibility, team_ids, project_ids, visible_to_guests. A Restricted field needs at least one Team or Project. Anything not sent is kept. PUT does the same.")} +
+
+
Contacts
From 9b3be455a88028af2161369148898c59c479dfa6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 09:45:02 +0000 Subject: [PATCH 2/3] Document restricted fields in contact responses Field Visibility hides a field from some users: list it with restricted: true and a null value, null hidden built-in fields and name them in restricted_fields, and refuse a write to a hidden field with 422. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xob9JFU7VBHYg7vQnM --- openapi.yaml | 32 ++++++++++++++++++++++++++++++-- server.js | 10 +++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index ca05388..c7ca3ea 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1428,6 +1428,10 @@ paths: description: | Returns all Contacts visible to the authenticated user. Filter by `charity_id` or `project_id`. Response includes `custom_fields` defined by the Beneficiary Category. + + Fields the Organisation's **Field Visibility** settings hide from you are not returned: a hidden custom field + comes back with `restricted: true` and `value: null`, and a hidden built-in field (`dob`, `mobile`, `email`, + `address`) is `null` and named in `restricted_fields`. operationId: listBeneficiaries security: [{tokenAuth: []}] parameters: @@ -1461,6 +1465,10 @@ paths: Creates a new Contact. Required: `name`, `owner_id`. Call `GET /beneficiary_types` for `beneficiary_type_id` values and `GET /custom_fields` for available custom field IDs. + + Setting a field the Organisation's Field Visibility settings hide from you (a custom field, a dropdown answer + in `sub_ratio_ids`, `date_of_birth` or `address`) is refused with `422` and an `errors` list naming each field; + no Contact is created. operationId: createBeneficiary security: [{tokenAuth: []}] requestBody: @@ -1630,7 +1638,9 @@ paths: get: tags: [Beneficiaries] summary: Get advanced custom fields for all Beneficiaries - description: Returns the per-record custom field values for all Beneficiaries. + description: | + Returns the per-record custom field values (Custom Forms answers) for all Beneficiaries. + An answer the Organisation's Field Visibility settings hide from you comes back with `restricted: true` and `value: null`. operationId: listBeneficiaryAdvancedCustomFields security: [{tokenAuth: []}] parameters: @@ -3335,6 +3345,8 @@ paths: moment, not just the fields that changed. Compare two Versions' `full_object` to see what changed. For a Story, `full_object` is `{schema_version, story, privacy_settings, contact_ids, outcome_ids, label_ids, media, answers}`, where each answer carries the survey question's label as it was then. + For a Contact, fields the Organisation's Field Visibility settings hide from you are `null` in `full_object` + and named in `restricted_fields`. Same permissions as `GET /versions`. operationId: getVersion security: [{tokenAuth: []}] @@ -15828,6 +15840,12 @@ components: type: array items: $ref: '#/components/schemas/CustomFieldValue' + restricted_fields: + type: array + items: + type: string + description: Built-in fields (`dob`, `mobile`, `email`, `address`) hidden from you by Field Visibility; each is returned as null + example: ["mobile"] BeneficiaryCreateRequest: type: object @@ -15971,8 +15989,12 @@ components: example: "text" description: "Field type: text, date, time, file, etc." value: - description: Field value (string for most types; object for file attachments) + description: Field value (string for most types; object for file attachments). Null when `restricted` is true. example: "Employed" + restricted: + type: boolean + description: Present and true when Field Visibility hides this field from you; `value` is then null, whether or not it has an answer + example: true Story: allOf: @@ -16796,6 +16818,12 @@ components: type: object additionalProperties: true description: Snapshot of every field of the record as saved in this Version + restricted_fields: + type: array + items: + type: string + description: Fields of a Contact hidden from you by Field Visibility, nulled in `full_object` (column names, or custom field names) + example: ["date_of_birth", "NHS number"] PaginatedVersions: allOf: diff --git a/server.js b/server.js index b3a4126..cea9313 100644 --- a/server.js +++ b/server.js @@ -1501,17 +1501,17 @@ function buildDocsPage() { ], [ { code: "200", cls: "response-2xx", desc: "Paginated list of Contacts including custom fields" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" } - ])} + ], "Fields hidden from you by Field Visibility come back with restricted: true and a null value (custom fields), or null and named in restricted_fields (dob, mobile, email, address).")} ${endpointCard("GET", "/beneficiaries/{id}", "Get a single Contact", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Contact ID" } ], [ { code: "200", cls: "response-2xx", desc: "Full Contact profile with all custom fields" }, { code: "404", cls: "response-4xx", desc: "Not found" } - ], "Opening a Contact this way is recorded in its Access Log, the audit trail of who has viewed it, under your name and marked as via the API (or via MCP when the Makerble MCP server sends X-Makerble-Client: makerble-mcp). Views less than 30 minutes apart are counted together. Use GET /beneficiaries when you only need to find or scan Contacts.")} + ], "Opening a Contact this way is recorded in its Access Log, the audit trail of who has viewed it, under your name and marked as via the API (or via MCP when the Makerble MCP server sends X-Makerble-Client: makerble-mcp). Views less than 30 minutes apart are counted together. Use GET /beneficiaries when you only need to find or scan Contacts. Fields hidden from you by Field Visibility come back with restricted: true and a null value (custom fields), or null and named in restricted_fields (dob, mobile, email, address).")} ${endpointCard("POST", "/beneficiaries", "Create a Contact", true, [], [ { code: "200", cls: "response-2xx", desc: "Contact created" }, - { code: "422", cls: "response-4xx", desc: "Validation failed (name and owner_id are required)" } - ], "Required fields: beneficiary.name, beneficiary.owner_id (User ID of the record owner). Submit custom field values as custom_fields: {\"field_id\": \"value\"}.")} + { code: "422", cls: "response-4xx", desc: "Validation failed (name and owner_id are required), or a field hidden from you by Field Visibility was sent" } + ], "Required fields: beneficiary.name, beneficiary.owner_id (User ID of the record owner). Submit custom field values as custom_fields: {\"field_id\": \"value\"}. Setting a field hidden from you by Field Visibility is refused with 422 and an errors list naming it.")} ${endpointCard("GET", "/beneficiaries/{beneficiary_id}/summary", "Get the AI summary of a Contact (SummaryMaker)", true, [ { name: "beneficiary_id", in: "path", type: "integer", required: true, desc: "Contact ID" } ], [ @@ -1912,7 +1912,7 @@ function buildDocsPage() { ], [ { code: "200", cls: "response-2xx", desc: "The Version, including full_object — every field as saved at that moment" }, { code: "404", cls: "response-4xx", desc: "Not found, or not visible to you" } - ])} + ], "For a Contact, fields hidden from you by Field Visibility are null in full_object and named in restricted_fields.")}
From 3d69176d1aba51b2b1471e7b5bc1a346500bdd8c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 15:56:47 +0000 Subject: [PATCH 3/3] Say restricted is always sent on contact custom fields Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xob9JFU7VBHYg7vQnM --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index c7ca3ea..51e8c6a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -15993,7 +15993,7 @@ components: example: "Employed" restricted: type: boolean - description: Present and true when Field Visibility hides this field from you; `value` is then null, whether or not it has an answer + description: True when Field Visibility hides this field from you; `value` is then null, whether or not it has an answer example: true Story: