Skip to main content

Data Migration - Import

Endpoint

/i/datamigration/import

Overview

Starts a migration import from an uploaded archive file or an existing server file path.

Authentication

Countly API supports three authentication methods:

  1. API key query parameter: api_key=YOUR_API_KEY
  2. Auth token query parameter: auth_token=YOUR_AUTH_TOKEN
  3. Auth token header: countly-token: YOUR_AUTH_TOKEN

This endpoint also supports scoped import tokens created by o/datamigration/createimporttoken.

Permissions

Requires data_migration Create permission (or valid scoped import token for this route).

Request Parameters

ParameterTypeRequiredDescription
import_fileFileConditionalMigration archive file upload (.tar.gz) when importing via upload.
existing_fileStringConditionalFull path to existing import archive on server.
test_conNumber/StringNoIf provided, endpoint only validates connectivity and returns valid.
exportidStringNoExport ID hint used in import flow metadata.
argsJSON String (Object)NoOptional JSON-stringified helper args.
api_keyStringConditionalRequired if auth_token is not provided and no scoped token is used.
auth_tokenStringConditionalRequired if api_key is not provided and no scoped token is used.

Response

Success Response

Connectivity test mode:

{
"result": "valid"
}

Import started:

{
"result": "data-migration.import-started"
}

Response Fields

FieldTypeDescription
resultStringStatus key for import test/start or error details.

Error Responses

  • 404
{
"result": "data-migration.import-file-missing"
}
  • 404
{
"result": "data-migration.could-not-find-file"
}
  • 404
{
"result": "data-migration.import-process-exist"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Connection testtest_con providedSkips import and validates route reachability.Wrapped { "result": "valid" }
Upload importimport_file providedReturns start message, then imports asynchronously in background.Wrapped start status key
Existing-file importexisting_file provided and existsReturns start message, then imports asynchronously from file path.Wrapped start status key

Impact on Other Data

  • Creates/imports files under plugin import workspace.
  • Runs background import that can write to many Countly collections for migrated apps.

Audit & System Logs

ActionTriggerPayload
import_finished / import_failedBackground import completion/failureImport app IDs/names and export ID context
import_finished_response_ok / import_finished_response_failedRemote callback reporting outcomeCallback delivery metadata

Database Collections

CollectionUsed forData touched by this endpoint
countly.data_migrationsMigration status tracking (via helper progress/report flow)Updates/creates migration status records during import lifecycle.
countly.systemlogsAudit trailWrites import lifecycle actions.
countly.* and countly_drill.*Imported app data targetsBackground import writes migrated application data into corresponding collections.

Examples

Start import from uploaded archive

/i/datamigration/import?
exportid=f9b35d90be5f2240eafced7c6bfdf130856cd0a7

Validate remote import token connection

/i/datamigration/import?
test_con=1

Start import from existing server file

/i/datamigration/import?
existing_file=/var/backups/countly/f9b35d90be5f2240eafced7c6bfdf130856cd0a7.tar.gz

Operational Considerations

  • Import processing is asynchronous; HTTP response confirms start, not completion.
  • Large imports can take significant time and are tracked through migration status and logs.

Limitations

  • Upload/import can be blocked by server file-size limits (for example web-server body-size settings).
  • Import lock checks prevent duplicate active import processes for the same export folder name.

Last Updated

2026-02-17