Skip to main content
Version: 24.05

Compliance Hub - Consent Search

Endpoint​

/o/consent/search

Overview​

Searches consent change history (countly.consent_history) with filtering, sorting, and skip/limit pagination.

Authentication​

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

Permissions​

Requires compliance_hub Read permission.

Request Parameters​

ParameterTypeRequiredDescription
app_idStringYesTarget app ID.
sSearchStringNoText search used against device ID.
filter / queryJSON String (Object)NoJSON-stringified MongoDB filter object. query takes precedence when both are sent.
project / projectionJSON String (Object)NoProjection object for returned fields.
sortJSON String (Object)NoExplicit sort object.
iSortCol_0NumberNoDataTables sort column index.
sSortDir_0StringNoDataTables sort direction (asc/desc).
limit / iDisplayLengthNumberNoPage size. If omitted or 0, no limit is applied.
skip / iDisplayStartNumberNoOffset. Default 0.
periodStringNoOptional period filter applied to ts.
sEchoString or NumberNoEcho value returned in DataTables-style response.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

Examples​

Search consents with pagination​

/o/consent/search?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
sSearch=device_123&
limit=20&
skip=0

Response​

Success Response​

{
"sEcho": "1",
"iTotalRecords": 150,
"iTotalDisplayRecords": 40,
"aaData": [
{
"device_id": "device_123",
"uid": "user_1",
"type": "sessions",
"change": {
"sessions": true
},
"ts": 1739788800000
}
]
}

Response Fields​

FieldTypeDescription
sEchoString or NumberEcho value from request.
iTotalRecordsNumberTotal records matched for base query.
iTotalDisplayRecordsNumberCount of records matching the full search filter (including sSearch and period).
aaDataArrayMatching consent_history documents for the requested page.

Error Responses​

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 400
{
"result": "Missing parameter \"app_id\""
}
  • 401
{
"result": "User does not have right"
}
  • 400
{
"result": "Error. Please check logs."
}

Behavior​

Behavior Modes​

ModeTriggerProcessing PathResponse Shape
Search modeApp has consent history recordsQueries consent_history with filter, sort, and skip/limit pagination.Raw DataTables-style object
Empty modeNo consent history records for the app (base query)Returns without running the paged query.Raw DataTables-style object with empty aaData

Impact on Other Data​

  • Read-only endpoint.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission checksReads member account and feature access for read validation.
countly.appsApp validation/context loadingValidates app_id and app context for search scope.
countly.consent_historyConsent change history sourceCounts and reads consent change records for the app.