Preview a base model's rules together
const url = 'https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/origin-mapping/previews';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"rules":[{"type":"ElementMappingRule","id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","name":"example","description":"example","nestedRules":[{"type":"ElementMappingRule","targetType":"example","targetTraits":["example"],"sourcePath":"example","sourceElementIds":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"],"root":false,"targetOwnedRelation":"example","originModelId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}],"targetOwnerId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","targetType":"example","targetTraits":["example"],"sourcePath":"example","sourceElementIds":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"],"root":false,"targetOwnedRelation":"example","originModelId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/origin-mapping/previews \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "rules": [ { "type": "ElementMappingRule", "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "description": "example", "nestedRules": [ { "type": "ElementMappingRule", "targetType": "example", "targetTraits": [ "example" ], "sourcePath": "example", "sourceElementIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "root": false, "targetOwnedRelation": "example", "originModelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ], "targetOwnerId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "targetType": "example", "targetTraits": [ "example" ], "sourcePath": "example", "sourceElementIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "root": false, "targetOwnedRelation": "example", "originModelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }'Preview the top-level rules of one base model together, in the one run a generation from that base model makes, without persisting changes, and answer each rule with its part of that run. A rule the run starts at alone is answered as the single-rule preview answers it; beside other rules, with what the generation makes of it, which can hold more than its single-rule preview: the run’s scope holds every rule’s pins, and its relation rules find the output of every rule. A rule whose preview fails is left out of the answer rather than failing the others.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Body
Section titled “Request Body”object
The top-level element rules to preview, each with its id and all reading the same base model. Rules the target model stores beside them run as stored.
object
The type of mapping rule (discriminator for polymorphism).
Unique identifier for this rule. Can be client-provided or server-generated.
The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.
The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.
Nested mapping rules owned by this rule. Order matters - rules are executed in list order.
A mapping rule, discriminated by its own type.
object
The type of mapping rule (discriminator for polymorphism).
Unique identifier for this rule. Can be client-provided or server-generated.
The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.
The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.
Optional reference to an existing element to attach this rule’s output to.
The target element type to create for each matched source element.
The traits each created element carries beside targetType. Where an owned relation holds the element, the relation decides its form: its default trait is added where the element carries no member of the default’s exclusive group, and replaces a member the relation refuses. Absent when the rule names none.
Path expression to select source elements. Mutually exclusive with sourceElementIds.
Explicit source element IDs to map. Mutually exclusive with sourcePath.
Whether the mapped elements are root elements in the target model.
Target owned relation name for nested element mappings. Required when nested under another element mapping.
Reference to the origin model from which source elements are selected.
object
The type of mapping rule (discriminator for polymorphism).
Unique identifier for this rule. Can be client-provided or server-generated.
The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.
The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.
Optional reference to an existing element to attach this rule’s output to.
The target attribute name on the parent element’s target type.
Optional path expression to navigate from the parent’s source context.
Value mapping for the right side of the join (typically from target element).
object
Path expression to navigate to target elements.
Attribute options to extract value from (tries each in order until one has a value).
object
The template expression string.
Variable bindings for the template. Keys are variable names referenced in the expression.
object
Default value if no value is found.
Value transformers to apply in order.
object
The type of value mapper (e.g., “lowercase”, “uppercase”, “replace”).
Optional configuration options for the mapper.
object
A rule that writes a relation on the elements its parent rule generates. The target elements come from exactly one source, which is why targetElementMappingId, selectElement and targetQuery are mutually exclusive and at least one of those three, joinOn or sourcePath must be present. A bare sourcePath names no target of its own: each element it reaches is answered by whatever already corresponds to it in the model being produced.
object
The type of mapping rule (discriminator for polymorphism).
Unique identifier for this rule. Can be client-provided or server-generated.
The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.
The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.
Optional reference to an existing element to attach this rule’s output to.
The target relation name on the parent element’s target type.
Optional path expression to navigate from the parent’s source context.
Reference to the element mapping that produces the target elements for this relation.
Selects the relation’s target directly, by naming one element of the target model or one of its dependencies.
object
The selected element.
Optional element-filter expression narrowing when the selection applies, evaluated against the source element the relation is written for.
object
Value mapping for the right side of the join (typically from target element).
object
Path expression to navigate to target elements.
Attribute options to extract value from (tries each in order until one has a value).
object
The template expression string.
Variable bindings for the template. Keys are variable names referenced in the expression.
object
Default value if no value is found.
Value transformers to apply in order.
object
The type of value mapper (e.g., “lowercase”, “uppercase”, “replace”).
Optional configuration options for the mapper.
object
Value mapping for the right side of the join (typically from target element).
object
Path expression to navigate to target elements.
Attribute options to extract value from (tries each in order until one has a value).
object
The template expression string.
Variable bindings for the template. Keys are variable names referenced in the expression.
object
Default value if no value is found.
Value transformers to apply in order.
object
The type of value mapper (e.g., “lowercase”, “uppercase”, “replace”).
Optional configuration options for the mapper.
object
A Core DSL match query selecting the relation’s candidates from the run’s target scope, compiled against the target metamodel (match $c isa Class). joinOn picks which candidate a source element relates to. Read before every other target reference; a blank query counts as absent.
Whether a source element whose join matches none of the targetQuery candidates gets an external element generated for it, carrying the joined value as its key. When false, a join matching nothing fails the run. Refused without a targetQuery.
Whether the rule runs only for the source elements the rules before it on the same relation, under the same parent rule, resolved no target for. Several rules on one relation are the routes of one end, tried in their stored order. When false, the rule runs for every source element. A rule carrying it with no rule on its relation before it is refused on save and at run start. A targetQuery rule that a marked rule follows hands a source element it finds nothing for on to that rule instead of refusing it.
Optional reference to an existing element to attach this rule’s output to.
The target element type to create for each matched source element.
The traits each created element carries beside targetType. Where an owned relation holds the element, the relation decides its form: its default trait is added where the element carries no member of the default’s exclusive group, and replaces a member the relation refuses. Absent when the rule names none.
Path expression to select source elements. Mutually exclusive with sourceElementIds.
Explicit source element IDs to map. Mutually exclusive with sourcePath.
Whether the mapped elements are root elements in the target model.
Target owned relation name for nested element mappings. Required when nested under another element mapping.
Reference to the origin model from which source elements are selected.
Responses
Section titled “Responses”OK
object
Each rule’s preview by rule id, in the order the rules were submitted. A rule whose preview failed is absent.
object
object
The ID of the rule that was previewed.
The elements that would be generated by this rule.
object
object
object
object
object
Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.
The values the element holds that its type declares no property for; absent when none.
A value an element holds under no binding its type declares, kept so a round trip loses nothing.
object
object
object
object
Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.
A structure the import holds without an element, kept with its own properties inside the layer of the element that refers to it. A node is held once; any other place that refers to it holds a reference to it instead.
object
The property that links the holding element or the enclosing node to this node; absent on a node no property links to.
The node’s global identity in the format’s own terms; absent on an anonymous node.
A label unique within the model, set only on an anonymous node that is referred to more than once.
Whether this entry only points at the node another entry holds under the same localId.
Whether the node is an ordered list, whose entries are its members in order.
Where an element was derived from: the source and rules models, and per property the source values it read.
object
object
object
object
Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.
object
object
object
Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.
Source element IDs that would be mapped.
How reversible the previewed rule’s value mappings are, per target attribute. The rule editor renders these grades and their assumption sentences verbatim rather than deriving its own, which is why the preview always answers with them.
object
The weakest finding; the rule as a whole is no better than this.
object
The attribute rule whose value mapping this classifies. One rule can write a target attribute through several attribute rules, so the attribute alone does not say which one a finding is about.
REVERSIBLE — the derived value determines the base value on its own. REVERSIBLE_WITH_IDENTITY_STORE — it determines it only together with the stored links, which resolve which base element the value came from. REVERSIBLE_WITH_PROVENANCE — it does not determine the base value, but every value that fed it is recorded per run, so reversing it is a lookup of those inputs rather than an attempt to undo the computation. CONDITIONALLY_REVERSIBLE — it determines the base value only while an assumption about the data holds. No classifier arm answers this today, because a step that reads the base records what it read; it remains for content no run recorded. NOT_REVERSIBLE — nothing to reverse to, or nothing recorded to look up: a value the base model never held, or a query in a language whose value projection cannot run.
Why it classifies that way, phrased for the authoring UI.
What a reader without this record has to take on trust, composed from the query the author wrote — “If voornaam or achternaam contains a space, this value cannot be split back into its parts.” Independent of the grade: the grade says whether the derivation can be reversed here, which for anything a run records is yes, while this says what the same value costs someone holding only the value. Absent when it costs them nothing, which is most findings, and always absent on a NOT_REVERSIBLE finding — nothing was recorded there, so there is no record for a reader to be holding the value without. Render it verbatim rather than deriving your own wording.
The relations this rule would write. A preview that answered with elements only would show a relation rule as having done nothing.
One relation a previewed rule would write, and where its target came from.
object
The element the relation is written on — the source end of the edge, and an element the run generates. Despite the name it is unrelated to sourceElementIds on the enclosing result, which means the origin-model elements the rule matched.
Name of the relation written.
The element the relation points at.
Where the target came from.
The relation rules that established the edge, in the order they wrote it. An edge two rules both established is reported once, naming both.
One row per source element a counterpart was sought for, so a resolution can be reported per source element rather than only per written edge.
What one source element resolved to, for any relation rule: the counterpart of whatever a navigation reaches, an element named outright, one a join or a target query found, or one another rule generated. One row per source element the rule tried to find a target for; one a guard turned away, or a join read no value on, has none.
object
The relation rule that resolved it.
The origin-model element a counterpart was sought for.
What it resolved to. Empty means nothing stands for this source element, which cannot be told apart from an element that was generated but whose origin was never recorded — lineage names a source element only inside the property entries a rule writes.
One element that stands for a source element, and on what evidence.
object
The corresponding element.
The evidence that it corresponds.
The identity of the scope snapshot the element lives in, as targetScope lists it. Present only for IN_SCOPE.
Candidates that stronger evidence outranked, so a reader can be told a linked element was passed over rather than have it silently discarded.
One element that stands for a source element, and on what evidence.
object
The corresponding element.
The evidence that it corresponds.
The identity of the scope snapshot the element lives in, as targetScope lists it. Present only for IN_SCOPE.
Relations the run refused to write: several distinct targets for a relation holding one, and a target query that answered several candidates, or none with no later rule on the relation to hand the source element to. A preview reports these as data so the refusal can be attributed to the card that caused it; a real generation still fails with 422.
A relation the run refused to write, because one source element resolved several distinct targets for a relation that holds only one.
object
The refused rule.
The element the relation would have been written on.
The origin-model element whose resolution produced several targets.
Name of the relation that holds only one.
The distinct targets that were resolved.
The engine’s own account of the refusal, including the repair.
The run’s target scope in feeder order: every model the previewed run could point into without generating it, and the elements of each its relations landed on. A snapshot the target does not already depend on and a relation landed in is one saving adds as a dependency.
One model a mapping run may point into without generating it: which model at which version, why it is in scope, whether the target already reaches it, and which of its elements the run’s relations landed on.
object
What makes the snapshot one — the model and commit, or an external document’s location and metamodel. What a counterpart’s scope names.
Why the snapshot is in scope: a built-in element model of the target metamodel, a model the mapping pins, one the target already depends on, or one the base model depends on.
How the snapshot is pinned; only INTERNAL and EXTERNAL are ever declared.
The model the snapshot is a version of; absent for an external document.
The commit it was read at; absent for a built-in and an external document.
The version name it was pinned by, absent where it was pinned at a commit.
Where an external document is read from.
The model’s name.
Whether the target reaches the snapshot without the run declaring it. False is a snapshot a relation landing in adds as a dependency when the run is saved.
The snapshot’s elements the run’s relations landed on.
One element of a scope snapshot, named as the snapshot’s own metamodel names it.
object
Generated element ID to the origin element it came from. Carried because the two per-rule maps cannot be zipped positionally: one skips elements with no source and the other does not, so their indices diverge.
object
Generated element ID to the generated element that holds it and the relation it is held through. An element placed in something the preview did not generate is absent, so a consumer drawing the output as a tree puts it at the top.
object
object
Total count of elements that would be generated.
Example
{ "previews": { "additionalProperty": { "generatedElements": [ { "extensionLayer": [ { "kind": "attribute" } ], "lineage": { "properties": [ { "propertyType": "ATTRIBUTE", "sources": [ { "propertyType": "ATTRIBUTE", "role": "PRIMARY" } ] } ] } } ], "reversibility": { "overall": "REVERSIBLE", "findings": [ { "reversibility": "REVERSIBLE" } ] }, "generatedRelations": [ { "targetProvenance": "GENERATED" } ], "counterpartResolutions": [ { "counterparts": [ { "provenance": "GENERATED" } ], "passedOver": [ { "provenance": "GENERATED" } ] } ], "targetScope": [ { "feeder": "BUILT_IN", "kind": "INTERNAL" } ] } }}Bad request
An RFC 9457 problem document, always sent as application/problem+json.
object
Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.
The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.
Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "example", "violations": [ { "property": "example", "message": "example" } ]}Not found
An RFC 9457 problem document, always sent as application/problem+json.
object
Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.
The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.
Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "example", "violations": [ { "property": "example", "message": "example" } ]}default
Section titled “default”Error
An RFC 9457 problem document, always sent as application/problem+json.
object
Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.
The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.
Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "example", "violations": [ { "property": "example", "message": "example" } ]}