With Transformations, you can change data as it flows through Segment to:
With Segment's Public API, you can use Transformations for several use cases:
newEventName
in the createTransformation
or updateTransformation
API call.propertyRenames
in the createTransformation
or updateTransformation
API call.propertyValueTransformations
in the createTransformation
or updateTransformation
API call.propertyValueTransformations
. However, Segment doesn't support changing fields outside the properties or traits object with propertyRenames
.Visit Segment's Transformations docs to learn more.
Creates a new Transformation.
• When called, this endpoint may generate the Transformation Created
event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
name required | string (name) The name of the Transformation. |
sourceId required | string (sourceId) The Source to be associated with the Transformation. |
destinationMetadataId | string (destinationMetadataId) The optional Destination metadata id to be associated with the Transformation. |
enabled required | boolean (enabled) If the Transformation should be enabled. |
if required | string (if) If statement (FQL) to match events. For standard event matchers, use the following: Track -> "event='<eventName>'" Identify -> "type='identify'" Group -> "type='group'" |
drop | boolean (drop) Optional boolean value if the Transformation should drop the event entirely when the if statement matches, ignores all other transforms. |
newEventName | string (newEventName) Optional new event name for renaming events. Works only for 'track' event type. |
Array of objects (propertyRenames) Optional array for renaming properties collected by your events. | |
Array of objects (propertyValueTransformations) Optional array for transforming properties and values collected by your events. Limited to 10 properties. | |
Array of objects (fqlDefinedProperties) Optional array for defining new properties in FQL. Currently limited to 1 property. | |
allowProperties | Array of strings (allowProperties) Optional array for allowing properties from your events. |
object (hashPropertiesConfiguration) Optional object for hashing properties within an event. |
OK
Resource not found
Validation failure
Too many requests
{- "name": "Name of the new transformation",
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "enabled": true,
- "newEventName": "new-event-name",
- "propertyRenames": [
- {
- "oldName": "old-name",
- "newName": "new-name"
}, - {
- "oldName": "another-name-old",
- "newName": "another-name-new"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.some-property",
- "context.some-property"
], - "propertyValue": "some property value"
}
], - "if": "event = 'Example Event V1'"
}
{- "data": {
- "transformation": {
- "id": "2c0vWrvonKH66Ml527NOmS8LHF0",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "Name of the new transformation",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "if": "event = 'Example Event V1'",
- "newEventName": "new-event-name",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-name",
- "newName": "new-name"
}, - {
- "oldName": "another-name-old",
- "newName": "another-name-new"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.some-property",
- "context.some-property"
], - "propertyValue": "some property value"
}
], - "allowProperties": [ ],
- "fqlDefinedProperties": [ ]
}
}
}
Lists all Transformations in the Workspace.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
object (PaginationInput) Pagination options. This parameter exists in v1. Example: pagination=pagination.count=20 |
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.transformations.listTransformations()) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "transformations": [
- {
- "id": "2c0vWLHfrXlOr5Y0dO3S0yGYW8r",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "Name of the new transformation",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "if": "event = 'Example Event Beta'",
- "newEventName": "new-event-name",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-name",
- "newName": "new-name"
}, - {
- "oldName": "another-name-old",
- "newName": "another-name-new"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "context.some-property",
- "properties.some-property"
], - "propertyValue": "some property value"
}
], - "allowProperties": [ ]
}, - {
- "id": "2c0vVod8qrbEsOTf9McBWT7Qizc",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "Name of the new transformation",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "if": "event = 'Example Event Alpha'",
- "newEventName": "new-event-name",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-name",
- "newName": "new-name"
}, - {
- "oldName": "another-name-old",
- "newName": "another-name-new"
}
], - "propertyValueTransformations": [ ],
- "allowProperties": [ ]
}, - {
- "id": "c5EmPMhTGmgwoas8YCKXgs",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "Order cancelled event rename in destination",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "destinationMetadataId": "54521fd725e721e32a72eebb",
- "if": "event = 'Order Cancelled'",
- "newEventName": "order_cancelled",
- "propertyDrops": [ ],
- "propertyRenames": [ ],
- "propertyValueTransformations": [ ],
- "allowProperties": [ ]
}, - {
- "id": "xx6AySGeFExzdv2Gw2EuhV",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "Order Completed",
- "enabled": true,
- "sourceId": "rh5BDZp6QDHvXFCkibm1pR",
- "destinationMetadataId": "54521fd725e721e32a72eebb",
- "destinationId": "fP7qoQw2HTWt9WdMr718gn",
- "if": "event = \"Order Completed\"",
- "propertyDrops": [
- "properties.userId",
- "properties.secretValue"
], - "propertyRenames": [ ],
- "propertyValueTransformations": [ ],
- "allowProperties": [ ]
}, - {
- "id": "pHrD51Ds35Zjfka84yXQE6",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "updated-name",
- "enabled": true,
- "sourceId": "rh5BDZp6QDHvXFCkibm1pR",
- "destinationMetadataId": "547610a5db31d978f14a5c4e",
- "if": "event=\"my-event\"",
- "newEventName": "my-updated-event",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-property",
- "newName": "new-property"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.another-property"
], - "propertyValue": "another property value"
}
], - "allowProperties": [ ]
}, - {
- "id": "rBoBnPKiAek36M192XJsYQ",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "User clicked edit identify event",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "if": "type = 'identify'",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "Group",
- "newName": "group"
}
], - "propertyValueTransformations": [ ],
- "allowProperties": [ ]
}, - {
- "id": "ks7SJDAn4XvW4VykJSQVz7",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "User clicked event rename",
- "enabled": true,
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "if": "event = 'User Clicked'",
- "newEventName": "user_clicked",
- "propertyDrops": [ ],
- "propertyRenames": [ ],
- "propertyValueTransformations": [ ],
- "allowProperties": [ ]
}
], - "pagination": {
- "current": "MA==",
- "totalEntries": 7
}
}
}
Deletes a Transformation.
• When called, this endpoint may generate the Transformation Deleted
event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.transformations.deleteTransformation('2c0vVuRdDmJ3UQkVjd5WxaA3dar')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "status": "SUCCESS"
}
}
Gets a Transformation.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.transformations.getTransformation('pHrD51Ds35Zjfka84yXQE6')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "transformation": {
- "id": "pHrD51Ds35Zjfka84yXQE6",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "updated-name",
- "enabled": true,
- "sourceId": "rh5BDZp6QDHvXFCkibm1pR",
- "destinationMetadataId": "547610a5db31d978f14a5c4e",
- "if": "event=\"my-event\"",
- "newEventName": "my-updated-event",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-property",
- "newName": "new-property"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.another-property"
], - "propertyValue": "another property value"
}
], - "allowProperties": [ ],
- "fqlDefinedProperties": [ ]
}
}
}
Updates an existing Transformation.
• When called, this endpoint may generate the Transformation Updated
event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
name | string (name) The name of the Transformation. |
sourceId | string (sourceId) The optional Source to be associated with the Transformation. |
destinationMetadataId | string (destinationMetadataId) The optional Destination metadata to be associated with the Transformation. |
enabled | boolean (enabled) If the Transformation should be enabled. |
if | string (if) If statement (FQL) to match events. For standard event matchers, use the following: Track -> "event='<eventName>'" Identify -> "type='identify'" Group -> "type='group'" |
drop | boolean (drop) Optional boolean value if the Transformation should drop the event entirely when the if statement matches, ignores all other transforms. |
newEventName | string (newEventName) Optional new event name for renaming events. Works only for 'track' event type. |
Array of objects (propertyRenames) Optional array for renaming properties collected by your events. | |
Array of objects (propertyValueTransformations) Optional array for transforming properties and values collected by your events. Limited to 10 properties. | |
Array of objects (fqlDefinedProperties) Optional array for updating properties defined in FQL. Currently limited to 1 property. | |
allowProperties | Array of strings (allowProperties) Optional array for allowing properties from your events. |
object (hashPropertiesConfiguration) Optional object for hashing properties within an event. |
OK
Resource not found
Validation failure
Too many requests
{- "name": "updated-name",
- "sourceId": "rh5BDZp6QDHvXFCkibm1pR",
- "enabled": true,
- "destinationMetadataId": "547610a5db31d978f14a5c4e",
- "if": "event=\"my-event\"",
- "newEventName": "my-updated-event",
- "propertyRenames": [
- {
- "newName": "new-property",
- "oldName": "old-property"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.another-property"
], - "propertyValue": "another property value"
}
]
}
{- "data": {
- "transformation": {
- "id": "pHrD51Ds35Zjfka84yXQE6",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "updated-name",
- "enabled": true,
- "sourceId": "rh5BDZp6QDHvXFCkibm1pR",
- "destinationMetadataId": "547610a5db31d978f14a5c4e",
- "if": "event=\"my-event\"",
- "newEventName": "my-updated-event",
- "propertyDrops": [ ],
- "propertyRenames": [
- {
- "oldName": "old-property",
- "newName": "new-property"
}
], - "propertyValueTransformations": [
- {
- "propertyPaths": [
- "properties.another-property"
], - "propertyValue": "another property value"
}
], - "allowProperties": [ ],
- "fqlDefinedProperties": [ ]
}
}
}