---
title: "Backfill historical Paperform responses for a cohort's matching form"
method: POST
path: "/cohorts/{cohortId}/intake/backfill"
tags: ["Intake"]
---

# Backfill historical Paperform responses for a cohort's matching form

`POST /cohorts/{cohortId}/intake/backfill`

## Request

- Base URL: `https://api.production.yourmedley.com`
- URL: `https://api.production.yourmedley.com/cohorts/{cohortId}/intake/backfill`
- Auth: HTTP bearer

MED-942. Pulls all historical submissions for the given Paperform form
via the Paperform API and matches them to cohort participants by email
(the same email-based matching logic MED-865 uses for inbound webhooks).

- **Read-only against Paperform** — no Paperform-side edits, deletions, or webhook resends.
- **Does NOT send any emails** to participants.
- **Idempotent** — already-processed submissions (per `form_submissions.paperform_submission_id`) are skipped.
- **Bounded** — fails with a clear error if the form has more than 2000 submissions.

Returns a classified summary the UI surfaces to the Cohort Manager
(matched, already-processed, unmatched, ambiguous, no-email-on-submission, failed).

## Path parameters

- `cohortId` string, uuid, required

## Request body

- object
  - `form_id` string, required: Paperform form ID to pull submissions from

## Response `200`

Backfill complete — see summary for per-submission outcomes

- object
  - `success` boolean
  - `data` object
    - `total_submissions_fetched` integer
    - `matched` object[]
      - `paperform_submission_id` string
      - `cohort_participant_id` string, uuid
      - `participant_email` string
    - `already_processed` integer: Count of submissions already in form_submissions for this paperform_submission_id
    - `unmatched` object[]
      - `paperform_submission_id` string
      - `participant_email` string
    - `ambiguous` object[]
      - `paperform_submission_id` string
      - `participant_email` string
      - `match_count` integer
    - `no_email` object[]
      - `paperform_submission_id` string
    - `failed` object[]
      - `paperform_submission_id` string
      - `error` string
    - `duration_ms` integer
  - `message` string

## Other responses

- `400`: Validation or operational error. Possible cases: - `form_id` missing - Paperform API not configured - Soft cap exceeded (more than 2000 submissions) - Paperform API fetch failed - Cohort not found
- `401`: Unauthorized
- `404`: Cohort not found
- `500`: Unexpected server error

---

[API](https://skmtc.dev/withmedley/apis/medley-api.md) - [All operations](https://skmtc.dev/withmedley/apis/medley-api/llms.txt) - [OpenAPI document](https://skmtc.dev/withmedley/apis/medley-api/revisions/40aaac5ca6bd?raw)
