diff --git a/openapi.yaml b/openapi.yaml
index 5b3b0ce..ccebc4b 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -1678,6 +1678,97 @@ paths:
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
+ /beneficiaries/bulk_checklists:
+ post:
+ tags: [Beneficiaries]
+ summary: Start a Checklist for many Contacts at once
+ description: |
+ Starts a Checklist for many Contacts (Beneficiaries) in one request. This is **Add to › A
+ Checklist** for the Contacts selected on the Manage Contacts page. Each Contact is started
+ the same way as Add a Checklist on their profile, and actions their records already prove
+ done are marked done straight away.
+
+ **Which Checklist.** `checklist_id` and `project_id`: a Checklist the project lets colleagues
+ add by hand, through that project. Organisation Editors and Reporters may use any open
+ project; other users only projects they are an Editor or Reporter of. Anything else is
+ refused with `422`.
+
+ **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
+ `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`. With `filter_data`,
+ `project_id` also narrows the filters to Contacts in that project, since anyone outside it
+ would be skipped anyway.
+
+ **Skipped Contacts** are counted in `skip_counts`: `headline_only` (the user only has
+ Headline Only Access to them), `not_in_project` (they aren't in the project), `not_allowed`
+ (the Checklist can't be started for them). A Contact who already has the Checklist keeps
+ their progress and isn't counted as changed.
+
+ Up to 50 Contacts are started straight away (`200`); more run in the background (`202`), and
+ `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
+ the user belongs to one organisation.
+ operationId: startChecklistForBeneficiaries
+ security: [{tokenAuth: []}]
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [checklist_id, project_id]
+ properties:
+ charity_id:
+ type: integer
+ description: The organisation whose Contacts to start it for
+ checklist_id:
+ type: integer
+ description: The Checklist to start
+ project_id:
+ type: integer
+ description: The project it is started through (one that lets colleagues add it by hand)
+ beneficiary_ids:
+ type: array
+ maxItems: 500
+ items: { type: integer }
+ description: The Contacts, at most 500. Leave out to use filter_data instead.
+ filter_data:
+ type: object
+ additionalProperties: true
+ description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
+ excluded_ids:
+ type: array
+ items: { type: integer }
+ description: Contacts matching the filters to leave out
+ example:
+ charity_id: 12
+ checklist_id: 31
+ project_id: 572
+ beneficiary_ids: [160498, 160499, 160500]
+ responses:
+ "200":
+ description: The Checklist was started straight away (50 Contacts or fewer)
+ content:
+ application/json:
+ schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
+ example:
+ id: 61
+ status: completed
+ total_count: 10
+ processed_count: 10
+ changed_count: 7
+ skip_counts: { not_in_project: 3 }
+ background: false
+ summary: "7 contacts changed. 3 skipped: 3 because they aren't in Youth Mentoring."
+ "202":
+ description: More than 50 Contacts, so it runs in the background. Poll GET /beneficiaries/bulk_actions/{id}.
+ content:
+ application/json:
+ schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
+ "401":
+ $ref: '#/components/responses/Unauthorized'
+ "404":
+ $ref: '#/components/responses/NotFound'
+ "422":
+ $ref: '#/components/responses/UnprocessableEntityList'
/beneficiaries/bulk_actions/{id}:
get:
tags: [Beneficiaries]
diff --git a/server.js b/server.js
index 8c7d402..c65f073 100644
--- a/server.js
+++ b/server.js
@@ -1565,6 +1565,20 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or started by someone else" }
], "Only the user who started the move can see it.")}
+ ${endpointCard("POST", "/beneficiaries/bulk_checklists", "Start a Checklist for many Contacts at once", true, [
+ { name: "checklist_id", in: "body", type: "integer", required: true, desc: "The Checklist to start" },
+ { name: "project_id", in: "body", type: "integer", required: true, desc: "The Project it is started through: one that lets colleagues add it by hand" },
+ { name: "charity_id", in: "body", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
+ { name: "beneficiary_ids", in: "body", type: "integer[]", required: false, desc: "The Contacts, at most 500. Leave out to choose them with filter_data" },
+ { name: "filter_data", in: "body", type: "object", required: false, desc: "Manage Contacts filters choosing the Contacts" },
+ { name: "excluded_ids", in: "body", type: "integer[]", required: false, desc: "Contacts matching the filters to leave out" }
+ ], [
+ { code: "200", cls: "response-2xx", desc: "Up to 50 Contacts, started straight away: id, status, changed_count, skip_counts and summary" },
+ { code: "202", cls: "response-2xx", desc: "More than 50 Contacts: started in the background. Poll GET /beneficiaries/bulk_actions/{id} with the id" },
+ { code: "401", cls: "response-4xx", desc: "Not authenticated" },
+ { code: "404", cls: "response-4xx", desc: "An organisation you aren't in" },
+ { code: "422", cls: "response-4xx", desc: "A Checklist or Project you can't start it through, more than 500 beneficiary_ids, or no charity_id when you belong to several organisations" }
+ ], "Add to › A Checklist for the Contacts selected on the Manage Contacts page. Each Contact is started as Add a Checklist on their profile does, and steps their records already prove done are ticked off. Contacts outside the Project are skipped (skip_counts.not_in_project), as are those you only have Headline Only Access to (skip_counts.headline_only). Contacts who already have the Checklist keep their progress. Organisation Editors and Reporters may use any open Project; others only Projects they are an Editor or Reporter of.")}
${endpointCard("GET", "/beneficiaries/bulk_actions/{id}", "Get the progress of a bulk action on Contacts", true, [
{ name: "id", in: "path", type: "integer", required: true, desc: "The id returned by a bulk change, e.g. POST /events/{id}/guests with filter_data" }
], [