diff --git a/apps/formbricks-com/app/docs/api/management/surveys/page.mdx b/apps/formbricks-com/app/docs/api/management/surveys/page.mdx
index c04ce5c1d7..08e834b142 100644
--- a/apps/formbricks-com/app/docs/api/management/surveys/page.mdx
+++ b/apps/formbricks-com/app/docs/api/management/surveys/page.mdx
@@ -14,6 +14,7 @@ This set of API can be used to
- [List All Surveys](#list-all-surveys)
- [Get Survey](#get-survey-by-id)
- [Create Survey](#create-survey)
+- [Update Survey](#update-survey-by-id)
- [Delete Survey](#delete-survey-by-id)
You will need an API Key to interact with these APIs.
@@ -472,6 +473,121 @@ This set of API can be used to
---
+## Update Survey by ID {{ tag: 'PUT', label: '/api/v1/management/surveys/' }}
+
+
+
+
+ Update a survey by its ID
+
+ ### Mandatory Headers
+
+
+
+ Your Formbricks API key.
+
+
+
+ ### Body
+
+
+ ```json {{ title: 'cURL' }}
+ {
+ "name": "My renamed Survey",
+ "redirectUrl":"https://formbricks.com",
+ "type":"web"
+ }
+ ```
+
+
+
+
+
+
+
+
+ ```bash {{ title: 'cURL' }}
+ curl -X POST https://app.formbricks.com/api/v1/management/surveys/ \
+ --header 'Content-Type: application/json' \
+ --header 'x-api-key: ' \
+ -d '{"name": "My renamed Survey"}'
+ ```
+
+
+
+
+
+ ```json {{title:'200 Success'}}
+ {
+ "data": {
+ "id": "cloqzeuu70000z8khcirufo60",
+ "createdAt": "2023-11-09T09:23:42.367Z",
+ "updatedAt": "2023-11-09T09:23:42.367Z",
+ "name": "My renamed Survey",
+ "redirectUrl": null,
+ "type": "link",
+ "environmentId": "clonzr6vc0009z8md7y06hipl",
+ "status": "inProgress",
+ "welcomeCard": {
+ "html": "Thanks for providing your feedback - let's go!",
+ "enabled": false,
+ "headline": "Welcome!",
+ "timeToFinish": false
+ },
+ "questions": [
+ {
+ "id": "l9rwn5nbk48y44tvnyyjcvca",
+ "type": "openText",
+ "headline": "Why did you leave the platform?",
+ "required": true,
+ "inputType": "text"
+ }
+ ],
+ "thankYouCard": {
+ "enabled": true,
+ "headline": "Thank you!",
+ "subheader": "We appreciate your feedback."
+ },
+ "hiddenFields": {
+ "enabled": true,
+ "fieldIds": []
+ },
+ "displayOption": "displayOnce",
+ "recontactDays": null,
+ "autoClose": null,
+ "delay": 0,
+ "autoComplete": 50,
+ "closeOnDate": null,
+ "surveyClosedMessage": null,
+ "productOverwrites": null,
+ "singleUse": {
+ "enabled": false,
+ "isEncrypted": true
+ },
+ "verifyEmail": null,
+ "pin": null,
+ "triggers": [],
+ "attributeFilters": []
+ }
+ }
+ ```
+
+ ```json {{ title: '401 Not Authenticated' }}
+ {
+ "code": "not_authenticated",
+ "message": "Not authenticated",
+ "details": {
+ "x-Api-Key": "Header not provided or API Key invalid"
+ }
+ }
+ ```
+
+
+
+
+
+---
+
## Delete Survey by ID {{ tag: 'DELETE', label: '/api/v1/management/surveys/' }}
diff --git a/apps/web/app/api/v1/management/surveys/[surveyId]/route.ts b/apps/web/app/api/v1/management/surveys/[surveyId]/route.ts
index 33663b04e2..f8a0314abe 100644
--- a/apps/web/app/api/v1/management/surveys/[surveyId]/route.ts
+++ b/apps/web/app/api/v1/management/surveys/[surveyId]/route.ts
@@ -64,7 +64,10 @@ export async function PUT(
return responses.notFoundResponse("Survey", params.surveyId);
}
const surveyUpdate = await request.json();
- const inputValidation = ZSurvey.safeParse(surveyUpdate);
+ const inputValidation = ZSurvey.safeParse({
+ ...survey,
+ ...surveyUpdate,
+ });
if (!inputValidation.success) {
return responses.badRequestResponse(
"Fields are missing or incorrectly formatted",