Skip to main content

Surveys - Edit Survey

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint

/i/surveys/survey/edit

Overview

Updates an existing Survey widget.

Authentication

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions

  • Surveys: Update permission.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key authentication
auth_tokenStringYes (or api_key)Auth token authentication
app_idStringYesApp ID
widget_idStringYesWidget ID
questionsString (JSON Array)YesSurvey questions
msgString (JSON Object)NoMessage config
appearanceString (JSON Object)NoAppearance config
statusBoolean/StringNoActive status

Examples

/i/surveys/survey/edit?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&widget_id=67b9db56f67aab0012cd8899&name=Product Feedback v2&questions=[{"id":"q1","type":"text","question":"How can we improve next?","required":false}]

Response

Success Response

{
"result": "Success"
}

Response Fields

FieldTypeDescription
resultStringUpdate status

Error Responses

  • HTTP 400 - Invalid parameters:
{
"result": "Invalid params: ..."
}
  • HTTP 404 - Unknown widget:
{
"result": "Widget not found"
}

Behavior

  • Parses and preprocesses widget properties such as msg, appearance, targeting, and questions.
  • Survey edits require questions; missing questions return Missing params: 'questions'.
  • Validates question definitions before updating; invalid question structure returns Error in param 'questions'.
  • Updates feedback_widgets by widget_id. Appearance fields are stored under appearance.<field>.
  • If delete_logo is set and no new logo file is uploaded, deletes the stored logo and clears appearance.logo.
  • If targeting changes, updates, creates, or deletes the linked cohort and recalculates cohort steps when needed.
  • Returns Success after widget/cohort updates, or specific cohort/upload error messages when follow-up work fails.
  • Emits surveys_widget_edited and, when applicable, cohort_edited system log actions.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.feedback_widgetsEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.
countly.cohortsEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.