Skip to content

Preview a mapping rule

POST
/models/{modelId}/semantic-correspondences/{correspondenceId}/rules/preview
curl --request POST \
--url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/semantic-correspondences/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/rules/preview \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "derivedElementId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "rule": { "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" }, "nestedDerivedElementIds": { "additionalProperty": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } }'

Preview what a correspondence-owned mapping rule would record, without persisting anything. Returns the base elements the rule matches — one materialized link per match on save — and how reversible its value mappings are. The rule runs against the correspondence’s base model, which grants the source: unlike origin-mapping rules it needs no configured origin.

modelId
required
string format: uuid
correspondenceId
required
string format: uuid
Media typeapplication/json

A mapping rule owned by a correspondence, describing how one derived element is derived from the correspondence’s base model. Authored in the canonical downward direction (base to derived): the base model is the source, this model the target.

object
derivedElementId
required

The element the rule derives, fixed for the rule’s lifetime. The rule selects which base elements it is derived from.

string format: uuid
rule
required

The rule. Its originModelId is set from the owning correspondence’s base model, so a client-supplied value is ignored. An element rule nested in it, at any depth, explains a derived element of its own, named in nestedDerivedElementIds, and saving records its links the same way, stamped with the nested rule’s id.

object
type
required

The type of mapping rule (discriminator for polymorphism).

string
Allowed values: ElementMappingRule AttributeMappingRule RelationMappingRule
id

Unique identifier for this rule. Can be client-provided or server-generated.

string format: uuid
name

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.

string
description

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.

string
nestedRules

Nested mapping rules owned by this rule. Order matters - rules are executed in list order.

Array

A mapping rule, discriminated by its own type.

One of: discriminator: type
ElementMappingRule
object
type
required

The type of mapping rule (discriminator for polymorphism).

string
Allowed values: ElementMappingRule AttributeMappingRule RelationMappingRule
id

Unique identifier for this rule. Can be client-provided or server-generated.

string format: uuid
name

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.

string
description

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.

string
nestedRules
Array recursive
targetOwnerId

Optional reference to an existing element to attach this rule’s output to.

string format: uuid
type
required
string
Allowed value: ElementMappingRule
targetType
required

The target element type to create for each matched source element.

string
>= 1 characters
targetTraits

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.

Array<string>
sourcePath

Path expression to select source elements. Mutually exclusive with sourceElementIds.

string
sourceElementIds

Explicit source element IDs to map. Mutually exclusive with sourcePath.

Array<string>
root

Whether the mapped elements are root elements in the target model.

boolean
targetOwnedRelation

Target owned relation name for nested element mappings. Required when nested under another element mapping.

string
originModelId
required

Reference to the origin model from which source elements are selected.

string format: uuid
targetOwnerId

Optional reference to an existing element to attach this rule’s output to.

string format: uuid
type
required
string
Allowed value: ElementMappingRule
targetType
required

The target element type to create for each matched source element.

string
>= 1 characters
targetTraits

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.

Array<string>
sourcePath

Path expression to select source elements. Mutually exclusive with sourceElementIds.

string
sourceElementIds

Explicit source element IDs to map. Mutually exclusive with sourcePath.

Array<string>
root

Whether the mapped elements are root elements in the target model.

boolean
targetOwnedRelation

Target owned relation name for nested element mappings. Required when nested under another element mapping.

string
originModelId
required

Reference to the origin model from which source elements are selected.

string format: uuid
nestedDerivedElementIds

The derived element each element rule nested in the rule explains, keyed by the nested rule’s id. A save refuses a nested element rule without an id or an entry here, an entry naming no nested rule of the tree, and a derived element the enclosing rule’s derived element does not hold. Not stored on the rule: the links a save records carry the rule’s id and the derived element, so the map is rebuilt from them.

object
key
additional properties
string format: uuid

OK

Media typeapplication/json

What a correspondence-owned rule would record, computed without persisting anything.

object
baseElementIds
required

The base elements the rule matches; one link per entry is materialized on save.

Array<string>
values
required

What the rule would write for each match, in baseElementIds order. Shorter than baseElementIds where a match generated no element of its own, so pair the two by baseElementId rather than by position.

Array<object>

What a correspondence rule would write for one base element it matched, taken from the element the read-only run generated and discarded. What the rule’s attribute mappings produced, not what they declare.

object
baseElementId
required

The base element the rule matched, and whose match produced these values.

string format: uuid
attributes
required

The values the rule’s attribute mappings wrote, keyed by the targetAttribute each mapping was authored with. An attribute whose mapping found nothing on this base element is absent rather than present and empty.

object
key
additional properties
Array
reversibility
required

How well a rule could be run backwards — lifting derived values back to the base values they came from. Recorded while authoring; nothing executes on it yet.

object
overall
required

The weakest finding; the rule as a whole is no better than this.

string
Allowed values: REVERSIBLE REVERSIBLE_WITH_IDENTITY_STORE REVERSIBLE_WITH_PROVENANCE CONDITIONALLY_REVERSIBLE NOT_REVERSIBLE
findings
required
Array<object>
object
ruleId

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.

string format: uuid
targetAttribute
required
string
reversibility
required

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.

string
Allowed values: REVERSIBLE REVERSIBLE_WITH_IDENTITY_STORE REVERSIBLE_WITH_PROVENANCE CONDITIONALLY_REVERSIBLE NOT_REVERSIBLE
reason
required

Why it classifies that way, phrased for the authoring UI.

string
assumption

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.

string
nested
required

What each element rule nested in the rule, at any depth, selected, in the order the tree holds them. Empty when the rule nests none. A nested rule without an id is left out. Saving records one link per entry’s base element.

Array<object>

What one nested element rule selected, across every match of the rule enclosing it.

object
ruleId
required

The nested rule.

string format: uuid
derivedElementId
required

The derived element the request names for the nested rule, or null where it names none. A save refuses a nested rule without one; a preview still answers what it selects.

string | null format: uuid
baseElementIds
required

The base elements the nested rule selected, distinct, in the order the run reached them. Saving records one link each.

Array<string>

Example

{
"reversibility": {
"overall": "REVERSIBLE",
"findings": [
{
"reversibility": "REVERSIBLE"
}
]
}
}

Bad request

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

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.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

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.

string
violations

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.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

Not found

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

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.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

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.

string
violations

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.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

Error

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

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.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

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.

string
violations

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.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}