Skip to main content

List formulas

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

/o/calculated_metrics/metrics

Overview

Returns formulas available to the current user in the app.

Authentication

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

Permissions

Requires formulas Read permission.

Request Parameters

ParameterTypeRequiredDescription
app_idStringYesTarget app ID.
for_widgetsBoolean/StringNoIf provided, returns only _id and title.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

Examples

/o/calculated_metrics/metrics?
app_id=64f5c0d8f4f7ac0012ab3456
/o/calculated_metrics/metrics?
app_id=64f5c0d8f4f7ac0012ab3456&
for_widgets=true

Response

Success Response

[
{
"_id": "67bd31c92e7f0b0012ab4567",
"title": "Revenue per Session",
"description": "Revenue divided by sessions",
"key": "revenue_per_session",
"visibility": "global",
"format": "float",
"dplaces": 2,
"unit": "USD",
"formula": "[...]",
"shared_email_edit": [],
"app": "64f5c0d8f4f7ac0012ab3456",
"formula_hash": "8e49d217047eafee994c3c8a4a1efcbb",
"owner_id": "64f5c0d8f4f7ac0012ab9999"
}
]

Response Fields

FieldTypeDescription
[]ArrayFormulas visible to current user in this app.
[]._idStringFormula ID.
[].titleStringFormula title.
[].visibilityStringglobal or private.
[].formulaStringStringified builder formula payload.

Error Responses

No explicit error response is returned by this handler; on DB failure, an empty array may be returned.

Visibility Filtering

  • Global formulas.
  • Formulas owned by current user.
  • Private formulas shared with current user's email.

Behavior

  • Uses visibility filter for non-global admins.
  • Excludes expression field from response.
  • When for_widgets is provided, response contains only _id and title.
Implementation details

Database Collections

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