Skip to main content

Dashboards - Update Widget

Endpoint

/i/dashboards/update-widget

Overview

Updates an existing widget in a dashboard. The endpoint validates access, sanitizes note content, optionally removes isPluginWidget for core widgets, and saves updated widget fields.

Authentication

Countly API supports three authentication methods:

  1. API key query parameter: api_key=YOUR_API_KEY
  2. Auth token query parameter: auth_token=YOUR_AUTH_TOKEN
  3. Auth token header: countly-token: YOUR_AUTH_TOKEN

Permissions

No separate feature permission flag is checked. Dashboard sharing rules enforce:

  • edit access required to update,
  • explicit payload for view-only and no-access paths.

Request Parameters

ParameterTypeRequiredDescription
dashboard_idStringYesDashboard ID (24-char ObjectId string).
widget_idStringYesWidget ID (24-char ObjectId string).
widgetJSON String (Object)YesJSON-stringified widget update payload.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

widget Object Structure

FieldTypeRequiredDescription
widget_typeStringNoWidget type. Used for note sanitization checks.
appsArrayNoApp IDs; inaccessible app IDs are removed before save.
featureStringNoIf set to core, endpoint removes isPluginWidget from stored document.
contenthtmlStringNoFor note widgets, content is sanitized and escaped.
titleStringNoWidget title.
positionArrayNoWidget grid position.
sizeArrayNoWidget size.

Decoded example:

{
"widget_type": "analytics",
"feature": "core",
"apps": ["6991c75b024cb89cdc04efd2"],
"title": "Sessions (Last 30 Days)",
"metrics": ["t", "u"],
"position": [0, 0],
"size": [4, 3]
}

Response

Success Response

{
"result": "Success"
}

Response Fields

FieldTypeDescription
resultStringSuccess or error message in wrapped responses.
errorBooleanPresent in access-denied branches.
edit_access_deniedBooleantrue when user has view access but no edit access.
dashboard_access_deniedBooleantrue when user has no dashboard access.

Error Responses

  • 400
{
"result": "Invalid parameter: dashboard_id"
}
  • 400
{
"result": "Invalid parameter: widget_id"
}
  • 400
{
"result": "Such dashboard and widget combination does not exist."
}
  • 500
{
"result": "Failed to update widget"
}
  • 200 (view-only access)
{
"error": true,
"edit_access_denied": true
}
  • 200 (no dashboard access)
{
"error": true,
"dashboard_access_denied": true
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Update widgetUser has edit accessParses widget, sanitizes note content, filters app IDs, updates widget document, logs update.Wrapped { "result": "Success" }
View-only deniedUser has view but not edit accessStops without update.Raw object with error and edit_access_denied
No access deniedUser has no dashboard accessStops without update.Raw object with error and dashboard_access_denied

Impact on Other Data

  • Updates widget document in countly.widgets.
  • Emits dashboard widget updated event for dependent processors.

Audit & System Logs

ActionTriggerPayload
widget_editedAfter successful widget update{ before, update } object

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and dashboard-share access checksReads current member record and group/share context for edit/view validation.
countly.dashboardsDashboard-widget relationship validationConfirms widget belongs to dashboard before update.
countly.widgetsWidget persistenceUpdates widget document via findAndModify.
countly.systemlogsAudit trailWrites widget_edited entry.

Examples

Update analytics widget

/i/dashboards/update-widget?
dashboard_id=65e1f3d2a4f41a5f6f6d7701&
widget_id=65e1f5f8a4f41a5f6f6d7703&
widget={
"widget_type":"analytics",
"feature":"core",
"apps":["6991c75b024cb89cdc04efd2"],
"title":"Sessions by Day",
"metrics":["t"],
"position":[0,0],
"size":[6,3]
}

Update note widget

/i/dashboards/update-widget?
dashboard_id=65e1f3d2a4f41a5f6f6d7701&
widget_id=65e1f5f8a4f41a5f6f6d7703&
widget={
"widget_type":"note",
"feature":"core",
"apps":["6991c75b024cb89cdc04efd2"],
"title":"Team Note",
"contenthtml":"<p>Review this week's funnel drop-off</p>"
}

Limitations

  • Invalid JSON in widget is logged and then handled through later validation/update branches; it does not return a dedicated parse-error response.
  • The endpoint does not perform schema-level validation for every widget-specific key.

Last Updated

2026-02-17