# Deliver responses with signed webhooks

Send survey data to your own software with a **webhook**: an HTTPS request from Shopoll to an address you provide. Choose whether to send saved answers, completed responses or events from question rules.

## Create a destination

In a paid workspace, open **Integrations → Webhooks**. Select the survey, enter the receiving HTTPS URL and choose when to send. When you first create the connection, copy its signing secret. Save it in the software that receives the webhook. It lets that software check that a request came from Shopoll.

## Verify a delivery

Read the raw request body before parsing it. The `X-Shopoll-Signature` header has the format `t=TIMESTAMP,v1=HEX_HMAC`, using a Unix timestamp in seconds and a SHA-256 HMAC. Compute the HMAC over the timestamp, a period and the raw body. Compare in constant time and check the age of the timestamp.

## Handle duplicates

Store each accepted `X-Shopoll-Delivery-Id`. A retry reuses the same delivery ID and body. Return a successful HTTP response after your software accepts the event. Open the destination's delivery history to inspect failures or replay an eligible event.

If delivery fails for a day, Shopoll emails your workspace recipients. See [notification settings](/docs/notifications.md) for the reminder schedule and inbox selection.


## Manage destinations through the API

Create a **Manage webhook destinations** key in Developer access as an owner or administrator on Standard or Unlimited. Use the app origin and `Authorization: Bearer YOUR_KEY`. For JSON bodies, also send `Content-Type: application/json`. This key cannot read reports or individual survey responses through the reporting API.

| Method and path | Result |
| --- | --- |
| GET `/api/v1/webhooks` | `destinations`, available `surveys`, and connection status fields `configured`, `slackAvailable`, `transport` |
| POST `/api/v1/webhooks` | Create a destination; HTTP 201 with `id` and, when first created for the workspace, `signingSecret` |
| DELETE `/api/v1/webhooks/{id}` | Remove a destination; `{ "removed": true }` |
| GET `/api/v1/webhooks/{id}/deliveries` | Latest 50 deliveries as `{ "deliveries": [...] }`; no pagination |
| POST `/api/v1/webhooks/{id}/deliveries/{event}/retry` | Requeue a failed or review-state delivery; `{ "queued": true }` |

### Create request fields

| Field | Requirement |
| --- | --- |
| `survey` | Required ID of an unarchived survey in this workspace |
| `label` | Required non-blank name, at most 80 characters |
| `kind` | Required: `webhook` or `slack` |
| `rule` | Required: `submitted`, `completed` or `action` |
| `url` | Required public HTTPS endpoint; Slack destinations require a Slack incoming webhook URL |

```bash
curl 'https://YOUR_APP_HOST/api/v1/webhooks' \
  -H 'Authorization: Bearer YOUR_KEY' \
  -H 'Content-Type: application/json' \
  --data '{"survey":"SURVEY_ID","label":"Completed surveys","kind":"webhook","rule":"completed","url":"https://example.com/shopoll-events"}'
```

`submitted` sends saved responses, including partial responses; `completed` sends completions. `action` creates a destination used only by question or workflow rules: select it in the survey's [workflow settings](/docs/surveys/behavior-settings.md) before expecting events. A survey can have up to 20 destinations. To change a destination, create its replacement, update any rules that refer to it, then delete the old destination. There is no destination update endpoint.

The signing secret is shared by webhook destinations in the workspace and returned only when first created. Store it immediately. Later destination creation can return only `id`; reuse the saved workspace signing secret. Destination list entries contain `id`, `survey`, `label`, `host`, `kind`, `rule` and survey `title`; the full receiving URL and signing secret are not returned. `transport` is `public` or `held`; held deliveries are not being sent to public receivers.

### Delivery history and retries

History entries contain `id`, `state`, `tries`, `due`, `http`, `occurred`, `question`, `questionLabel` and `workflow`. Use the entry's `id` as `{event}` in the retry path. Retry requires no JSON body. HTTP 409 means the delivery is not in an eligible state; HTTP 404 means the destination is unavailable. HTTP 503 means Shopoll cannot create the destination or retry the delivery. Try again later. If it persists, contact Shopoll support.

### Event body and headers

Webhook requests use JSON with `schemaVersion: 1`, `type`, `accountId`, `surveyId`, `surveyTitle`, `revision`, `participantId`, `metadata`, `responses`, `submissionsComplete`, `timestamp`, `email` and `emails`. `responses` maps question IDs to saved answer values. `timestamp` is event time in milliseconds. `type` is `submitted-responses`, `completed-survey`, `question-action` or `survey-action`. Action events include `questionId` or `workflowRule` as applicable. For a content or closing slide, a question-action event also includes `trigger` set to `slide-presented` and `slideTitle`. The slide contributes no entry to `responses`. File, form and matrix answers can also include `formattedFileAnswers`, `formattedFormAnswers` and `formattedMatrixAnswers`.

Alongside the signature and delivery ID, requests include `X-Shopoll-Attempt` and `X-Shopoll-Triggered-At` (the signing timestamp in seconds). Verify the raw body and signature before accepting it. Slack destinations receive Slack message JSON rather than this webhook envelope.
