Skip to main content
Version: 25.03

/o/export/requestQuery

Endpoint​

/o/export/requestQuery

Overview​

Creates an asynchronous export task from a target API query and returns a task ID immediately.

Only paths registered as export query producers are accepted. The named endpoint is re-run to build the collection and pipeline that get exported, so any other path is rejected with 400 "Path is not an export query producer".

Authentication​

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

Permissions​

  • Requires authenticated dashboard user access.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)Dashboard API authentication key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
app_idStringNoOptional app ID attached to created export task metadata.
pathStringYesTarget API path to query, including its query string. Must match a registered export query producer (see Supported paths).
methodStringNoOptional method value forwarded to request pipeline.
dataJSON String (Object)NoRequest payload for target query.
dbStringNoIgnored. The database is chosen by the matched export query producer, not by the caller.
typeStringNoExport format (json, csv, xls, xlsx).
filenameStringNoExport base file name (extension is appended from type).
type_nameStringNoTask type label in task metadata (default: tableExport).

Parameter Semantics​

  • path is parsed as a URL. Its pathname must be /o or start with /o/, and it must match a registered producer's path plus its required query parameters; otherwise the request fails with Path is not an export query producer.
  • The producer's required parameters are forced onto path, so the caller cannot switch the target endpoint into a different mode.
  • The export reads from the database declared by the producer (countly, countly_drill, or countly_out).

Supported paths​

Producer pathRequired parametersDatabaseSource
/omethod=views, action=getExportQuerycountlyViews
/o/surveys/survey/datamethod=export, action=getExportQuerycountly_drillSurveys (Enterprise)
/o/heatmaps/exportNonecountlyHeatmaps (Enterprise)

A producer is only available when its feature is enabled.

  • data parse failures fall back to {}.
  • Task metadata stores report file name as filename + "." + type.

Examples​

Example 1: Create async CSV export of the Views table​

/o/export/requestQuery?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
path=/o?method=views%26action=getExportQuery%26app_id=6991c75b024cb89cdc04efd2%26period=30days&
type=csv&
filename=views-30days

Example 2: Create async JSON export of heatmap data​

/o/export/requestQuery?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
path=/o/heatmaps/export?app_id=6991c75b024cb89cdc04efd2&
type=json&
filename=heatmaps

Response​

Success Response​

{
"result": {
"task_id": "17f0f6c3a2c42cbced96d4a01f88f9a7f45bc7a5"
}
}

Response Fields​

FieldTypeDescription
resultObjectWrapped long-task creation payload.
result.task_idStringID of created export task. Use this ID to download task output later.

Error Responses​

Status Code: 400 Bad Request

{
"result": "Missing parameter \"path\""
}

Status Code: 400 Bad Request

{
"result": "Path is not an export query producer"
}

Behavior​

Behavior Modes​

ModeTriggerProcessing PathResponse Shape
Valid request modepath is provided and request validatesCreates long task immediately (force mode), returns wrapped task_id, continues export in background.Wrapped object { "result": { "task_id": "..." } }
Invalid request modepath is missing, unparseable, or not a registered export query producerFails validation before task creation.Wrapped string error (for example missing path)

Impact on Other Data​

  • Creates/updates task metadata and export result files.

Operational Considerations​

Limitations​

  • Returns only task creation response, not final export data.
  • Final export availability depends on task completion and output size.
Implementation details

Audit & System Logs

  • No /systemlogs action is emitted by this endpoint itself for normal task creation flow.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication validationReads caller identity for management-read access validation.
countly.long_tasksAsync export task stateCreates and updates export task records.
countly_fs.task_resultsAsync export output storageStores export result file content for later download.