From 693a75f058831770c0353eab6ae1e7d485bc9f67 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 19:39:28 +0000 Subject: [PATCH 1/2] Document POST /projects/bulk_status_change CP-8392. Close or reopen many Projects at once (Rails PR MakerbleDev/makerble#17411): openapi.yaml path and the endpoint card. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xr9EtxXdr9dUjEub5L --- openapi.yaml | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 11 +++++++ 2 files changed, 103 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 76bf8ea..469afdf 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1626,6 +1626,98 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /projects/bulk_status_change: + post: + tags: [Projects] + summary: Close or reopen many Projects at once + description: | + Closes or reopens several Projects in one request. This is **Close projects** and **Reopen + projects** for the projects ticked in the Rows view of the My Projects page. Each Project is + closed or reopened the same way as from its own settings menu, so its team is told. + + A closed Project can't get new updates (Stories) or Contacts, and its existing updates can't + be edited, until it is reopened. Closed Projects are listed on the organisation's Closed + Projects page. + + **Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager + (Project Editor) of the Project. If any listed Project is one the user may not change, nothing + is changed and the reply is `403` naming those Projects. + + **Already closed or open.** `close` changes only the listed Projects that are open, and + `reopen` only those that are closed. The others are left as they are. + + **Signup Pages.** Closing a Project that an active Signup Page uses would break that Signup + Page, so `close` needs `signup_pages`: + - `deactivate`: deactivate those Signup Pages, then close the Project. A Project whose Signup + Page the user may not deactivate is left open. + - `skip`: leave those Projects open and close the rest. + + **In the background.** The reply is `202` straight away. The user is emailed when it has + finished: how many Projects were closed, with a link to the Closed Projects page, or which + Projects were reopened. Check the result with `GET /projects/{id}` (`is_closed`). + operationId: bulkChangeProjectStatus + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [status_action, project_ids] + properties: + status_action: + type: string + enum: [close, reopen] + description: Whether to close or reopen the Projects + project_ids: + type: array + minItems: 1 + maxItems: 200 + items: { type: integer } + description: The Projects to change, at most 200 + signup_pages: + type: string + enum: [deactivate, skip] + description: Required with `close`. What to do with Projects that an active Signup Page uses. + example: + status_action: close + project_ids: [619, 620] + signup_pages: skip + responses: + "202": + description: The Projects are being closed or reopened in the background + content: + application/json: + schema: + type: object + properties: + status_action: + type: string + enum: [close, reopen] + project_ids: + type: array + items: { type: integer } + message: + type: string + example: + status_action: close + project_ids: [619, 620] + message: The projects are being changed in the background. You will be emailed when this is done. + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user may not close or reopen one of the listed Projects. Nothing is changed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + error: "You don't have permission to close or reopen project 619." + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /beneficiaries: get: tags: [Beneficiaries] diff --git a/server.js b/server.js index 916806a..33f6e92 100644 --- a/server.js +++ b/server.js @@ -1298,6 +1298,17 @@ function buildDocsPage() { { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "422", cls: "response-4xx", desc: "Validation failed" } ], "Grant one or more users a role on a Project. A user can hold Editor, Reporter, and Observer simultaneously. Pass user IDs in role_data[].editor_ids, reporter_ids, or observer_ids.")} + ${endpointCard("POST", "/projects/bulk_status_change", "Close or reopen many Projects at once", true, [ + { name: "status_action", type: "string", required: true, desc: "close or reopen" }, + { name: "project_ids", type: "integer[]", required: true, desc: "The Projects to change, at most 200" }, + { name: "signup_pages", type: "string", required: false, desc: "Required with close. deactivate: deactivate the active Signup Pages that use a Project, then close it. skip: leave those Projects open and close the rest" } + ], [ + { code: "202", cls: "response-2xx", desc: "Queued: status_action, project_ids and message. The user is emailed when it has finished" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "You may not close or reopen one of the listed Projects; nothing changes" }, + { code: "404", cls: "response-4xx", desc: "One of the listed Projects doesn't exist" }, + { code: "422", cls: "response-4xx", desc: "Unknown status_action, missing signup_pages for close, or no Projects (or more than 200)" } + ], "What Close projects and Reopen projects do for the projects ticked in the Rows view of My Projects. Organisation Admins and Project Managers (Project Editors) can use it. close changes only the open Projects listed and reopen only the closed ones; each is closed or reopened as from its own settings menu, so its team is told. Check the result with GET /projects/{id} (is_closed).")} ${endpointCard("GET", "/project_results", "Get Results Canvas figures for Projects", true, [ { name: "project_ids", type: "integer[]", required: false, desc: "Projects to include, as project_ids[]=619 or a JSON array string. Defaults to every Project you can view" }, { name: "start_date", type: "string", required: false, desc: "First Story date to include, YYYY-MM-DD. Omit both dates for all time" }, From 53b0c6462377fb0b829467dbe9cc34318e3f64cc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 19:53:57 +0000 Subject: [PATCH 2/2] Document POST /projects/bulk_deletion CP-8392. Delete many closed Projects at once: openapi.yaml path and the endpoint card. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xr9EtxXdr9dUjEub5L --- openapi.yaml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 9 +++++++ 2 files changed, 85 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 469afdf..7fdfe84 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1718,6 +1718,82 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /projects/bulk_deletion: + post: + tags: [Projects] + summary: Delete many closed Projects at once + description: | + Permanently deletes several closed Projects in one request. This is **Delete projects** for + the projects ticked in the Rows view of the My Projects page. Each Project is deleted the + same way as with the Delete project button on the organisation's Closed Projects page: its + team is emailed, it is listed under Deleted Projects there, and its automations are turned + off. **Deletion is permanent and cannot be undone**, so confirm the list with the user first. + + **Only closed Projects are deleted.** Open Projects in the list are kept and returned in + `kept_project_ids`; close them first (`POST /projects/bulk_status_change`) to delete them. A + list with no closed Project is refused with `422`. + + **Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager + (Project Editor) of the Project. If any listed Project is one the user may not delete, + nothing is deleted and the reply is `403` naming those Projects. + + **In the background.** The reply is `202` straight away and the Projects are deleted soon + after. `GET /projects/{id}` returns `404` for a Project once it has been deleted. + operationId: bulkDeleteProjects + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [project_ids] + properties: + project_ids: + type: array + minItems: 1 + maxItems: 200 + items: { type: integer } + description: The Projects to delete, at most 200. Only the closed ones are deleted. + example: + project_ids: [619, 620] + responses: + "202": + description: The closed Projects are being deleted in the background + content: + application/json: + schema: + type: object + properties: + project_ids: + type: array + items: { type: integer } + description: The closed Projects that will be deleted + kept_project_ids: + type: array + items: { type: integer } + description: The open Projects in the list, which are kept + message: + type: string + example: + project_ids: [619] + kept_project_ids: [620] + message: The closed projects are being deleted in the background. + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user may not delete one of the listed Projects. Nothing is deleted. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + error: "You don't have permission to delete project 619." + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /beneficiaries: get: tags: [Beneficiaries] diff --git a/server.js b/server.js index 33f6e92..5fecd04 100644 --- a/server.js +++ b/server.js @@ -1309,6 +1309,15 @@ function buildDocsPage() { { code: "404", cls: "response-4xx", desc: "One of the listed Projects doesn't exist" }, { code: "422", cls: "response-4xx", desc: "Unknown status_action, missing signup_pages for close, or no Projects (or more than 200)" } ], "What Close projects and Reopen projects do for the projects ticked in the Rows view of My Projects. Organisation Admins and Project Managers (Project Editors) can use it. close changes only the open Projects listed and reopen only the closed ones; each is closed or reopened as from its own settings menu, so its team is told. Check the result with GET /projects/{id} (is_closed).")} + ${endpointCard("POST", "/projects/bulk_deletion", "Delete many closed Projects at once", true, [ + { name: "project_ids", type: "integer[]", required: true, desc: "The Projects to delete, at most 200. Only the closed ones are deleted" } + ], [ + { code: "202", cls: "response-2xx", desc: "Queued: project_ids (closed, to be deleted), kept_project_ids (open, kept) and message" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "You may not delete one of the listed Projects; nothing is deleted" }, + { code: "404", cls: "response-4xx", desc: "One of the listed Projects doesn't exist" }, + { code: "422", cls: "response-4xx", desc: "None of the Projects is closed, or no Projects (or more than 200)" } + ], "What Delete projects does for the projects ticked in the Rows view of My Projects. Deletion is permanent. Only closed Projects are deleted; close others first with POST /projects/bulk_status_change. Organisation Admins and Project Managers (Project Editors) can use it. Each Project is deleted as with the Delete project button on the Closed Projects page, so its team is emailed and it is listed under Deleted Projects. Runs in the background; GET /projects/{id} returns 404 once a Project has gone.")} ${endpointCard("GET", "/project_results", "Get Results Canvas figures for Projects", true, [ { name: "project_ids", type: "integer[]", required: false, desc: "Projects to include, as project_ids[]=619 or a JSON array string. Defaults to every Project you can view" }, { name: "start_date", type: "string", required: false, desc: "First Story date to include, YYYY-MM-DD. Omit both dates for all time" },