Skip to main content
RapidDev - Software Development Agency
bolt-ai-integrationsBolt Chat + API Route

How to Integrate Bolt.new with SurveyMonkey

To integrate SurveyMonkey with Bolt.new, embed your surveys using SurveyMonkey's iframe embed link (works in the WebContainer preview), or use SurveyMonkey's REST API via a Next.js API route to fetch survey responses and build custom results dashboards. OAuth 2.0 for API authorization requires a deployed callback URL — test the embed approach in Bolt's preview and the API dashboard approach after deploying to Netlify or Bolt Cloud.

What you'll learn

  • How to embed a SurveyMonkey survey in a Bolt.new app using the iframe embed code for immediate use in the WebContainer preview
  • How to add hidden fields to pass user context (user ID, account tier) to SurveyMonkey responses
  • How to set up SurveyMonkey's OAuth 2.0 flow and call the REST API from a Next.js API route
  • How to fetch survey responses from the SurveyMonkey API and display them in a custom dashboard
  • Why OAuth callback URLs require a deployed app URL and cannot be tested in Bolt's WebContainer preview
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate18 min read25 minutesAnalyticsApril 2026RapidDev Engineering Team
TL;DR

To integrate SurveyMonkey with Bolt.new, embed your surveys using SurveyMonkey's iframe embed link (works in the WebContainer preview), or use SurveyMonkey's REST API via a Next.js API route to fetch survey responses and build custom results dashboards. OAuth 2.0 for API authorization requires a deployed callback URL — test the embed approach in Bolt's preview and the API dashboard approach after deploying to Netlify or Bolt Cloud.

SurveyMonkey in Bolt.new: Embeds for User Surveys, API for Analytics Dashboards

SurveyMonkey is the world's most widely used online survey platform, trusted by teams for everything from customer satisfaction (CSAT) measurement to NPS surveys, market research, and employee feedback. Its combination of a visual survey builder, advanced branching logic, statistical analysis tools, and a comprehensive REST API makes it suitable for both simple one-off surveys and systematic user research programs integrated into product workflows.

For Bolt.new developers, SurveyMonkey has two integration paths that serve different purposes. The embed path is the simplest: SurveyMonkey provides an iframe embed code for every survey, which you can paste into your Bolt app to display a survey anywhere — a post-onboarding feedback form, a customer satisfaction widget on a confirmation page, or a modal survey triggered after specific user actions. The iframe sends responses directly to SurveyMonkey without any server-side code, and it works in Bolt's WebContainer preview immediately.

The API path is more powerful: SurveyMonkey's REST API lets you create surveys programmatically, fetch responses, run analysis, and build custom dashboards that display survey results without requiring users to log into SurveyMonkey. This path requires OAuth 2.0, which needs a deployed callback URL — you cannot complete the OAuth flow in Bolt's WebContainer preview. Set up the OAuth flow after deploying to Netlify or Bolt Cloud, then use the access token in your API routes. SurveyMonkey's Advantage plan ($99/month) is typically required for API access with unlimited responses.

Integration method

Bolt Chat + API Route

SurveyMonkey integrates with Bolt apps through two complementary methods: embedding surveys via iframe (works in the WebContainer preview immediately) for displaying surveys to users, and calling SurveyMonkey's REST API from a Next.js API route to fetch responses, analyze data, and build custom dashboards. OAuth 2.0 authorization for the API requires a deployed callback URL and must be set up after deploying to Netlify or Bolt Cloud.

Prerequisites

  • A SurveyMonkey account with at least the Advantage plan ($99/month) for API access — free accounts have limited API functionality
  • A survey created in SurveyMonkey with the embed or sharing link available from the survey's 'Collect Responses' section
  • A Bolt.new project — Vite or Next.js both work for the iframe embed; Next.js is required for the API dashboard
  • For OAuth API access: a SurveyMonkey developer app created at developer.surveymonkey.com with a registered redirect URI matching your deployed domain

Step-by-step guide

1

Embed a SurveyMonkey Survey Using an Iframe

The quickest way to add a SurveyMonkey survey to your Bolt app is the iframe embed. Every SurveyMonkey survey has a shareable link and an embeddable iframe code. Go to your survey in SurveyMonkey → click 'Collect Responses' → select 'Embed in a Web Page' from the options. SurveyMonkey generates an iframe HTML snippet with a src pointing to your survey's URL. Copy this embed code. In Bolt, you can use this iframe directly in a React component. The iframe src contains your survey URL — render it with React's iframe element. Set appropriate width (100%) and height (600px is a good starting default) CSS properties. The iframe communicates with SurveyMonkey's servers directly from the user's browser, bypassing the WebContainer's server-side networking entirely. This means the embed works in the Bolt WebContainer preview immediately — no deployment needed to test the survey display and response submission. To make the embed context-aware, pass user information to SurveyMonkey via URL query parameters. SurveyMonkey supports 'custom variables' (also called hidden fields) that you can pre-populate by appending them to the survey URL as query parameters. First, in SurveyMonkey, go to your survey Design → scroll to the bottom → Add a Custom Variable named 'user_id'. Then in your Bolt app, append ?user_id={encodeURIComponent(userId)} to the survey URL before passing it to the iframe src. SurveyMonkey records this value with each response, allowing you to match survey responses to user accounts in your database. For detecting survey completion (to dismiss a modal or trigger a post-survey action), SurveyMonkey sends a postMessage to the parent window when the survey is completed. Listen for this message with a window event listener. The message format is { type: 'survey_complete' } or similar — check SurveyMonkey's current documentation for the exact format as it may change.

Bolt.new Prompt

Create a React component SurveyMonkeyEmbed that embeds a SurveyMonkey survey using an iframe. Accept props: surveyUrl (string), userId (string, optional), onComplete (function, optional). Append the userId to the survey URL as ?user_id= query parameter if provided (URL encode it). Render the iframe with 100% width and 550px height. Listen for a postMessage from the iframe to detect survey completion and call onComplete. Wrap the component in a div with a visible border and a title. Add a loading spinner that shows until the iframe loads.

Paste this in Bolt.new chat

components/SurveyMonkeyEmbed.tsx
1// components/SurveyMonkeyEmbed.tsx
2'use client';
3
4import { useEffect, useRef, useState } from 'react';
5
6interface SurveyMonkeyEmbedProps {
7 surveyUrl: string;
8 userId?: string;
9 onComplete?: () => void;
10 height?: number;
11}
12
13export function SurveyMonkeyEmbed({
14 surveyUrl,
15 userId,
16 onComplete,
17 height = 550,
18}: SurveyMonkeyEmbedProps) {
19 const iframeRef = useRef<HTMLIFrameElement>(null);
20 const [loading, setLoading] = useState(true);
21
22 // Build URL with user context
23 const embedUrl = userId
24 ? `${surveyUrl}${surveyUrl.includes('?') ? '&' : '?'}user_id=${encodeURIComponent(userId)}`
25 : surveyUrl;
26
27 useEffect(() => {
28 const handleMessage = (event: MessageEvent) => {
29 // SurveyMonkey sends completion message from their domain
30 if (
31 event.origin.includes('surveymonkey.com') &&
32 (event.data?.type === 'survey_complete' ||
33 event.data === 'survey_complete')
34 ) {
35 onComplete?.();
36 }
37 };
38
39 window.addEventListener('message', handleMessage);
40 return () => window.removeEventListener('message', handleMessage);
41 }, [onComplete]);
42
43 return (
44 <div style={{ position: 'relative', width: '100%' }}>
45 {loading && (
46 <div style={{
47 position: 'absolute', inset: 0, display: 'flex',
48 alignItems: 'center', justifyContent: 'center',
49 background: '#f9fafb',
50 }}>
51 Loading survey...
52 </div>
53 )}
54 <iframe
55 ref={iframeRef}
56 src={embedUrl}
57 width="100%"
58 height={height}
59 style={{ border: 'none' }}
60 onLoad={() => setLoading(false)}
61 title="Customer Survey"
62 allow="autoplay"
63 />
64 </div>
65 );
66}

Pro tip: SurveyMonkey's default survey pages include SurveyMonkey branding and navigation that can distract users. Set the iframe to the survey's full-page link (not the embed-optimized link) for a cleaner experience, or use SurveyMonkey's whitelabel options on higher-tier plans to remove the SurveyMonkey header.

Expected result: The SurveyMonkey survey renders inside the iframe in the Bolt preview. Users can complete the survey and their responses are recorded in the SurveyMonkey dashboard. If you pass a userId, it appears as a custom variable on each response in the SurveyMonkey Analyze section.

2

Set Up SurveyMonkey OAuth and API Access

SurveyMonkey's REST API uses OAuth 2.0 authorization. To access your survey data programmatically, you need a developer app registered at developer.surveymonkey.com. Go to developer.surveymonkey.com → sign in with your SurveyMonkey account → create a new app → give it a name → select OAuth 2.0 as the auth type. The critical configuration is the Redirect URI (also called OAuth Callback URL). This is the URL SurveyMonkey redirects to after a user authorizes your app. It must be a publicly accessible URL — it cannot be localhost or a Bolt WebContainer preview URL. Use your deployed domain: https://yourapp.netlify.app/api/auth/surveymonkey/callback. Deploy your Bolt app to Netlify or Bolt Cloud first (even a basic version) to get a stable domain. Then register that domain as the redirect URI in your SurveyMonkey developer app settings. For internal dashboards where only you (the app owner) need API access, the simpler approach is to generate an OAuth access token once using the manual authorization flow: open the authorization URL in your browser, grant access, copy the access token from the callback URL parameters, and store it in your .env file as SURVEYMONKEY_ACCESS_TOKEN. This token works for personal API access without building a full OAuth flow for users. For apps where your users need to authorize SurveyMonkey access (e.g., letting customers connect their SurveyMonkey accounts), implement the full OAuth 2.0 code flow — authorization URL redirect, callback handler, token exchange — all in Next.js API routes. The token exchange and subsequent API calls happen server-side, keeping credentials secure.

Bolt.new Prompt

Create the SurveyMonkey OAuth setup for my Next.js Bolt app. Create a .env file with placeholders: SURVEYMONKEY_CLIENT_ID, SURVEYMONKEY_CLIENT_SECRET, SURVEYMONKEY_ACCESS_TOKEN, SURVEYMONKEY_SURVEY_ID. Create an API route at app/api/auth/surveymonkey/route.ts that generates the SurveyMonkey OAuth authorization URL using the client ID and redirects the user to it. Create a callback handler at app/api/auth/surveymonkey/callback/route.ts that exchanges the authorization code for an access token (POST to https://api.surveymonkey.com/oauth/token) and stores it. Show me the exact SurveyMonkey developer app configuration I need.

Paste this in Bolt.new chat

app/api/auth/surveymonkey/route.ts
1// app/api/auth/surveymonkey/route.ts
2import { NextResponse } from 'next/server';
3
4export async function GET() {
5 const clientId = process.env.SURVEYMONKEY_CLIENT_ID;
6 const redirectUri = `${process.env.NEXT_PUBLIC_APP_URL}/api/auth/surveymonkey/callback`;
7
8 if (!clientId) {
9 return NextResponse.json({ error: 'SurveyMonkey client ID not configured' }, { status: 500 });
10 }
11
12 const params = new URLSearchParams({
13 response_type: 'code',
14 client_id: clientId,
15 redirect_uri: redirectUri,
16 });
17
18 return NextResponse.redirect(
19 `https://api.surveymonkey.com/oauth/authorize?${params.toString()}`
20 );
21}
22
23// app/api/auth/surveymonkey/callback/route.ts
24import { NextResponse } from 'next/server';
25
26export async function GET(request: Request) {
27 const { searchParams } = new URL(request.url);
28 const code = searchParams.get('code');
29
30 if (!code) {
31 return NextResponse.json({ error: 'No authorization code' }, { status: 400 });
32 }
33
34 const redirectUri = `${process.env.NEXT_PUBLIC_APP_URL}/api/auth/surveymonkey/callback`;
35
36 const response = await fetch('https://api.surveymonkey.com/oauth/token', {
37 method: 'POST',
38 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
39 body: new URLSearchParams({
40 grant_type: 'authorization_code',
41 code,
42 redirect_uri: redirectUri,
43 client_id: process.env.SURVEYMONKEY_CLIENT_ID!,
44 client_secret: process.env.SURVEYMONKEY_CLIENT_SECRET!,
45 }).toString(),
46 });
47
48 const data = await response.json() as { access_token?: string; error?: string };
49
50 if (!data.access_token) {
51 return NextResponse.json({ error: data.error ?? 'Token exchange failed' }, { status: 400 });
52 }
53
54 // In production, store the token in a database associated with the user.
55 // For development/personal use, log it and store in .env manually:
56 console.log('SurveyMonkey access token:', data.access_token);
57
58 return NextResponse.redirect(`${process.env.NEXT_PUBLIC_APP_URL}/admin?sm_connected=true`);
59}

Pro tip: For personal use (accessing your own SurveyMonkey surveys), you can generate a long-lived access token using SurveyMonkey's API directly — go to developer.surveymonkey.com → your app → Settings → find the 'Access Token' section. This token doesn't expire for 365 days and is simpler than implementing the full OAuth flow.

Expected result: After deploying to Netlify with the redirect URI registered in SurveyMonkey developer settings, visiting /api/auth/surveymonkey redirects to SurveyMonkey authorization. After granting access, you are redirected back to your app. The access token is logged and can be stored in environment variables.

3

Fetch Survey Responses and Build a Custom Dashboard

With an access token stored in SURVEYMONKEY_ACCESS_TOKEN, you can fetch survey responses and build a custom analytics view inside your Bolt app. The SurveyMonkey API provides several endpoints for working with survey data: /v3/surveys (list all surveys), /v3/surveys/{id}/responses/bulk (get all responses with question details), and /v3/surveys/{id}/rollups (get aggregated answer counts per question). For a responses dashboard, the bulk responses endpoint is most useful — it returns each individual response with the question text, answer choice, and any metadata including custom variables you set. The responses are paginated; the default page size is 50 responses, up to 100. Use the links.next URL from the response to paginate through all responses. Response parsing requires understanding SurveyMonkey's response object structure. Each response contains pages, each page contains questions, and each question contains answers. The answer format depends on question type: single-choice questions have a choice_id that maps to the choices array, open-text questions have a text property, and rating questions have a value. For aggregate dashboards (showing totals and percentages rather than individual responses), the rollups endpoint is much simpler — it pre-calculates answer counts and percentages for you. Use rollups when you need a quick overview; use bulk responses when you need to analyze individual response details, filter by custom variables, or export raw data. Note: server-side API calls from Next.js routes work in the Bolt WebContainer preview since they are outbound HTTPS calls. However, if you encounter authentication issues in the preview, deploy to Netlify to test in a proper Node.js environment where cookie and session management is more predictable.

Bolt.new Prompt

Create a SurveyMonkey responses dashboard. Build a Next.js API route at app/api/surveys/responses/route.ts that fetches the latest 50 responses from my survey using SURVEYMONKEY_ACCESS_TOKEN and SURVEYMONKEY_SURVEY_ID (both server-side env vars). Call GET https://api.surveymonkey.com/v3/surveys/{id}/responses/bulk?per_page=50&sort_order=DESC with Authorization: Bearer {token}. Parse the responses to extract each respondent's answers to all questions. Create a SurveyResponsesDashboard React component that shows total response count, the last 10 individual responses with their answers, and average score if there's a rating question.

Paste this in Bolt.new chat

app/api/surveys/responses/route.ts
1// app/api/surveys/responses/route.ts
2import { NextResponse } from 'next/server';
3
4interface SMChoice { id: string; text: string; }
5interface SMAnswer { choice_id?: string; text?: string; row_id?: string; }
6interface SMQuestion { id: string; heading: string; answers?: { choices?: SMChoice[] }; }
7interface SMPage { questions: SMQuestion[]; }
8interface SMSurveyDetails { pages: SMPage[]; }
9
10export async function GET() {
11 const token = process.env.SURVEYMONKEY_ACCESS_TOKEN;
12 const surveyId = process.env.SURVEYMONKEY_SURVEY_ID;
13
14 if (!token || !surveyId) {
15 return NextResponse.json(
16 { error: 'SurveyMonkey credentials not configured' },
17 { status: 500 }
18 );
19 }
20
21 const headers = {
22 Authorization: `Bearer ${token}`,
23 'Content-Type': 'application/json',
24 };
25
26 try {
27 // Fetch survey details to get question/choice mappings
28 const surveyRes = await fetch(
29 `https://api.surveymonkey.com/v3/surveys/${surveyId}/details`,
30 { headers }
31 );
32 const survey = await surveyRes.json() as SMSurveyDetails;
33
34 // Build question id → text map
35 const questionMap: Record<string, string> = {};
36 const choiceMap: Record<string, string> = {};
37 survey.pages?.forEach((page) => {
38 page.questions?.forEach((q) => {
39 questionMap[q.id] = q.heading;
40 q.answers?.choices?.forEach((c) => {
41 choiceMap[c.id] = c.text;
42 });
43 });
44 });
45
46 // Fetch responses
47 const responsesRes = await fetch(
48 `https://api.surveymonkey.com/v3/surveys/${surveyId}/responses/bulk?per_page=50&sort_order=DESC`,
49 { headers }
50 );
51 const data = await responsesRes.json() as {
52 total: number;
53 data: Array<{
54 id: string;
55 date_created: string;
56 pages: Array<{ questions: Array<{ id: string; answers: SMAnswer[] }> }>;
57 }>;
58 };
59
60 const responses = data.data?.map((resp) => ({
61 id: resp.id,
62 date: resp.date_created,
63 answers: resp.pages?.flatMap((page) =>
64 page.questions?.map((q) => ({
65 question: questionMap[q.id] ?? q.id,
66 answer: q.answers?.map((a) =>
67 a.text ?? choiceMap[a.choice_id ?? ''] ?? a.choice_id ?? ''
68 ).join(', ') ?? '',
69 }))
70 ).filter(Boolean),
71 }));
72
73 return NextResponse.json({ total: data.total, responses });
74 } catch (error: unknown) {
75 const e = error as { message: string };
76 return NextResponse.json({ error: e.message }, { status: 500 });
77 }
78}

Pro tip: SurveyMonkey's API rate limits are 120 requests per minute on standard plans. For a dashboard that updates frequently, add server-side caching: store the responses in-memory or in Supabase with a 15-minute TTL, and only re-fetch from SurveyMonkey when the cache expires.

Expected result: After deploying and setting SURVEYMONKEY_ACCESS_TOKEN and SURVEYMONKEY_SURVEY_ID, GET /api/surveys/responses returns parsed survey responses. The dashboard component displays the total count and recent individual responses with question-answer pairs.

4

Deploy and Test the Full Integration

The complete SurveyMonkey integration — embed for user-facing surveys and API for admin dashboard — requires a deployed URL to function fully. The iframe embed works in the Bolt preview, but the OAuth authorization flow and API calls should be verified on the production domain. After deploying to Netlify or Bolt Cloud, set your environment variables in the hosting platform. In Netlify: Site Settings → Environment Variables → add SURVEYMONKEY_CLIENT_ID, SURVEYMONKEY_CLIENT_SECRET, SURVEYMONKEY_ACCESS_TOKEN, SURVEYMONKEY_SURVEY_ID, and NEXT_PUBLIC_APP_URL (your deployed domain). The NEXT_PUBLIC_APP_URL is used to construct the OAuth redirect URI dynamically. Verify the OAuth redirect URI in your SurveyMonkey developer app matches your deployed domain exactly. Go to developer.surveymonkey.com → your app → Settings → Redirect URI. It must match https://yourapp.netlify.app/api/auth/surveymonkey/callback exactly, including the https protocol and path. A URI mismatch returns a redirect_uri_mismatch error from SurveyMonkey. For ongoing production use, SurveyMonkey access tokens expire after 365 days. Implement a refresh mechanism or set a calendar reminder to regenerate the token before expiry. SurveyMonkey does not provide refresh tokens for OAuth 2.0 access tokens — you must re-run the authorization flow to get a new token. Note about Bolt WebContainer: the SurveyMonkey API calls from your Next.js API routes use outbound HTTPS (fetch() calls), which work in the WebContainer preview. However, the OAuth callback URL redirect is browser-based and requires your deployed production URL to be registered. Test outbound API calls (fetching responses) in the preview; test OAuth flows on the deployed URL.

Bolt.new Prompt

Create a netlify.toml for my Next.js Bolt app with SurveyMonkey integration. Set up the build configuration and add environment variable documentation comments. Also create a /admin/surveys page that's protected (requires authentication), showing the SurveyMonkey dashboard with the SurveyResponsesDashboard component if connected (SURVEYMONKEY_ACCESS_TOKEN is set), or a 'Connect SurveyMonkey' button linking to /api/auth/surveymonkey if not connected.

Paste this in Bolt.new chat

netlify.toml
1# netlify.toml
2[build]
3 command = "npm run build"
4 publish = ".next"
5
6[build.environment]
7 NODE_VERSION = "20"
8
9[[plugins]]
10 package = "@netlify/plugin-nextjs"
11
12# Required environment variables set in Netlify Dashboard:
13# SURVEYMONKEY_CLIENT_ID - from developer.surveymonkey.com app settings
14# SURVEYMONKEY_CLIENT_SECRET - from developer.surveymonkey.com app settings
15# SURVEYMONKEY_ACCESS_TOKEN - long-lived token (expires 365 days)
16# SURVEYMONKEY_SURVEY_ID - your survey ID from the URL
17# NEXT_PUBLIC_APP_URL - your deployed domain (https://yourapp.netlify.app)
18# NEXT_PUBLIC_SUPABASE_URL - if using Supabase for auth
19# NEXT_PUBLIC_SUPABASE_ANON_KEY - if using Supabase for auth

Pro tip: Add the SurveyMonkey token expiry date as a comment in your .env file and set a calendar reminder 30 days before expiry. When the token expires, run the OAuth flow again (visit /api/auth/surveymonkey while logged into your admin account) to get a fresh token. Update the SURVEYMONKEY_ACCESS_TOKEN in Netlify and redeploy.

Expected result: The deployed app shows survey responses in the admin dashboard. The SurveyMonkey embed works on all pages where it is included. The OAuth flow completes successfully on the production domain, and the access token fetches live survey data.

Common use cases

Embed a Post-Onboarding Satisfaction Survey

After a user completes your app's onboarding flow, show them a SurveyMonkey survey asking what they liked and what was confusing. Use SurveyMonkey's iframe embed to display the survey in a modal overlay triggered by the onboarding completion event. Pass the user's ID as a hidden field so you can match responses to user accounts in your database.

Bolt.new Prompt

Add a SurveyMonkey post-onboarding survey to my Bolt app. After a user completes step 5 of my onboarding wizard, show a modal overlay containing the SurveyMonkey survey iframe. The survey URL is https://www.surveymonkey.com/r/MY_SURVEY_ID. Pass the user's ID as a custom variable by appending ?user_id={userId} to the survey URL (I've set up a hidden field in SurveyMonkey named 'user_id'). Show a 'Skip survey' button below the iframe. Dismiss the modal after the user submits the survey or clicks skip.

Copy this prompt to try it in Bolt.new

Build a Customer Feedback Dashboard Using the API

Fetch survey responses from SurveyMonkey's REST API and display them in an internal admin dashboard inside your Bolt app. Show the latest responses, calculate average satisfaction scores, and display a breakdown of multiple-choice answers. This lets your team review survey data without needing SurveyMonkey account access.

Bolt.new Prompt

Create an admin dashboard at /admin/feedback that displays SurveyMonkey survey responses. Create a Next.js API route at app/api/surveys/responses/route.ts that fetches the latest 50 responses from my SurveyMonkey survey using the API. Use SURVEYMONKEY_ACCESS_TOKEN (server-side) and SURVEYMONKEY_SURVEY_ID from environment variables. Parse the response to extract the main satisfaction score question and open-text comments. Create a React AdminFeedbackDashboard component that displays scores, comment text, and submission timestamps.

Copy this prompt to try it in Bolt.new

Create a Recurring NPS Survey with SurveyMonkey

Use SurveyMonkey's scheduled reminder feature to send monthly NPS surveys to your user list, then fetch and display the results in your Bolt app's admin section. SurveyMonkey handles email delivery, response collection, and scoring — your Bolt app displays the aggregated results through the API.

Bolt.new Prompt

I have a monthly NPS survey in SurveyMonkey. Create an API route that fetches the aggregate NPS score from my survey: GET https://api.surveymonkey.com/v3/surveys/{id}/rollups returns question-level aggregates. Parse the NPS question rollup to calculate the percentage of Promoters (9-10), Passives (7-8), and Detractors (0-6) and compute the NPS score (Promoters% - Detractors%). Create a simple NPS gauge component that displays the current score and trend vs last month.

Copy this prompt to try it in Bolt.new

Troubleshooting

SurveyMonkey OAuth returns 'redirect_uri_mismatch' error

Cause: The redirect URI in the API request does not exactly match the Redirect URI registered in your SurveyMonkey developer app. Case, trailing slashes, and protocol differences all cause this error.

Solution: Go to developer.surveymonkey.com → your app → Settings → Redirect URIs. Ensure the URI matches exactly: same protocol (https://), same domain, same path. No trailing slash unless you include one in the API call. Copy the exact redirect URI from your API route and paste it into SurveyMonkey developer settings.

typescript
1// Ensure NEXT_PUBLIC_APP_URL has no trailing slash:
2// NEXT_PUBLIC_APP_URL=https://yourapp.netlify.app (correct)
3// NEXT_PUBLIC_APP_URL=https://yourapp.netlify.app/ (wrong — trailing slash)
4
5// The redirect URI construction in your route:
6const redirectUri = `${process.env.NEXT_PUBLIC_APP_URL}/api/auth/surveymonkey/callback`;
7// Must match developer.surveymonkey.com registered URI exactly

SurveyMonkey API returns 401 Unauthorized

Cause: The access token has expired (tokens expire after 365 days), or the SURVEYMONKEY_ACCESS_TOKEN environment variable is not set in the hosting platform.

Solution: Check that SURVEYMONKEY_ACCESS_TOKEN is set in your Netlify or Bolt Cloud environment variables. If it was set more than a year ago, regenerate it by running the OAuth flow again. Trigger a redeploy after updating environment variables.

SurveyMonkey embed iframe shows blank or fails to load in the Bolt preview

Cause: SurveyMonkey may block iframe embedding on certain plan tiers, or the survey URL may not be the correct embed URL format. The SurveyMonkey CORS and frame-options headers vary by account type.

Solution: Ensure the survey URL is the sharing/collector link from SurveyMonkey (format: www.surveymonkey.com/r/XXXXXXX), not the edit URL. Some SurveyMonkey plans restrict iframe embedding — check your plan's features. Add allow='autoplay' and loading='eager' attributes to the iframe element. Test the embed URL directly in a browser first.

typescript
1// Use the correct SurveyMonkey share URL format:
2// Correct: https://www.surveymonkey.com/r/XXXXXXX
3// Wrong (edit URL): https://www.surveymonkey.com/create/?sm=XXXXXXX

Custom variable (user_id) not appearing in SurveyMonkey response data

Cause: The custom variable must be defined in SurveyMonkey before it can be passed via URL. If the variable name doesn't match a defined custom variable, SurveyMonkey ignores it silently.

Solution: In SurveyMonkey, open your survey → Design tab → scroll to the bottom → look for 'Custom Variables' section → Add a variable with the exact name 'user_id'. After defining it, the ?user_id= parameter in the survey URL will be recorded. Custom variables appear in the SurveyMonkey Analyze section under each response.

Best practices

  • Use the iframe embed for user-facing surveys — it works in the Bolt preview, requires no API credentials, and handles survey rendering and submission automatically
  • Pass user context (user ID, plan tier) to SurveyMonkey via URL custom variables so you can match responses to specific user accounts in your database
  • Store SURVEYMONKEY_ACCESS_TOKEN as a server-side environment variable only — never expose it with NEXT_PUBLIC_ prefix since it grants full read access to your survey data
  • Deploy to Netlify or Bolt Cloud before setting up OAuth — the OAuth callback URL must be a publicly accessible HTTPS URL, not a localhost or WebContainer preview URL
  • Add server-side caching (15-60 minutes) to your survey response API routes to avoid hitting SurveyMonkey's 120 requests/minute rate limit
  • Set a calendar reminder 30 days before your SurveyMonkey access token expires (365 days after generation) to regenerate it before your dashboard stops working
  • Use SurveyMonkey's rollups endpoint for aggregate dashboard views (totals, percentages) and the bulk responses endpoint only when you need individual response details

Alternatives

Frequently asked questions

Does the SurveyMonkey embed work in Bolt.new's WebContainer preview?

Yes. SurveyMonkey survey iframes communicate directly from the user's browser to SurveyMonkey's servers — the WebContainer is not involved. You can embed a SurveyMonkey survey in your Bolt app and test the full survey experience (including response submission) in the preview. Only the OAuth API flow requires a deployed URL for the callback.

Do I need the paid SurveyMonkey plan for API access?

Yes. SurveyMonkey's REST API access requires at least the Advantage plan ($99/month for annual billing). Free and Basic accounts have very limited API access. If API access is not in your budget, the iframe embed approach works on any plan tier including free. For a free alternative with an API, consider building a custom feedback form in Bolt and storing responses in your Supabase database.

Can I create SurveyMonkey surveys programmatically from Bolt?

Yes, using the POST /v3/surveys API endpoint. You can define survey pages, questions, and answer choices in JSON and create new surveys via API. This is useful for generating dynamic surveys based on user data or app context — for example, creating a personalized feedback survey after a specific workflow completes. Requires API access (Advantage plan or higher) and an access token.

How do I link SurveyMonkey responses to my Supabase users?

Use SurveyMonkey's custom variables feature. Define a custom variable named 'user_id' in your survey's Design settings. When embedding the survey, append ?user_id={userId} to the survey URL. SurveyMonkey records this value with each response. When you fetch responses via the API, each response includes the custom variable values — match the user_id to your Supabase auth.users table to link feedback to specific accounts.

Why does the OAuth flow fail in the Bolt preview but work after deployment?

SurveyMonkey's OAuth requires a registered redirect URI — the URL SurveyMonkey sends the authorization code to after the user grants access. The Bolt WebContainer preview uses dynamic URLs that change between sessions, so they cannot be registered as stable redirect URIs in SurveyMonkey's developer settings. Deploy to Netlify or Bolt Cloud first to get a stable HTTPS domain, register that as your redirect URI, and the OAuth flow works correctly.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.