Skip to main content

/o/export/download/\{task_id\}

Endpoint

/o/export/download/\{task_id\}

Overview

Downloads a previously generated export file by task ID.

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 core read access validation.
  • app_id is required for non-global users by read validation rules.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)Dashboard API authentication key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
app_idStringYes (for non-global users)App context used in access validation.
\{task_id\}StringYesLong task ID from /o/export/requestQuery response.

Response

Success Response

CSV file example (download body):

country,total_sessions,new_users
United States,121,11
Spain,87,6

JSON file example (download body):

[
{
"country": "United States",
"total_sessions": 121,
"new_users": 11
},
{
"country": "Spain",
"total_sessions": 87,
"new_users": 6
}
]

Response Fields

FieldTypeDescription
(download body)String or BinaryExport file content retrieved from task storage.

Error Responses

Status Code: 400 Bad Request

{
"result": "Missing filename"
}

Status Code: 400 Bad Request

{
"result": "Export size is 0"
}

Status Code: 400 Bad Request

{
"result": "Export stream does not exist"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
GridFS file modeTask output exists in task_results GridFS bucket with non-zero sizeLoads task metadata and streams stored file bytes with attachment headers.HTTP file stream (non-JSON body)
Legacy inline-data modeTask type is dbviewer, task has inline data, GridFS size is zeroReturns legacy inline JSON payload from task document.HTTP JSON body/file download
Empty-output error modeGridFS size is zero and task is not eligible for inline fallbackReturns explicit export-size error.Wrapped string { "result": "Export size is 0" }

Impact on Other Data

  • Read-only endpoint. Does not modify export/task content.

Audit & System Logs

  • No /systemlogs action is emitted by this endpoint itself.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and read-permission validationReads caller identity for core-read access validation.
countly.long_tasksTask lookup by IDReads task metadata (report_name, type, storage mode).
countly_fs.task_resultsStored export file contentReads and streams export file bytes.

Examples

Example 1: Download task output

/o/export/download/17f0f6c3a2c42cbced96d4a01f88f9a7f45bc7a5?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2

Operational Considerations

  • Download availability depends on task completion and stored output.
  • Large files are streamed from GridFS.

Limitations

  • If task output is empty and not in compatible legacy format, download fails.
  • Invalid or missing task IDs do not produce export output.

Last Updated

2026-02-17