diff --git a/openapi.yaml b/openapi.yaml index e4b9393..f2b6e30 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2479,6 +2479,13 @@ paths: Lists the personal survey links already generated for a Survey Campaign, e.g. to reuse a Contact's existing link. A `use_once` link that has been answered has `expired: true`. Requires Project Editor or Organisation Editor access. + + Each link's `responses_in_progress` lists the survey responses the Contact has + started on it but not finished (saved with Finish Later), newest first. This is the + **Surveys in progress** column on the Survey Campaign's Response Rates tab. Pass + `in_progress=true` to list only links with one. Unfinished responses are kept for 30 + days after they were last updated. Saving one doesn't change the link's `updated_at`, + so `last_synced_datetime` doesn't pick it up. operationId: listSurveyLinks security: [{tokenAuth: []}] parameters: @@ -2495,6 +2502,11 @@ paths: schema: type: integer description: Only links for this Wave + - name: in_progress + in: query + schema: + type: boolean + description: "`true`: only links where the Contact has started a response but not finished it" responses: "200": description: Paginated list @@ -2502,6 +2514,27 @@ paths: application/json: schema: $ref: '#/components/schemas/PaginatedSurveyLinks' + example: + page: 1 + page_size: 1 + page_count: 1 + total_count: 1 + data: + - id: 812 + send_survey_id: 340 + beneficiary_id: 5521 + email: sam@example.org + survey_token: 0f8c1d2e3b4a59687a6b5c4d3e2f1a0b + survey_url: https://app.makerble.com/stories/new/0f8c1d2e3b4a59687a6b5c4d3e2f1a0b + link_expiry: use_once + is_anonymised: false + send_survey_wave_id: 12 + expired: false + created_at: "2026-10-01T09:00:00Z" + updated_at: "2026-10-01T09:00:00Z" + responses_in_progress: + - send_survey_wave_id: 12 + last_updated_at: "2026-10-03T14:30:00Z" "401": $ref: '#/components/responses/Unauthorized' "403": @@ -15755,6 +15788,21 @@ components: updated_at: type: string format: date-time + responses_in_progress: + type: array + description: | + Survey responses the Contact has started on this link but not finished (saved with + Finish Later), newest first; empty when there are none. Only those updated in the + last 30 days. Not counted as completed responses. + items: + type: object + properties: + send_survey_wave_id: + type: integer + nullable: true + last_updated_at: + type: string + format: date-time SurveyWave: type: object diff --git a/server.js b/server.js index d5064cf..308790b 100644 --- a/server.js +++ b/server.js @@ -1681,14 +1681,15 @@ function buildDocsPage() { { name: "id", in: "path", type: "integer", required: true, desc: "Survey Campaign (Project Story Category) ID" }, { name: "beneficiary_id", type: "integer", required: false, desc: "Only this Contact's links" }, { name: "send_survey_wave_id", type: "integer", required: false, desc: "Only links for this Wave" }, + { name: "in_progress", type: "boolean", required: false, desc: "true: only links where the Contact has started a response but not finished it" }, { name: "page", type: "integer", required: false, desc: "Page number" }, { name: "per_page", type: "integer", required: false, desc: "Records per page (max 200)" }, { name: "last_sync_datetime", type: "string", required: false, desc: "ISO 8601 incremental sync" } ], [ - { code: "200", cls: "response-2xx", desc: "Paginated list of links" }, + { code: "200", cls: "response-2xx", desc: "Paginated list of links, each with responses_in_progress: [{send_survey_wave_id, last_updated_at}], newest first" }, { code: "403", cls: "response-4xx", desc: "Not a Project Editor or Organisation Editor" }, { code: "404", cls: "response-4xx", desc: "Survey Campaign not found" } - ], "Use it to reuse a Contact's existing link. A use_once link that has been answered has expired: true.")} + ], "Use it to reuse a Contact's existing link. A use_once link that has been answered has expired: true. responses_in_progress lists the responses the Contact started on the link but hasn't finished (the Surveys in progress column on the Response Rates tab); they're kept for 30 days after they were last updated.")}