Skip to main content

Data Transformations - Create Rule

Endpoint

/i/data-manager/transformation

Enterprise Only This API is available exclusively in Countly Enterprise.

Overview

Creates a transformation rule. Depending on transformation.transformationProcessTarget, it either:

  • applies to incoming data only and returns immediate success, or
  • starts a long task for historical processing and returns a task reference.

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

Permissions

Requires data_manager_transformations Create permission.

Request Parameters

ParameterTypeRequiredDescription
app_idStringYesTarget app ID.
transformationJSON String (Object)YesJSON-stringified transformation definition. Example (decoded): {"actionType":"rename","parentEvent":"Playback Started","transformTarget":["state"],"transformResult":"playback_state","transformationProcessTarget":"incoming"}
rerunBoolean StringNoSystem-use flag for background execution callbacks. Do not send this in normal API usage.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

transformation Object Structure

FieldTypeRequiredDescription
actionTypeStringYesOperation type: rename, merge, change-value, copy-to-user-custom. Behavior depends on parentEvent: event merge (parentEvent=""), segment-level actions (parentEvent="event_key"), or custom-property actions (parentEvent="CUSTOM_PROPERTY"). Invalid combinations return 500 Error.
transformTargetArrayYesSource key(s) or event(s) to transform. For merge, provide multiple source values. For rename/change-value/copy-to-user-custom, typically one source key.
transformResultStringYesTarget key/name/value after transformation (for example target event name, segment name, property name, or replacement value).
transformationProcessTargetStringNoProcessing scope: incoming (default), existing, or both. incoming returns immediate "Success"; existing and both start async historical processing and return result.task_id.
parentEventStringConditionalDomain selector. Use event key for segment-level actions, CUSTOM_PROPERTY for custom user property actions, and empty string for event-level merge.
targetRegexStringConditionalRequired for change-value; also used when regex-based rename/merge is enabled.
isRegexBoolean/StringNoEnables regex-based rename matching.
isRegexMergeBoolean/StringNoEnables regex-based merge matching.
sourceEventDeleteBoolean/StringNoOptional source cleanup flag used by merge workflows.
isExistingEventBoolean/StringNoOptional merge behavior flag for existing event handling.
statusStringNoInitial rule status. Defaults to ENABLED when omitted.

Decoded example:

{
"actionType": "merge",
"parentEvent": "",
"transformTarget": ["Playback Started", "Playback Resumed"],
"transformResult": "Playback Unified",
"transformationProcessTarget": "existing"
}

Configuration Impact

SettingDefaultAffectsUser-visible impact
COUNTLY_CONFIG_PROTOCOLhttpLong-task callback URL construction for historical processing (existing / both)If this is incorrect for your deployment, historical transformation runs may fail and return runtime errors instead of completing.
COUNTLY_CONFIG_HOSTNAMElocalhostLong-task callback URL construction for historical processing (existing / both)If this host is not reachable by the server itself, historical transformation runs may fail and return runtime errors.

Response

Success Response

Incoming-only mode (transformationProcessTarget=incoming):

"Success"

Historical mode (transformationProcessTarget=existing or both):

{
"result": {
"task_id": "03ccb0c8ac773298f62f8bdb5d0f8869cb78f788"
}
}

Response Fields

FieldTypeDescription
(root value)StringRoot string value for incoming-only mode ("Success").
result.task_idStringLong-task ID for historical processing modes.

Error Responses

  • 400
{
"result": "Long task runtime error"
}
  • 500
{
"result": "Error"
}
  • 400 (auth validation)
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Incoming-onlytransformationProcessTarget=incoming (or omitted/default)Saves transformation rule and applies it to new incoming data only.Raw root string: "Success"
HistoricaltransformationProcessTarget=existing or bothSaves transformation rule, schedules asynchronous historical processing, and starts background execution.Wrapped object with result.task_id

Impact on Other Data

  • Creates transformation rule records in countly.datamanager_transforms.
  • Schedules background long-task execution for historical modes (existing / both).
  • Updates historical datasets affected by the selected transformation target.
  • Refreshes Data Manager transformation cache for the app.

Audit & System Logs

ActionTriggerPayload
dm-transformationAfter successful transformation rule creation{"transform":"json_string","id":"rule_id"}

Database Collections

CollectionUsed forData touched by this endpoint
countly.datamanager_transformsStores transformation rule definitionsInserts new transformation documents (for example actionType, parentEvent, transformTarget, transformResult, transformationProcessTarget, status, app).
countly.long_tasksTracks background processing for historical runsCreates long-task records for existing/both processing, including task metadata, status, and execution request details.
countly.systemlogsAudit trailWrites dm-transformation audit entries with transformation payload and created rule ID.

Examples

Incoming-only segment rename

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"Playback Started",
"transformTarget":["state"],
"transformResult":"playback_state",
"actionType":"rename",
"transformationProcessTarget":"incoming"
}

Historical event merge

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"",
"transformTarget":["Playback Started","Playback Resumed"],
"transformResult":"Playback Unified",
"actionType":"merge",
"transformationProcessTarget":"existing"
}

Incoming-only segment-to-user copy

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"Playback Started",
"transformTarget":["Content Type"],
"transformResult":"last_content_type",
"actionType":"copy-to-user-custom",
"transformationProcessTarget":"incoming"
}

Historical custom property rename

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"CUSTOM_PROPERTY",
"transformTarget":["legacy_plan"],
"transformResult":"plan_tier",
"actionType":"rename",
"transformationProcessTarget":"existing"
}

Historical custom property value normalization

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"CUSTOM_PROPERTY",
"transformTarget":["plan_tier"],
"transformResult":"premium",
"actionType":"change-value",
"targetRegex":"/gold|platinum/",
"transformationProcessTarget":"existing"
}

Historical + incoming segment value normalization (both)

/i/data-manager/transformation?
app_id=6991c75b024cb89cdc04efd2&
transformation={
"parentEvent":"Playback Started",
"transformTarget":["state"],
"transformResult":"started",
"actionType":"change-value",
"targetRegex":"/^.*$/",
"transformationProcessTarget":"both"
}

Operational Considerations

  • Historical modes are asynchronous and return result.task_id immediately.
  • Use long-task monitoring flows to track completion and diagnose failures.
  • Incoming mode is synchronous and returns immediate success without historical backfill.

Limitations

  • transformation must be valid JSON string; malformed payload returns generic 500 Error.
  • Unsupported or invalid action/field combinations return generic 500 Error.
  • change-value execution paths expect targetRegex; missing/invalid regex can fail during transformation processing.
  • rerun is reserved for system background callbacks and should not be used directly by API clients.


Last Updated

2026-02-16