Skip to main content

/o/date_presets/getById

Endpoint

/o/date_presets/getById

Overview

Returns one preset by ID when the caller has access through ownership or sharing.

Authentication

  • API Key (parameter): api_key=YOUR_API_KEY
  • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
  • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

Permissions

  • Requires authenticated dashboard user.
  • Access to the preset itself is filtered by owner/share rules.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)Dashboard API authentication key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
preset_idStringYesPreset ID (24-char hex).
app_idStringYesRequired by argument validation.

Response

Success Response

{
"_id": "6992de8e6fbee4231c404429",
"name": "Marketing Review",
"range": ["7days", "today"],
"share_with": "selected-users",
"created_at": 1771232910,
"edited_at": 1771234302,
"owner_id": "6991c7de024cb89cdc04efd6",
"fav": false,
"shared_email_edit": ["editor@example.com"],
"shared_email_view": ["viewer@example.com"],
"shared_user_groups_edit": ["6992ad9f87f8467de103390a"],
"shared_user_groups_view": [],
"sort_order": 0,
"is_owner": true
}

Response Fields

FieldTypeDescription
_idStringPreset ID.
nameStringPreset name.
rangeString, Array, or ObjectStored period definition.
share_withStringSharing mode.
created_atNumberCreation timestamp (seconds).
edited_atNumberLast edit timestamp (seconds), when present.
owner_idStringOwner member ID.
favBooleanWhether current user marked this preset as favorite.
shared_email_editArrayEditable email list.
shared_email_viewArrayView email list.
shared_user_groups_editArrayEditable user-group list.
shared_user_groups_viewArrayView user-group list.
sort_orderNumberDisplay order.
is_ownerBooleanTrue if caller owns preset or is global admin.

Error Responses

Status Code: 400 Bad Request

{
"result": "Not enough args"
}

Status Code: 400 Bad Request

{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}

Status Code: 500 Internal Server Error

{
"result": "Could not find preset"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Accessible presetCaller is global admin or matches owner/share rulesLoads preset, computes is_owner, converts fav to caller-specific boolean.Raw preset object
Inaccessible/missing presetNo matching preset under visibility filterReturns not-found branch.Wrapped object: { "result": "Could not find preset" }

Impact on Other Data

  • This endpoint is read-only and does not modify stored data.

Database Collections

CollectionUsed forData touched by this endpoint
countly.date_presetsSource of preset detailsReads one preset by _id with ownership/share filter and returns caller-adjusted view fields (fav, is_owner).
countly.membersAuthentication and caller identity resolutionResolves caller identity for ownership and sharing checks.

Examples

Example 1: Read preset by ID

/o/date_presets/getById?api_key=YOUR_API_KEY&app_id=6991c75b024cb89cdc04efd2&preset_id=6992de8e6fbee4231c404429

Limitations

  • app_id is required by argument validation even though lookup is based on preset_id and visibility rules.
  • Additional custom fields can appear if they were stored during preset create/update.

Last Updated

2026-02-17