Create a derivation rule
Create a new derivation rule. Requires an admin grant on attribute_derivations, and the rule is owned by
your own company.
The rule’s transformation is validated before the rule can exist: the source and target attributes must exist and
be viewable — and the target must additionally grant your company map, since the rule produces values for it —
every expression must parse and type-check against the source attribute’s shape, the result must match the target
attribute’s declared type, every function must resolve. Each failure returns a 400 with a descriptive message.
A rule that closes a cycle in the derivation graph is created anyway; the cycle comes back as a warning on the response.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Body of POST /derivations.
Name of the derivation rule, unique within the owning company.
256"raw_email_to_sha256"
What the rule does, for whoever is deciding whether to accept derived data.
2048"Hashes the raw email address with SHA-256."
The attribute the rule reads from through $source.
The attribute whose value the rule produces. Must differ from source_attribute_id.
The company that owns the rule. Must be the caller's company.
The transformation that produces the target attribute's value from the source attribute's value. Expressions
reference the source attribute's shape through $source — for a rule from raw_email to sha256_hashed_email,
the value property maps to SHA2(NORMALIZE_EMAIL($source.value), 256).
The shape mirrors mapping expressions, except cached_mapping is not allowed: a cached mapping reads values out
of a stored dataset, so there would be nothing to substitute a $source reference into.
Expressions may use the current date or time (CURRENT_DATE, CURRENT_TIMESTAMP, …): the expression runs when a
query resolves the rule, so a rule like birthdate → age in years is correct as of each query that uses it. Enum
constraints and validation expressions on the target attribute do not restrict the transformation, exactly as
they do not restrict a dataset mapping.
- Option 1
- Option 2
The transformation loses information, e.g. hashing.
The transformation is approximate, e.g. bucketing an age into a range.
Which companies, besides the one that owns the rule, may have the rule applied to their data. A rule grants a
single thing, so there is one use dimension. Only Narrative can share a rule broadly — with all companies or
with everyone outside an exclusion set.
Explains the lossy and imprecise flags to whoever is deciding whether to accept derived data.
2048"Hashing is one-way, so the original address cannot be recovered."
Breaks ties when more than one rule reaches the same target attribute — cheapest first. Resolution over multi-step paths sums the cost of every rule on a path and prefers the cheapest total.
x >= 1Inactive rules are never applied.
Response
Created
Unique identifier of the derivation rule.
42
Name of the derivation rule, unique within the owning company.
256"raw_email_to_sha256"
What the rule does, for whoever is deciding whether to accept derived data.
2048"Hashes the raw email address with SHA-256."
Which companies, besides the one that owns the rule, may have the rule applied to their data. A rule grants a
single thing, so there is one use dimension. Only Narrative can share a rule broadly — with all companies or
with everyone outside an exclusion set.
The transformation that produces the target attribute's value from the source attribute's value. Expressions
reference the source attribute's shape through $source — for a rule from raw_email to sha256_hashed_email,
the value property maps to SHA2(NORMALIZE_EMAIL($source.value), 256).
The shape mirrors mapping expressions, except cached_mapping is not allowed: a cached mapping reads values out
of a stored dataset, so there would be nothing to substitute a $source reference into.
Expressions may use the current date or time (CURRENT_DATE, CURRENT_TIMESTAMP, …): the expression runs when a
query resolves the rule, so a rule like birthdate → age in years is correct as of each query that uses it. Enum
constraints and validation expressions on the target attribute do not restrict the transformation, exactly as
they do not restrict a dataset mapping.
- Option 1
- Option 2
Explains the lossy and imprecise flags to whoever is deciding whether to accept derived data. null when
the rule has no note.
2048Breaks ties when more than one rule reaches the same target attribute — cheapest first. Resolution over multi-step paths sums the cost of every rule on a path and prefers the cheapest total.
x >= 1Id of the user who created the rule.
Id of the user who last updated the rule.
Populated on create and update responses; empty on reads.

