Skip to content

Export tasks ​

An export task collects the history of selected points on one device into a CSV or JSON file. Tasks run in the background: create a task, wait for status to reach completed, then request a short-lived download URL.

MethodEndpointDescription
GET/api/v2/data-download-tasks/List export tasks in the organization
GET/api/v2/projects/{project_id}/data-download-tasks/List export tasks in a project
GET/api/v2/projects/{project_id}/data-download-tasks/options/Retrieve export limits
POST/api/v2/projects/{project_id}/data-download-tasks/Create an export task
GET/api/v2/projects/{project_id}/data-download-tasks/{id}/Retrieve an export task
POST/api/v2/projects/{project_id}/data-download-tasks/{id}/cancel/Cancel an export task
POST/api/v2/projects/{project_id}/data-download-tasks/{id}/retry/Retry an export task
GET/api/v2/projects/{project_id}/data-download-tasks/{id}/download/Get a download URL
DELETE/api/v2/projects/{project_id}/data-download-tasks/{id}/Delete an export task

Tasks cannot be edited; PUT and PATCH return 405.

Visibility ​

Manager and Owner callers see every task in the projects they can access. Read-only and Operator callers see only tasks created with their own credentials. Operators can cancel, retry, download, and delete only their own tasks. The can_* fields on each task report what the caller can do.

The export task object ​

json
{
  "id": 15,
  "task_key": "6f1c2a7e-3b9d-4c55-9a51-2f0f6c7d8e90",
  "organization_id": 3,
  "project_id": "proj_AbCdEfGhIj",
  "project_name": "Greenhouse Alpha",
  "device_id": 42,
  "device_agri_id": "d-1000-abcd",
  "name": "ColdRoom_2factors_20260201-20260203",
  "format": "csv",
  "start_time": 1769904000,
  "end_time": 1770076800,
  "factor_count": 2,
  "status": "completed",
  "status_display": "Completed",
  "error_code": "",
  "error_msg": null,
  "estimated_raw_count": 5760,
  "progress_stage": "",
  "processed_row_count": 2880,
  "row_count": 2880,
  "file_size": 183204,
  "create_time": "2026-02-03T08:00:00Z",
  "updated_time": "2026-02-03T08:01:12Z",
  "started_at": "2026-02-03T08:00:05Z",
  "completed_at": "2026-02-03T08:01:12Z",
  "expires_at": "2026-05-04T08:01:12Z",
  "can_cancel": false,
  "can_retry": false,
  "can_download": true,
  "can_delete": true,
  "project_access_removed": false
}
FieldTypeDescription
idintegerTask ID
task_keystringTask UUID
project_id, project_namestringProject at creation time; kept after the project is deleted
device_id, device_agri_idinteger, stringExported device
namestringFile name stem
formatstringcsv or json
start_time, end_timeintegerExport range in Unix seconds
factor_countintegerNumber of points exported
statusstringSee Task status
error_code, error_msgstring | nullFailure details
estimated_raw_count, processed_row_count, row_countinteger | nullProgress counters
file_sizeinteger | nullFile size in bytes
create_time, updated_time, started_at, completed_atstring | nullLifecycle times
expires_atstring | nullTime the file is removed
can_cancel, can_retry, can_download, can_deletebooleanActions available to the caller
project_access_removedbooleantrue when the caller lost access to the project. Such tasks show only id, format, status, status_display, create_time, and the can_* fields.

Retrieve an export task and Create an export task also return factor_ids (the exported point agri_id values) and field_mapping (column headers by agri_id).

Task status ​

StatusMeaning
pendingCreated, waiting to be queued
queuedQueued for the export worker
exportingExport in progress
cancellingCancel requested while exporting
completedFile ready to download
failedExport failed; see error_code and error_msg
cancelledCancelled

List organization export tasks ​

http
GET /api/v2/data-download-tasks/

Returns visible tasks across the organization, newest first, one page at a time.

Authentication ​

Bearer token. Minimum role: Read-only.

Query parameters ​

NameTypeRequiredDescription
project_idstringNoReturn tasks of one project
statusstringNoReturn tasks in one status
pageintegerNoPage number. Default 1.
page_sizeintegerNoTasks per page, 1–100. Default 50.

Example request ​

bash
curl 'https://dl.yengear.com/api/v2/data-download-tasks/?status=completed&page_size=20' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'

Example response ​

json
{
  "success": true,
  "data": {
    "count": 1,
    "next": null,
    "previous": null,
    "results": [{ "id": 15, "status": "completed", "name": "ColdRoom_2factors_20260201-20260203" }],
    "has_active_tasks": false
  },
  "error": null
}

has_active_tasks is true while a matching task is pending, queued, exporting, or cancelling. next and previous are absolute URLs.

Responses ​

List project export tasks ​

http
GET /api/v2/projects/{project_id}/data-download-tasks/

Returns visible tasks of one project, newest first.

Authentication ​

Bearer token. Minimum role: Read-only.

Path parameters ​

NameTypeRequiredDescription
project_idstringYesProject identifier

Responses ​

  • 200: Array of export task objects, not paginated.
  • 403: The project is outside the token's scope.
  • 404: No such project.

Retrieve export limits ​

http
GET /api/v2/projects/{project_id}/data-download-tasks/options/

Returns the formats and limits that apply to new tasks.

Authentication ​

Bearer token. Minimum role: Read-only.

Example response ​

json
{
  "success": true,
  "data": {
    "formats": ["csv", "json"],
    "default_format": "csv",
    "max_factor_count": 200,
    "max_range_days": 90,
    "max_raw_records": 1000000,
    "file_retention_days": 90,
    "presigned_url_seconds": 60
  },
  "error": null
}
FieldDescription
max_factor_countPoints per task
max_range_daysLongest export range
max_raw_recordsRaw records per task
file_retention_daysDays a finished file is kept
presigned_url_secondsLifetime of a download URL

Read limits from this endpoint instead of hard-coding them.

Create an export task ​

http
POST /api/v2/projects/{project_id}/data-download-tasks/

Creates an export task for points on one device and queues it.

Authentication ​

Bearer token. Minimum role: Operator.

Headers ​

NameRequiredDescription
Idempotency-KeyNoUp to 64 characters. Repeating a request with the same key returns the existing task with 200 instead of creating another.

Path parameters ​

NameTypeRequiredDescription
project_idstringYesProject identifier

Request body ​

NameTypeRequiredDescription
device_idintegerYesDevice ID in the project
factorsstring[]YesPoint agri_id values of that device. Duplicates are removed.
start_timeintegerYesRange start, Unix seconds
end_timeintegerYesRange end, Unix seconds; not earlier than start_time
formatstringNocsv (default) or json
namestringNoFile name stem, up to 128 characters. Generated from the device name, point count, and dates when omitted.

Example request ​

bash
curl -X POST 'https://dl.yengear.com/api/v2/projects/proj_AbCdEfGhIj/data-download-tasks/' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: coldroom-2026-02-01' \
  -d '{
    "device_id": 42,
    "factors": ["d-1000-abcd-1-00", "d-1000-abcd-1-10"],
    "start_time": 1769904000,
    "end_time": 1770076800,
    "format": "csv"
  }'

Responses ​

  • 201: The new export task object, with factor_ids and field_mapping.
  • 200: A task with the same Idempotency-Key already exists; it is returned unchanged.
  • 400: Validation error. error.reason is one of INVALID_DEVICE, INVALID_FACTORS, TOO_MANY_FACTORS, INVALID_TIME_RANGE, EXPORT_RANGE_TOO_LARGE, INVALID_FORMAT, INVALID_NAME, or INVALID_IDEMPOTENCY_KEY.
  • 403 INVALID_FACTORS: A point is not on the selected device.
  • 404 DEVICE_NOT_FOUND: The device is not in the project.
  • 503 EXPORT_TEMPORARILY_UNAVAILABLE: The export service is unavailable.

Retrieve an export task ​

http
GET /api/v2/projects/{project_id}/data-download-tasks/{id}/

Returns one task, including factor_ids and field_mapping. Poll this endpoint to follow progress.

Authentication ​

Bearer token. Minimum role: Read-only.

Path parameters ​

NameTypeRequiredDescription
project_idstringYesProject identifier
idintegerYesTask ID

Responses ​

Cancel an export task ​

http
POST /api/v2/projects/{project_id}/data-download-tasks/{id}/cancel/

Cancels a task. A pending or queued task becomes cancelled; an exporting task becomes cancelling until the worker stops.

Authentication ​

Bearer token. Minimum role: Operator.

Responses ​

  • 200: The updated export task object.
  • 409 TASK_NOT_CANCELLABLE: The task has already finished.

Retry an export task ​

http
POST /api/v2/projects/{project_id}/data-download-tasks/{id}/retry/

Queues a failed task again.

Authentication ​

Bearer token. Minimum role: Operator.

Responses ​

  • 200: The updated export task object, with status pending.
  • 409 TASK_NOT_RETRYABLE: Only failed tasks can be retried.

Get a download URL ​

http
GET /api/v2/projects/{project_id}/data-download-tasks/{id}/download/

Returns a signed URL for the finished file. The URL expires after presigned_url_seconds (60 seconds by default), so request it right before downloading.

Authentication ​

Bearer token. Minimum role: Operator. The organization's plan must be active.

Example request ​

bash
curl 'https://dl.yengear.com/api/v2/projects/proj_AbCdEfGhIj/data-download-tasks/15/download/' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'

Example response ​

json
{
  "success": true,
  "data": { "download_url": "https://example-bucket.s3.amazonaws.com/exports/..." },
  "error": null
}

Responses ​

  • 200: data.download_url holds the signed URL.
  • 403: Role below Operator, or the plan is read-only.
  • 404 EXPORT_FILE_MISSING: The file no longer exists in storage.
  • 409 EXPORT_FILE_MISSING: The task is not completed.
  • 410 EXPORT_FILE_EXPIRED: The file passed its retention period.
  • 503 EXPORT_TEMPORARILY_UNAVAILABLE: File storage is unavailable.

Delete an export task ​

http
DELETE /api/v2/projects/{project_id}/data-download-tasks/{id}/

Deletes a finished task and its file from storage.

Authentication ​

Bearer token. Minimum role: Operator.

Responses ​

  • 204: Task and file deleted.
  • 409 TASK_NOT_DELETABLE: Only completed, failed, or cancelled tasks can be deleted.
  • 503 EXPORT_TEMPORARILY_UNAVAILABLE: The file could not be removed from storage.