# Work with reports and participants

A **report** captures one interaction at a VisitReport event. It can include multiple **participants**, each with contact details and associated answers. Use the Reports API to export event leads, read answers, or correct a participant’s details.

Use a [personal API token](/authentication/#personal-api-token) in `x-api-key`. The examples use the base URL `https://backend.snapaddy.com/questionnaire`.

To process completed reports on export, [add a DataAgents workflow to your VisitReport event](https://portal.snapaddy.com/knowledge/how-do-i-add-a-workflow-to-a-visitreport-event).

## Find reports for an event

Get the event ID using [Find events](/visitreport/events/). Submit it as `questionnaireId` in the URL. The request body lets you search, filter, sort, and page through reports.

See the [API reference](/reference/visitreport-reports/) for the full search request schema.

```bash
curl --fail-with-body \
  'https://backend.snapaddy.com/questionnaire/v1/ExampleEvent0001/reports/grid-view' \
  -H "x-api-key: $SNAPADDY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"pagination":{"limit":10,"offset":0}}'
```

```typescript
const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");

const payload = {
  pagination: {
    limit: 10,
    offset: 0
  }
};
const response = await fetch("https://backend.snapaddy.com/questionnaire/v1/ExampleEvent0001/reports/grid-view", {
  method: "POST",
  headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
console.log(await response.json());
```

```python
import json
import os
from urllib.request import Request, urlopen

payload = {
    "pagination": {
        "limit": 10,
        "offset": 0
    }
}
request = Request(
    "https://backend.snapaddy.com/questionnaire/v1/ExampleEvent0001/reports/grid-view",
    method="POST",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"], "Content-Type": "application/json"},
    data=json.dumps(payload).encode(),
)
with urlopen(request, timeout=20) as response:
    print(json.load(response))
```

This search uses `POST` to accept a JSON body and returns `201`. It reads report data. It requires access to the event in the dashboard. Reporters see only their own reports in this view.

- `reportCount` counts matching reports before pagination.
- `participantCount` counts participants associated with the matching reports.
- `reports` contains **participant rows**. Use `parentId` when present and otherwise `id` to identify the report. Group rows by that value when you need one record per report.
- Advance `offset` by the number of report IDs returned on the page, keeping filters and sort order consistent. Counting participant rows can skip reports.

## Read a report and its answers

Call `GET /v1/report/{reportId}` with a report ID from the search. The response includes `participants` and `answers`. Participant contact fields appear under `participants[].address` in this response. Use the participant ID to find a specific person in that array. If you already have a participant ID from the legacy API, the detail endpoint can resolve it to the containing report. Use the returned report ID for later report-level requests.

Get the event’s [questionnaire structure](/visitreport/events/#read-the-questionnaire-structure) to interpret `answers[].questionId` and `answers[].answerOptions[].questionOptionId`. The report includes answer and answer-option IDs for matching existing records. For files, use attachment references from the report or `files[].publicUrlPath` from [Download a report snapshot](/reference/visitreport-reports/). Follow the returned path for the corresponding environment. The snapshot route returns JSON, while the file path points to the file.

## Export participants to a file

Use an export job when a sales team needs a spreadsheet, vCards, or report documents. Give the job an event ID and the participant IDs from your report search. For a row with a parent, use the row’s own `id` to select that participant. The token needs dashboard access to the event and a role that can export the selected reports.

To include every participant, [export an entire event](/visitreport/exports/).

### Create the export

This example exports one participant to an Excel workbook. Replace both IDs with values from your event. The request queues an asynchronous job and returns its ID. Larger exports can take longer, depending on the number of reports and the export format. Wait for the job to complete before requesting the download link.

See the [API reference](/reference/job-management/) for the full request schema.

```bash
JOBS=https://backend.snapaddy.com/job-management/jobs

curl --fail-with-body "$JOBS/vr-download" \
  -H "x-api-key: $SNAPADDY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
    "questionnaireId": "ExampleEvent0001",
    "participantIds": ["ExamplePerson001"],
    "downloadType": "EXCEL"
  }'
```

```typescript
const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");

const payload = {
  questionnaireId: "ExampleEvent0001",
  participantIds: [
    "ExamplePerson001"
  ],
  downloadType: "EXCEL"
};
const response = await fetch("https://backend.snapaddy.com/job-management/jobs/vr-download", {
  method: "POST",
  headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
console.log(await response.json());
```

```python
import json
import os
from urllib.request import Request, urlopen

payload = {
    "questionnaireId": "ExampleEvent0001",
    "participantIds": [
        "ExamplePerson001"
    ],
    "downloadType": "EXCEL"
}
request = Request(
    "https://backend.snapaddy.com/job-management/jobs/vr-download",
    method="POST",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"], "Content-Type": "application/json"},
    data=json.dumps(payload).encode(),
)
with urlopen(request, timeout=20) as response:
    print(json.load(response))
```

Keep the job’s `id` from the `201` response. Each participant must belong to the specified event. An empty `participantIds` array applies the event filters and can select every participant. For other output formats, set `downloadType` to `PDF`, `V_CARD`, `ATTACHMENT`, or `SIGNATURE_PDF`. To combine PDF reports into one document, use `downloadType: "PDF"` and `documentStrategy: "merged"`.

### Retrieve the file

Poll `GET /jobs/{id}` with the [Job Management guide](/platform/jobs/#poll-a-job). Once the job reaches `completed`, set `JOB_ID` to its ID and fetch the download link. This example uses `jq` to read the `url` field.

```bash
JOBS=https://backend.snapaddy.com/job-management/jobs

DOWNLOAD_URL=$(curl --fail --silent --show-error "$JOBS/vr-download/$JOB_ID/result" \
  -H "x-api-key: $SNAPADDY_API_KEY" | jq -er '.url') &&
  curl --fail --output participants.xlsx "$DOWNLOAD_URL"
```

```typescript
import { writeFile } from "node:fs/promises";

const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");
const jobId = process.env.JOB_ID;
if (!jobId) throw new Error("Set JOB_ID");

const response = await fetch(`https://backend.snapaddy.com/job-management/jobs/vr-download/${encodeURIComponent(jobId)}/result`, {
  headers: { "x-api-key": apiKey },
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
const { url } = await response.json();
const file = await fetch(url);
if (!file.ok) throw new Error(`Download failed (${file.status})`);
await writeFile("participants.xlsx", new Uint8Array(await file.arrayBuffer()));
```

```python
import json
import os
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen

request = Request(
    f"https://backend.snapaddy.com/job-management/jobs/vr-download/{quote(os.environ['JOB_ID'], safe='')}/result",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"]},
)
with urlopen(request, timeout=20) as response:
    download_url = json.load(response)["url"]
with urlopen(download_url, timeout=30) as file:
    Path("participants.xlsx").write_bytes(file.read())
```

The signed URL authorizes the file download by itself. Send your API key only to the snapAddy endpoint. A result request returns `404` for an unfinished or unknown job and `410` for a result older than 30 days after completion. To remove a finished export earlier, an authorized user can call `DELETE /jobs/vr-download/{id}` to delete the export job and its stored file.

[Export and job API reference](/reference/job-management/)

## Correct a participant

Call `PATCH /v1/participant/{participantId}` with the **participant’s** ID. Send the contact fields you want to update.

See the [API reference](/reference/visitreport-reports/) for the full request schema.

```bash
curl --fail-with-body -X PATCH \
  'https://backend.snapaddy.com/questionnaire/v1/participant/ExamplePerson001' \
  -H "x-api-key: $SNAPADDY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"firstName":"Alex","lastName":"Morgan"}'
```

```typescript
const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");

const payload = {
  firstName: "Alex",
  lastName: "Morgan"
};
const response = await fetch("https://backend.snapaddy.com/questionnaire/v1/participant/ExamplePerson001", {
  method: "PATCH",
  headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
console.log(await response.json());
```

```python
import json
import os
from urllib.request import Request, urlopen

payload = {
    "firstName": "Alex",
    "lastName": "Morgan"
}
request = Request(
    "https://backend.snapaddy.com/questionnaire/v1/participant/ExamplePerson001",
    method="PATCH",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"], "Content-Type": "application/json"},
    data=json.dumps(payload).encode(),
)
with urlopen(request, timeout=20) as response:
    print(json.load(response))
```

## Create, save, and complete a report

For a complete example in cURL, TypeScript and Python, [prefill questionnaire answers and hand over or complete the report](/visitreport/questionnaires/).

1. Send the first participant’s details to `POST /v1/{questionnaireId}/report/create`. The create schema uses `firstname` and `lastname`. Keep the returned `participantId`, which is the new report’s ID.
2. For an existing report, fetch a fresh snapshot with `GET /v1/report/{reportId}/download`. Use the upload request schema to send the complete participant and answer collections to `PUT /v1/report/{reportId}/upload`. **Omitted participants and answers can be removed.** Preserve existing IDs and values that you intend to keep.
3. Uploading saves the report in **In Progress**. [Complete it in VisitReport](/visitreport/questionnaires/#complete-the-report-in-visitreport) when it’s ready, or [hand it over](/visitreport/questionnaires/#hand-the-unfinished-report-to-a-colleague) for a colleague to continue.

The snapshot operation checks app access and the caller’s access to the report. For a contact field correction, use the participant patch above.

[Reports API reference](/reference/visitreport-reports/) · [VisitReport dashboard guide](https://portal.snapaddy.com/knowledge/guide-for-visitreport-admins)
