From 62c67c08ad74a0625eccf29d94f1b27ca1abc988 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 23:24:44 +0000 Subject: [PATCH] Document PATCH /beneficiaries/{beneficiary_id}/bio_fields (CP-4666) Change a Contact's Bio answers: text, number, date, time and telephone fields, Dropdowns, date of birth and address, up to 50 at once and all or none. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xpNYXk28wfHyDchMm4 --- openapi.yaml | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 9 +++++ 2 files changed, 106 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index c3236bf..c510261 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4842,6 +4842,103 @@ paths: "404": $ref: '#/components/responses/NotFound' + /beneficiaries/{beneficiary_id}/bio_fields: + patch: + tags: [Beneficiaries] + summary: Change a Contact's Bio answers + operationId: updateContactBioFields + description: | + Changes a Contact's answers to some of their Bio fields: the fields on their Contact Forms, such as + School, Gender or Date of birth. This is what a cell of the **Bio per Contact** and **Custom Table** + views saves in Edit mode, and it goes through the same save as the Contact's Edit Bio page. + + Each field is named by `field_class` and `field_id`: + + - `CustomField`: a text, number, date, time or telephone field, by its id. `value` is a string. + Dates may be `YYYY-MM-DD` and times `HH:MM` (24-hour). + - `RatioSet`: a Dropdown, by its id. `value` is an array of answer (Sub Ratio) ids; `[]` clears it. + A Dropdown that allows one answer keeps the first. + - `BeneficiaryColumn`: `date_of_birth` (`YYYY-MM-DD`) or `address`. `value` is a string. + + A blank string clears an answer. Every field is checked before anything is saved, so one refused + field leaves the Contact unchanged. A field is refused when you can't edit the Contact (403), Field + Visibility hides it from you (403), it doesn't exist (404), it isn't on any of the Contact's own + Contact Forms, it is a file, signature, weekly availability or extended table field or an email the + organisation messages Contacts through, a mandatory field is left empty, or a Dropdown answer isn't + one of its choices (422). + security: [{tokenAuth: []}] + parameters: + - name: beneficiary_id + in: path + required: true + description: The Contact (Beneficiary) + schema: + type: integer + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [fields] + properties: + fields: + type: array + minItems: 1 + maxItems: 50 + items: + type: object + required: [field_class, field_id, value] + properties: + field_class: + type: string + enum: [CustomField, RatioSet, BeneficiaryColumn] + field_id: + oneOf: + - type: integer + - type: string + enum: [date_of_birth, address] + value: + oneOf: + - type: string + - type: array + items: + type: integer + example: + fields: + - { field_class: CustomField, field_id: 412, value: Lydiard Park Academy } + - { field_class: RatioSet, field_id: 37, value: [215] } + - { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" } + responses: + "200": + description: The answers were saved. Each value is what the field now shows (Dropdown answers joined with ", "). + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + type: object + properties: + field_class: { type: string } + field_id: { type: string } + value: { type: string } + example: + data: + - { field_class: CustomField, field_id: "412", value: Lydiard Park Academy } + - { field_class: RatioSet, field_id: "37", value: Female } + - { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" } + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /beneficiaries/{beneficiary_id}/staff_suggestions: get: tags: [Staff Matching] diff --git a/server.js b/server.js index 2f30914..f43aa3f 100644 --- a/server.js +++ b/server.js @@ -1924,6 +1924,15 @@ function buildDocsPage() { { code: "200", cls: "response-2xx", desc: "Contact created" }, { code: "422", cls: "response-4xx", desc: "Validation failed (name and owner_id are required), a field hidden from you by Field Visibility was sent, or a Weekly availability answer can't be read" } ], "Required fields: beneficiary.name, beneficiary.owner_id (User ID of the record owner). Submit custom field values as custom_fields: {\"field_id\": \"value\"}. A Weekly availability field takes a list of days and times: [{\"day\": \"monday\", \"from\": \"15:30\", \"to\": \"18:00\"}], times HH:MM in 15-minute steps with to after from; overlapping times on a day are joined. Setting a field hidden from you by Field Visibility is refused with 422 and an errors list naming it.")} + ${endpointCard("PATCH", "/beneficiaries/{beneficiary_id}/bio_fields", "Change a Contact's Bio answers", true, [ + { name: "beneficiary_id", in: "path", type: "integer", required: true, desc: "Contact ID" }, + { name: "fields", in: "body", type: "array", required: true, desc: "1 to 50 of {field_class, field_id, value}" } + ], [ + { code: "200", cls: "response-2xx", desc: "Saved. data lists each field with what it now shows" }, + { code: "403", cls: "response-4xx", desc: "You can't edit the Contact, or Field Visibility hides a field from you" }, + { code: "404", cls: "response-4xx", desc: "The Contact or a field wasn't found" }, + { code: "422", cls: "response-4xx", desc: "A field isn't on the Contact's forms or can't be changed here, a mandatory field was left empty, or a Dropdown answer isn't one of its choices" } + ], "Changes a Contact's answers to Bio fields, as a cell of Bio per Contact or a Custom Table does in Edit mode. field_class is CustomField (a text, number, date, time or telephone field, by id, with a string value), RatioSet (a Dropdown, by id, with an array of answer ids; [] clears it) or BeneficiaryColumn (date_of_birth or address). Dates may be YYYY-MM-DD and times HH:MM. A blank string clears an answer. Every field is checked before anything is saved, so one refused field leaves the Contact unchanged. File, signature, weekly availability and extended table fields are changed on the Contact's Edit Bio page.")} ${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" } ], [