Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 216 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,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),
Expand Down Expand Up @@ -1628,6 +1633,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:
Expand Down Expand Up @@ -1661,6 +1670,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:
Expand Down Expand Up @@ -1830,7 +1843,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:
Expand Down Expand Up @@ -3535,6 +3550,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: []}]
Expand Down Expand Up @@ -8144,6 +8161,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]
Expand Down Expand Up @@ -16479,6 +16677,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
Expand Down Expand Up @@ -16622,8 +16826,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: True when Field Visibility hides this field from you; `value` is then null, whether or not it has an answer
example: true

Story:
allOf:
Expand Down Expand Up @@ -17447,6 +17655,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:
Expand Down
Loading
Loading