# Use the survey REST API

Use the REST API to connect Shopoll data and supported actions to your own software. Standard and Unlimited owners and administrators can create a key in **Developer access**. Each key belongs to one workspace and has one permission scope.

## Authenticate and choose a scope

Use your Shopoll app origin as the base URL, followed by the paths below. Send `Authorization: Bearer YOUR_KEY` on every request and `Content-Type: application/json` for JSON bodies. Keep keys in server-side credential storage. Requests from a different browser origin are rejected; use the [storefront JavaScript API](/javascript-api.md) for browser controls.

| Permission in Developer access | Scope | Access |
| --- | --- | --- |
| Reports | `reports` | Survey list, aggregate reports, attribution, Studio datasets and reporting MCP tools |
| Responses | `responses` | Reports access plus individual responses and customer history |
| Customer survey history | `helpdesk` | Customer history lookup only |
| Manage webhook destinations | `webhooks` | Destination creation, listing, removal, delivery history and retries only |
| Manage question visibility | `question-visibility` | Survey list and question visibility through REST or MCP only |

Choose Responses instead of Reports when individual answers are needed. Use separate keys for connections with different permissions. Copy each key when created; revoke it in Developer access to disconnect that client. Keys require an active installed paid workspace and their creator to remain an owner or administrator. External OAuth onboarding is not currently available.

## Read a survey

| Request | Purpose |
| --- | --- |
| GET /api/v1/surveys | List surveys and their identifiers |
| GET /api/v1/surveys/{id}/report | Read the aggregate report |
| GET /api/v1/surveys/{id}/responses | Read individual responses |
| GET /api/v1/surveys/{id}/attribution | Read order attribution |

Survey and response lists accept query parameters `limit` (integer 1–100, default 50) and `before` (positive integer). They return `{ "items": [...], "next": null }` or a numeric next cursor. Send `next` as `before` until it is null. Report and attribution results are not paginated.

```bash
curl 'https://YOUR_APP_HOST/api/v1/surveys?limit=20' \
  -H 'Authorization: Bearer YOUR_KEY'
```

Survey items contain `id`, `title`, `active`, `archived` and `version`. Response items contain `attempt`, `version`, `answers`, `metadata`, `complete` and `created`. Answers are keyed by question ID and use their saved JSON types; `complete` is the stored completion flag. Reviewed corrections are included. Date and report filters do not filter the individual-response list.

A report returns `responses` (count), `completed`, `channels`, `insights` and `funnel`. Each channel includes `source`, `currency`, `orders`, `revenue` and `average`. The funnel can be null for segmented results.

## Manage access

Create a separate key for each client so you can revoke one connection independently. A webhook-management key can manage webhook addresses and read delivery history. It cannot read survey reports. For an assistant that needs to interpret results, see the [MCP guide](/mcp.md).

## Look up a customer

POST to `/api/v1/customer-history` with content type `application/json` and a body such as `{"email":"customer@example.com"}`. Use a bearer key with the **Customer survey history** or **Responses** scope. The **Customer survey history** permission gives access only to this endpoint.

The result includes partial and finished submissions, the finished count, CSAT rating count and percentage satisfied, and average scored sentiment from 0 to 100. Recent responses include the survey name, UTC submission time, completion status, available sentiment and individual answers. Shopoll uses reviewed answers when a merchant makes a correction.

The default page has five responses. Include a numeric `limit` from 1 to 25 in the JSON body and pass `next` as the numeric `before` field for older responses. Counts and scores cover all matching responses, including those on other pages. A `match` value of `no_history` means there are no eligible records for that email. A `match` value of `shared_email` means more than one known customer matches. In both cases the response list is empty.

Use the [Gorgias setup guide](/integrations/gorgias.md) or [Richpanel setup guide](/integrations/richpanel.md) for the ticket-specific URL and sidebar configuration.

## Filter report data

Both `/report` and `/attribution` accept GET query parameters or a JSON POST body. With POST, put every filter in the body and leave the URL query empty. Use scalar strings, numbers or booleans, without arrays or nested objects. Personal filter values (`value`, `analysisValue`, `analysisName`, `email`, `phone`, `q`, `search`) are rejected in GET URLs. Only the supported filters below affect these reports.

| Filter | Meaning |
| --- | --- |
| `from`, `to` | Inclusive UTC dates in `YYYY-MM-DD` format |
| `status` | `complete` or `partial`; omit for both |
| `field`, `value` | Exact match on a captured metadata field; supply both in POST |
| `analysis` | `sentiment`, `classification`, `churn`, `reply`, `personal`, `quality`, `topic` or `field` |
| `analysisValue` | Required with `analysis`: exact stored analysis value, up to 650 characters; boolean flags use `"1"` or `"0"` |
| `analysisName` | Required for topic or extracted-field analysis; up to 80 characters |
| `group` | Attribution only: metadata field to group by; default `attribution_channel` |
| `question` | Attribution only: question ID to split by answer; supports choice, numeric and ranked question families |
| `interval` | Attribution only: `day` (default), `week` (Monday-based) or `month` |
| `compare` | Attribution only: `previous`; requires both valid dates and compares the preceding equal-length period |
| `projected` | Attribution only: `1` requests estimates; `0` or omission uses observed results |

```bash
curl 'https://YOUR_APP_HOST/api/v1/surveys/SURVEY_ID/attribution' \
  -H 'Authorization: Bearer YOUR_KEY' \
  -H 'Content-Type: application/json' \
  --data '{"from":"2026-10-01","to":"2026-10-31","group":"attribution_channel","interval":"month","compare":"previous","field":"placement","value":"order_confirmation"}'
```

Attribution returns `respondents`, `group`, `interval`, `rows`, `fields` (available metadata names), `previousPeriod` and `projection`. Each row contains `period`, `segment`, `label`, `count` and `money`. Each money entry contains `currency`, `revenue`, `orders` and `average`. Without `question`, the label is `All answers`. Previous-period rows are aligned to the current period and attached as `previous`. An order may contribute to several selected answers, so do not sum those rows as unique orders. Currencies stay separate.

Projections need measured views covering all responses, at least 30 responses for the selected question and a measured response rate from 5% to 100%. Segmentation can make projections unavailable. Check `projection.enabled` and `projection.reason`; eligible rows include `estimate` and, for comparisons, `previousEstimate`. Estimates are not observed sales.

### Read an answer-by-group breakdown

POST to the survey’s attribution endpoint with a question ID and the field to compare. For example:

```json
{"view":"groups","question":"cover","group":"device","from":"2026-10-01","to":"2026-10-31","compare":"previous"}
```

The response returns a series for each compatible question type and scale. Within a series, **answered** counts submissions that answered the question, **recorded** counts those with a known grouping field, and **withValue** counts those with a non-empty value. For discount codes this distinguishes a known order with no code from an order using a code. **choices** supplies the full heatmap axis. Each group row includes its response count, share of all answers to that question, and counts and within-group shares for selected choices. An omitted choice count is zero. A null group value means the field was unrecorded.

Each entry in **money** reports one currency, distinct linked orders, revenue and average order value. **previous**, **responseChange** and **revenueChange** accompany a date comparison. Revenue changes require linked values in the same currency in both periods. With **projected** set to 1, eligible series also include estimated responses and revenue alongside the observed numbers. Read **projection.reason** when estimates are unavailable.

For grouped reports, recognised aliases in `utm_source`, `entrySource`, `lastUtmSource` and `lastClickSource` share a row across both periods. For example, Facebook app and facebook.com return one **Facebook** value. Individual records retain the original source.

Grouping supports reported channel and source, UTM fields, device, browser, page type, browser and requested survey language, country, region and verified discount codes. Recorded storefront visits also support `landingPage`, `answeredPage`, `referringDomain`, `entrySource`, `entryMedium`, `entryCampaign`, `entryContent`, `entryTerm`, `adCampaign`, `adGroup`, `adCreative` and `adPlacement`. For verified Shopify orders, **groups** also accepts `lastClickSource`, `lastClickType`, `orderLandingPage`, `orderReferrer`, `lastLandingPage` and `lastReferrer`. Choose `lastUtmSource`, `lastUtmMedium`, `lastUtmCampaign`, `lastUtmContent` or `lastUtmTerm` for the final visit’s campaign tags. That visit can also supply `lastAdCampaign`, `lastAdGroup`, `lastAdCreative` and `lastAdPlacement`. Choose `daysToConversion` for days between the first visit and the order. Use the series’ **fields** list to discover what was recorded. The default attribution view continues to provide time series and accepts an interval. [Read the group comparison in Results](/report/#compare-the-same-answer-across-groups)

## Read Studio datasets

POST `/api/v1/studio` with a Reports or Responses key and a JSON body. Query strings are rejected. This is the reporting endpoint used by the [Looker Studio connector](/integrations/data-studio.md).

| Body field | Values and defaults |
| --- | --- |
| `dataset` | Required: `overview`, `daily`, `nps`, or `access` |
| `survey` | Optional survey ID; omit or use an empty string for the workspace |
| `before` | Optional positive integer cursor from `next` |
| `from`, `to` | Optional inclusive UTC dates in `YYYY-MM-DD` format for daily datasets |

```bash
curl 'https://YOUR_APP_HOST/api/v1/studio' \
  -H 'Authorization: Bearer YOUR_KEY' \
  -H 'Content-Type: application/json' \
  --data '{"dataset":"daily","survey":"SURVEY_ID","from":"2026-10-01","to":"2026-10-31"}'
```

`access` returns `{ "authorized": true }`. Other datasets return `{ "rows": [...], "next": null }` or a numeric cursor. Pass `next` as `before`, retaining the other fields, until null. Page size is fixed at 100 source records. Daily groups can recur across pages: combine matching dimensions and sum their measures after reading every page.

| Dataset | Row fields |
| --- | --- |
| `overview` | `pollId`, `pollSlug`, `pollTitle`, `createdAt`, `pollType`, `status`, `responseCount`, `presentationCount`, `participantCount`, `emailCount`, `voteCount`, `completeCount` |
| `daily` | `day`, `pollId`, `pollTitle`, `slideId`, `slideType`, `slideTitle`, `answerHandle`, `answerTitle`, `valueType`, `count`, `rankSum` |
| `nps` | `day`, `pollId`, `pollTitle`, `slideId`, `slideType`, `slideTitle`, `detractorCount`, `passiveCount`, `promoterCount`, `totalCount` |

Overview counts cover the survey lifetime; date filters do not restrict them. `createdAt` uses `YYYYMMDDHHmmss` when available; daily `day` uses `YYYYMMDD`, in UTC. Daily written answers, personal details and files contribute an Answered count without exporting their contents. Numeric scores and ranked positions contribute to `rankSum`. NPS rows supply counts: calculate `(promoterCount - detractorCount) / totalCount * 100` after combining pages and dates, and handle a zero total.

## Manage webhook destinations

Use a dedicated webhook key. See the [webhook API reference](/webhook.md) for every destination and delivery endpoint, request fields, signing and retry behaviour.

## Change question visibility

Create a **Manage question visibility** key. POST to `/api/v1/slide/list` with a JSON body such as `{"survey":"SURVEY_ID"}` to read the question identifiers, draft visibility, published visibility and version.

POST to `/api/v1/slide/update` with the same bearer key. This example hides a published question. Replace both identifiers and use the version returned by the list request.

```json
{"survey":"SURVEY_ID","question":"QUESTION_ID","settings":{"hidden":true},"applyTo":"live","expectedVersion":2}
```

Omit `applyTo` to change the saved draft only. A live change also updates the flag on the draft and keeps other pending edits separate. A version conflict returns HTTP 409. Read the latest state before retrying. Set `hidden` to `false` to show the same question again.


Visibility list results contain `survey`, `version`, `active` and `questions`. Each question has `id`, `label`, `hidden` (draft) and `publishedHidden` (null if unpublished). Update results contain `survey`, `question`, `hidden`, `applyTo` and `version`. `expectedVersion` is an optional non-negative integer. Archived surveys must be restored first; live updates require an active survey and a question already present in it.

## Handle errors and scope limits

REST errors return an `error` message. Handle HTTP 400 for invalid fields, 401 for an invalid or inactive key, 403 for insufficient permission or a rejected browser origin, 404 for an unavailable resource, 405 for an unsupported method, 409 for a conflict or ineligible action, and 503 when webhook setup or delivery retries are unavailable.

These customer endpoints support reading data, webhook management and question visibility. They do not provide general survey creation, content editing, branching changes, full publication, billing or team administration. MCP has its own [tool reference](/mcp.md); storefront controls are documented in the [JavaScript API guide](/javascript-api.md).
