Skip to main content
Traffical’s config-as-code lives in a .traffical/ directory at the root of your repository. The CLI reads and writes these files and syncs them with the platform. This page is the reference for the file formats; see the CLI page for the commands that act on them.

The .traffical/ directory

.traffical/
├── config.yaml             # Parameters, events, property groups
├── project.yaml            # Which Traffical project this repo syncs with
├── metrics.yaml            # Metrics-as-code (optional)
├── traffical.generated.ts  # Generated types (optional, from generate-types)
└── .gitignore              # Auto-created — ignores .env
FilePurposeCommit to git?
config.yamlParameter, event, and property-group definitionsYes
project.yamlRepo → project link (org + project IDs), written by traffical linkYes
metrics.yamlMetric and fact-source definitionsYes
traffical.generated.tsTypeScript types from traffical generate-typesUsually
.gitignoreCreated automatically to keep .env out of gitYes
The CLI searches for the config starting in the current directory and walking up the tree, so commands work from any subfolder of your repo. Point at a non-default path with traffical --config <path>.
Legacy layout. A single traffical.yaml at the repo root is still parsed for backwards compatibility, as is a project: block inside config.yaml. Both are deprecated in favour of the .traffical/ directory and a dedicated project.yaml. New projects scaffolded by traffical init use the layout above.

config.yaml

The main file. It declares parameters, events, and reusable property groups. Everything declared here becomes synced when you traffical push — its definition turns read-only in the dashboard to prevent drift between your repo and the platform.
version: "1.0"

# Parameters with no namespace prefix
parameters:
  feature_enabled:
    type: boolean
    default: false
    description: Master toggle for the new feature

# Namespace-grouped parameters (the format the CLI writes)
namespaces:
  checkout:
    description: Checkout flow configuration
    parameters:
      button.color:                 # full key: checkout.button.color
        type: string
        default: "#1E6EFB"
        description: Primary button color on checkout
      show_trust_badges:
        type: boolean
        default: false

  pricing:
    parameters:
      discount_pct:                 # full key: pricing.discount_pct
        type: number
        default: 0
        constraints:
          min: 0
          max: 50

events:
  purchase:
    valueType: currency
    unit: USD
    description: Completed purchase

propertyGroups:
  geo:
    description: Geographic context
    properties:
      country: { type: string, dimension: true }

Top-level fields

FieldRequiredDescription
versionYesConfig schema version. Currently always "1.0".
parametersYesMap of parameters with no namespace (may be empty {}).
namespacesNoNamespace-grouped parameters — an alternative to flat parameters.
eventsNoEvent definitions.
propertyGroupsNoReusable property schemas shared across events.
Flat vs. grouped. You can declare a parameter either as a fully-qualified key under parameters (checkout.button.color) or as a local key inside a namespaces: block. They’re equivalent — traffical pull writes the grouped form, but both are accepted on read.

Parameters

A parameter is a typed value with a default. See the concept page for how parameters relate to layers and policies.
catalog.ranking_algo:
  type: string
  default: default
  description: Which ranking algorithm to use
  constraints:
    allowedValues: [default, popularity, random]

Parameter fields

FieldRequiredDescription
typeYesstring, number, boolean, or json.
defaultYesDefault value. Must match type (a json default must be an object or array).
descriptionNoFree-form text shown in the dashboard.
namespaceNoOrganizational grouping. Implicit when declared inside a namespaces: block.
constraintsNoOptional validation — see below.

Constraints

Constraints are enforced at edit time (in the dashboard and on traffical push), not at SDK resolution.
ConstraintApplies toDescription
minnumberMinimum allowed value.
maxnumberMaximum allowed value.
patternstringRegex that values must match.
allowedValuesstring, numberEnum of permitted values.
ui.accent_color:
  type: string
  default: "#E8451C"
  description: Brand accent color used throughout the UI

Events

Event definitions describe the track events your application emits. They generate TypeScript types, let the edge validate incoming payloads, and mark which properties become warehouse dimensions and measures.
events:
  add_to_cart:
    valueType: count
    description: User adds an item to cart
    schemaVersion: "1-0-0"
    schemaEnforcement: warn
    propertyGroups: [geo]
    properties:
      product_id:
        type: string
        required: true
        description: Unique product identifier
      price:
        type: number
        minimum: 0
        measure: true
        measureDisplayName: Unit Price
        desiredDirection: increase
      category:
        type: string
        enum: [gaming, fashion, beauty, coffee, electronics, home]
        dimension: true

Event fields

FieldRequiredDescription
valueTypeYescurrency, count, rate, or boolean.
unitNoFree-form unit (USD, items, percent, …).
descriptionNoFree-form text.
propertiesNoProperty schema for the event payload — see below.
propertyGroupsNoNames of property groups to merge into this event’s schema.
schemaVersionNoSchemaVer string (MODEL-REVISION-ADDITION, e.g. 1-0-0).
schemaEnforcementNooff, warn, or reject. How the edge handles payloads that violate the schema.
schemaEnforcement controls validation: off skips it, warn accepts the event but returns warnings, reject drops invalid events before they reach the pipeline.

Property fields

Each entry under properties: is a field in Traffical’s YAML DSL, which compiles to JSON Schema internally. The same shape is used inside propertyGroups and for nested object/array fields.
FieldApplies toDescription
typeallstring, number, integer, boolean, array, or object. Required.
requiredallWhether the property must be present on the event.
descriptionallFree-form text.
enumscalarAllowed values.
patternstringRegex the value must match.
formatstringdate-time, email, uri, or uuid.
minimum / maximumnumberNumeric bounds.
minLength / maxLengthstringString length bounds.
defaultallDefault value for documentation/codegen.
examplesallExample values for documentation.
dimensionallExtract as a warehouse dimension for slicing metrics.
measurenumberExtract as an additional fact measure for metric creation.
measureDisplayNamenumberDisplay name for the measure in the dashboard.
desiredDirectionnumberincrease or decrease — which way is “good” for this measure.
warehouseTypeallOverride the auto-inferred warehouse column type.
itemsarraySchema for array items (a nested property field).
minItems / maxItemsarrayArray length bounds.
propertiesobjectNested property fields.
additionalPropertiesobjectWhether extra keys are allowed on nested objects.
Mark properties you’ll want to break experiment results down by with dimension: true, and numeric properties you’ll want to build metrics on with measure: true. Both feed the warehouse-native pipeline.

Property groups

Property groups are reusable schemas you can attach to many events with propertyGroups: [name]. They keep shared context (geo, device, session) defined once.
propertyGroups:
  geo:
    description: Geographic context for commerce events
    schemaVersion: "1-0-0"
    properties:
      market:
        type: string
        required: true
        enum: [US, EU, APAC]
        dimension: true
      country:
        type: string
        dimension: true
FieldRequiredDescription
propertiesYesProperty fields (same DSL as event properties).
descriptionNoFree-form text.
schemaVersionNoSchemaVer string.

project.yaml

The repo → project link, written by traffical link (or traffical init). It records which Traffical project and organization this repository syncs with. Safe to commit — edit it via the CLI rather than by hand.
# Traffical project link — managed by `traffical link`.
version: "1.0"
org:
  id: org_DqQZGfRs
  key: acme
project:
  id: proj_ST6qGDbR
  key: mahally
FieldRequiredDescription
versionYesAlways "1.0".
org.idYesOrganization ID (org_…).
org.keyNoHuman-readable org key.
project.idYesProject ID (proj_…).
project.keyNoHuman-readable project key.

metrics.yaml

Optional. Defines metrics and warehouse fact sources as code. Synced with traffical push and imported with traffical import metrics.
version: "1.0"

fact_sources:
  orders:
    sql: SELECT user_id, order_total, created_at FROM analytics.orders
    timestamp_column: created_at
    measures:
      - column: order_total
        type: float64
        displayName: Order Total
        desiredDirection: increase

metrics:
  add_to_cart_rate:
    display_name: Add-to-Cart Rate
    metricType: conversion_rate
    event: add_to_cart
    desiredDirection: increase

  avg_order_value:
    metricType: sum
    fact: orders
    measure: order_total
    unit: USD
    winsorizeAt: 0.99

Top-level fields

FieldRequiredDescription
versionYesAlways "1.0".
metricsYesMap of metric definitions (at least one).
fact_sourcesNoWarehouse-native fact sources referenced by metrics.

Fact source fields

FieldRequiredDescription
sqlYesQuery that produces the fact rows.
timestamp_columnYesColumn used as the event timestamp.
descriptionNoFree-form text.
measuresNoNumeric columns (column, type, displayName, desiredDirection).
dimensionsNoSliceable columns (column, type).

Metric fields

FieldRequiredDescription
metricTypeYesconversion_rate, sum, count, ratio, funnel, or percentile.
display_name / descriptionNoHuman-readable labels.
eventNoEvent this metric is built on (event-based metrics).
fact / measureNoFact source and measure column (warehouse-native metrics).
desiredDirectionNoincrease or decrease.
unitNoDisplay unit.
winsorizeAtNoWinsorization quantile (0–1) to clip outliers.
certifiedNoMark as a certified metric.
filtersNodimension / operator (equals, not_equals, in, not_in) / values.
timeframeNostartDays / endDays attribution window.
numerator / denominatorNo{ fact, measure } pairs for ratio metrics.
percentileNoQuantile (0–1) for percentile metrics.
funnelStepsNoOrdered { event } or { fact } steps for funnel metrics.

Validation

Both config.yaml and metrics.yaml are validated against a JSON Schema on every read. Invalid files fail fast with the offending path and reason, e.g.:
Error: Invalid traffical.yaml at .traffical/config.yaml
Errors:
  - parameters.discount_pct.default: must be number
traffical push --dry-run validates and prints the diff without writing anything to the platform.

Next steps

CLI

The commands that sync these files with Traffical.

Parameters

Typed values with defaults.

Events

Event definitions, schemas, and property groups.

Type-safe events

Generate types from your event definitions.