Tutorial: Setting Up Data Transformation Rules
Rules let you automatically transform inventory data as it flows through Carfluence. This tutorial covers creating rules for common scenarios.
What Are Rules?
Rules are condition-action pairs. When a vehicle matches the conditions, the actions are applied. Rules run automatically during every sync.
Example 1: Price Floor for Used Vehicles
Ensure no used vehicle is listed below $5,000:
POST /api/v1/rules
{
"name": "Used Vehicle Price Floor",
"conditions": [
{"field": "condition", "operator": "equals", "value": "used"},
{"field": "price", "operator": "less_than", "value": "5000"}
],
"actions": [
{"type": "set_field", "field": "price", "value": "5000"}
]
}Example 2: Auto-Tag Luxury Vehicles
Tag vehicles from luxury brands:
POST /api/v1/rules
{
"name": "Tag Luxury Brands",
"conditions": [
{"field": "make", "operator": "in", "value": "BMW,Mercedes-Benz,Audi,Lexus,Porsche"}
],
"actions": [
{"type": "set_field", "field": "tags", "value": "luxury"}
]
}Example 3: Standardize Color Names
Normalize color variations:
POST /api/v1/rules
{
"name": "Normalize Black Colors",
"conditions": [
{"field": "exterior_color", "operator": "in", "value": "Blk,BLK,Ebony,Jet Black,Crystal Black Pearl"}
],
"actions": [
{"type": "set_field", "field": "exterior_color", "value": "Black"}
]
}Testing Rules
Before activating a rule, test it against sample data:
POST /api/v1/rules/:id/test
{
"vehicle": {
"vin": "1HGCM82633A004352",
"make": "BMW",
"model": "X5",
"price": "3500",
"condition": "used",
"exterior_color": "Jet Black"
}
}The response shows what the vehicle would look like after the rule is applied, without actually modifying any data.
Rule Ordering
Rules execute in creation order. Keep this in mind when rules might conflict — the last rule to modify a field wins.
Operators Reference
| Operator | Description |
|---|---|
equals | Exact match |
not_equals | Does not match |
contains | String contains |
in | Value in comma-separated list |
less_than | Numeric less than |
greater_than | Numeric greater than |
is_empty | Field is null or empty |
is_not_empty | Field has a value |