Skip to main content
Version: 25.03

Star Rating - Create Widget

Endpoint​

/i/feedback/widgets/create

Overview​

Creates a new star-rating widget for an app.

Authentication​

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

Permissions​

Requires star_rating Create permission.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.
app_idStringYesApp ID the widget belongs to.
statusBoolean/StringYesWhether the widget is active.
popup_header_textStringNoHeader text of the rating popup.
popup_comment_calloutStringNoText of the comment field.
popup_email_calloutStringNoText of the contact-by-email option.
popup_button_calloutStringNoText of the submit button.
popup_thanks_messageStringNoMessage shown after submitting.
finalTextStringNoFinal text shown at the end of the flow.
trigger_positionStringNoPosition of the feedback trigger button.
trigger_bg_colorStringNoBackground color of the trigger button.
trigger_font_colorStringNoFont color of the trigger button.
trigger_button_textStringNoText of the trigger button.
trigger_sizeStringNoSize of the trigger button.
hide_stickerBoolean/StringNoHide the trigger button by default.
contact_enableBooleanNoAllow users to leave contact details.
comment_enableBooleanNoAllow users to leave a comment.
consentBooleanNoShow a consent option.
linksArray/StringNoJSON array string of consent links.
ratings_textsArray/StringNoJSON array string of rating labels. Defaults to five labels from "Very dissatisfied" to "Very Satisfied".
rating_symbolStringNoSymbol type used for ratings.
target_pageStringNoTarget page mode.
target_pagesArray/StringNoJSON array string of pages. Defaults to ["/"].
targetingObject/StringNoJSON object string with cohort targeting conditions. Used only when the Cohorts plugin is enabled.
logoStringNoFile name of an uploaded logo.
logoTypeStringNoLogo type.
globalLogoBooleanNoUse the global logo.
internalNameStringNoInternal name of the widget.
appearanceObjectNoAppearance settings.
showPolicyStringNoDisplay policy.

Examples​

Create a widget​

/i/feedback/widgets/create?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
status=true&
popup_header_text=How was your experience?&
target_pages=["/","/pricing"]

Response​

Success Response​

HTTP status 201:

{
"result": "Successfully created 6256d161e8faa7b449e2dd6b"
}

Response Fields​

FieldTypeDescription
resultStringConfirmation that includes the new widget ID.

Error Responses​

  • 400
{
"result": "Invalid params: ..."
}
  • 400
{
"result": {
"error": "Failed to set cohort",
"widgetId": "6256d161e8faa7b449e2dd6b"
}
}
  • 500: the database error message, if the widget could not be stored.

Targeting conditions that are not accepted are also returned as 400. Standard authentication/authorization errors from create validation can also be returned.

Behavior​

  • Applies the widget field preprocessors (target_pages, targeting, links, ratings_texts, hide_sticker, status) and validates the payload.
  • Stores the widget with type rating, a wv value of 1, counters set to 0, display policy afterPageLoad, and all device types (desktop, phone, tablet) enabled.
  • If the Cohorts plugin is enabled and targeting is given, creates a cohort for the widget and stores its ID on the widget.
  • Writes a feedback_widget_created system log entry.

Impact on Other Data​

  • Adds one widget to countly.feedback_widgets.
  • May create a cohort in countly.cohorts.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.feedback_widgetsWidget storageInserts the widget document.
countly.cohortsTargeting cohortsMay create a cohort (when cohorts plugin enabled).
countly.systemlogsAudit trailReceives feedback_widget_created.