Preview connecting an element to a dependency
const url = 'https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/elements/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/connection-preview';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"dependencyId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","modelId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","versionRef":"example","choices":{"additionalProperty":{"decision":"USE_THEIRS","counterpartId":"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/elements/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/connection-preview \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "dependencyId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "modelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "versionRef": "example", "choices": { "additionalProperty": { "decision": "USE_THEIRS", "counterpartId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } } }'How the elements that an element whose type represents a model owns as copies compare with the version of that model one of the model’s internal dependencies pins: which DEPENDENCY_CONNECT would replace, which offer a choice, and which stay owned. Read-only and computed on demand at the model’s main branch head, or at the head of ref when given, so a caller previews against its draft as it stands. Asked with the choices a DEPENDENCY_CONNECT would be staged with, it answers what that connection does, and marks each copy that cannot give way with the reason. Without choices, every copy whose counterpart is settled counts as replaced and every other copy as kept; note that a staged DEPENDENCY_CONNECT replaces only the copies its choices name. The element must be of a type whose metamodel declares representsModel.
The model compared with is named by exactly one of dependencyId, a dependency the model has, or modelId, a model on the platform the model need not depend on yet, at versionRef. The second form compares as though the dependency had been created by a staged DEPENDENCY_CREATE (same access, owner and metamodel rules; a model reached only transitively is promoted), without writing anything; counterpart ids are that model’s element ids. A modelId the model already depends on directly is compared as its dependency is, at the pin it has.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The element to connect, one of a type whose metamodel declares representsModel.
Query Parameters
Section titled “Query Parameters”The ref to compare at, a model_branch document id, read as GET /models/{modelId}?ref= reads it: a draft is its owner’s alone. When omitted, the model’s main branch is read.
Request Bodyrequired
Section titled “Request Bodyrequired”What a preview of connecting an element whose type represents a model compares with: exactly one of dependencyId and modelId.
object
The internal dependency of the model the element would be connected to.
A model on the platform the element would be connected to, through a dependency the model need not have yet.
With modelId: omitted or @HEAD for the head of its main branch, or the name of one of its versions, as DEPENDENCY_CREATE takes it. Ignored with dependencyId.
What connecting does with each copy, keyed by the copy’s id, as a DEPENDENCY_CONNECT would be staged with. Omitted, every copy whose counterpart is settled counts as replaced.
object
What connecting an element to a dependency does with one copy the element owns: put the named counterpart in its place (USE_THEIRS, with counterpartId), or keep the copy (KEEP_MINE, without one).
object
The element of the connected model that takes the copy’s place: one of the copy’s candidateIds in the preview. Required with USE_THEIRS, refused with KEEP_MINE.
Responses
Section titled “Responses”OK
How the elements that an element whose type represents a model owns as copies compare with a version of that model: what connecting the element to that model would replace, offer a choice for, or leave owned. Producing one changes nothing.
object
The element compared, one whose type represents a model.
Each element it owns, in the order it holds them. Absent when it owns none.
How one element owned as a copy by an element whose type represents a model, or one owned child of such a copy, compares with the model it represents.
object
The owned element compared.
Where an owned copy, or one of its owned children, lands. SAME: a counterpart exists and nothing differs. DIFFERENT: a counterpart exists and a property or an owned child differs, or the counterpart is still to be chosen, because several elements fit or another copy fits the same one. NOT_IN_MODEL: no element of the model fits.
The element of the model it corresponds to. Absent when none fits, and when one is still to be chosen among candidateIds: several fit, or another copy compared beside it fits the same one. Present when a choice took one of them.
Every element of the model that fits: one when the counterpart is settled or another copy fits the same one, several when it is to be chosen among them. Absent when nothing fits.
Each of candidateIds, in the same order, with where it sits in the model: path names the elements owning it from the topmost one under the model’s root down to its direct owner, empty for an element the root holds, so candidates of one name can be told apart. Absent when candidateIds is.
object
The properties whose values differ from the counterpart’s. Absent when none does.
One property whose value on an owned copy differs from its counterpart’s.
object
The property’s name, as the metamodel files it.
The values the copy stores: attribute values as stored, or for a relation the name of each target it refers to, null for a target in no model the host reads. Absent when it stores none.
The counterpart’s effective values, in the same form. Absent when it has none.
Why an owned copy stays owned whatever is chosen, and the elements of the model that make it so. Absent when the copy can be replaced.
object
OWNED_CHILD_TARGETED_WITHOUT_COUNTERPART: an owned child of the copy is the target of a relation elsewhere in the model, and the child has no counterpart that relation could be pointed at instead. TERM_REFERENCE_NOT_A_CANDIDATE: an element refers to the copy or one of its owned children in its text, and the counterpart that reference would move to is not among the terms that text may refer to. COPY_OWNED_ELSEWHERE: another element owns the copy beside the connected element, so removing the copy would take it from that owner as well. REFERENCE_NOT_ACCEPTED: a reference moved onto the counterpart lands where the metamodel admits no such target, such as a relation that admits no element of a dependency; the referring elements are named. Other readers treat an unknown reason as a refusal they cannot special-case.
The elements of the model whose relations would be left without a target.
Example
{ "elements": [ { "group": "SAME", "notReplaceable": { "reason": "OWNED_CHILD_TARGETED_WITHOUT_COUNTERPART" } } ]}The body is malformed (both or neither of dependencyId and modelId, a choice without a decision, USE_THEIRS without a counterpart, KEEP_MINE with one), or the element’s type represents no model, or modelId’s metamodel is not one the model may depend on (answered as ChangeValidationProblem with one dependency-metamodel-not-allowed error, as a staged DEPENDENCY_CREATE is refused), or dependencyId names a dependency the model only brings along transitively, or versionRef differs from the version the model already depends on modelId at (each answered as ChangeValidationProblem, with dependency-not-direct and dependency-version-differs), or versionRef names no version of it, or a choice is for no copy the element owns or names a counterpart that is none of its copy’s candidates.
A Problem that additionally carries errors when a staged change was refused, with nothing written. Its own type is what tells it from the plain 400 of a malformed body. Separate from Problem.violations, which stays what it is: request-body validation, one entry per rejected field of the request itself.
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
Stable constant a client branches on, which is what tells a refused change from the plain 400 of a malformed body.
Every reason the change was refused, not only the first, so a whole change can be corrected in one round trip. Never empty: a refusal carries at least one reason. A later entry may still be a consequence of an earlier failing action, which the messages say rather than hide. An entry’s actionIndex counts into the change’s own actions.
One reason a change was not applied, in the form an agent can correct itself from: which action was at fault, what kind of fault it was, and which element and property it was about. The same shape wherever a refusal is reported, so one piece of client code renders all of them.
code and message answer different readers. The code is a stable constant a client branches on without parsing prose; the message is the human sentence and may be reworded at any time. Every member a throw site did not know is left off the wire rather than sent as null, so a reader never has to tell “not applicable” from “unknown”.
object
Where the failing action sits in the change’s own action list, counted from zero. Absent, together with actionType, when the fault belongs to the change as a whole rather than to one of its actions.
The type of the failing action, exactly as the caller sent it, which for a not-stageable refusal is a type no variant answers to. Absent together with actionIndex.
A stable kebab-case constant a client branches on rather than parsing the message.
A refusal of the change as a whole carries one of not-stageable, updater-rejected, write-rejected, chain-too-long, change-too-large or closure-action-must-stand-alone. That list is closed, except where the errors member carrying this error names one more of its own. A refusal about one element or one of its properties carries an element-level code from the same namespace instead, such as element-not-found, owner-not-found, already-exists, unknown-property, invalid-target, multiplicity-violated or invalid-value, and a refused dependency action one of dependency-target-not-found, dependency-exists, dependency-in-use, dependency-connected, members-missing-in-version, dependency-not-direct, dependency-version-differs, dependency-snapshot-missing, dependency-metamodel-not-allowed or dependency-not-found, and a relation a change writes into content of a dependency the model no longer holds, which a rebase meets after the branch removed that dependency, dependency-removed, naming the referring element and the relation. A DEPENDENCY_CONNECT or DEPENDENCY_DISCONNECT may carry copy-not-replaceable, element-connected, element-not-connected or connection-changed, and a write that would set, change or clear an element’s connection other than through those two connection-not-writable. That second set is stable in the sense that a code is never reused for something else, but it is open: new ones are added as refusals learn to name themselves, so a client treats one it does not recognise as a refusal it cannot special-case rather than as a malformed response.
The sentence a human reads. Reworded freely, never parsed.
The element the failure is about, where the refusal named one.
The name elementId is listed under, where the refusal read it: the connected element a dependency-connected error names, the member a members-missing-in-version error names.
The attribute or relation the failure is about, where the refusal named one.
On a members-missing-in-version error: a member a connected element holds by reference that the version its dependency moves to lacks, the element that holds it, and what uses it.
object
The member, an element of the version the dependency leaves.
The name it is listed under, its type when nothing names it.
Its type, as stored.
The element that holds the member, one whose type represents a model and that is connected to the dependency.
The name the element that holds the member is listed under, its type when nothing names it.
For a member the new version still holds: the owned child of it that the version lacks and the model uses, which makes the member count as missing. Absent for a member the version lacks itself.
object
The name it is listed under, its type when nothing names it.
The model’s elements referring to the member or one of its owned children, through an authored relation or a term reference, each once per relation, in element id order. The member relation of the element that holds it holds the member rather than using it and is not listed.
object
The key the reference is stored under.
The name the metamodel shows for the relation; absent when it declares none.
Present only when errors was cut short at its bound: every reason found, counted by code, so a client can say how many there are without parsing detail. A refused DEPENDENCY_UPDATE with many missing members answers its first ones in errors and their total under members-missing-in-version; POST /models/{modelId}/dependencies/{dependencyId}/version-change-preview lists them all.
object
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
{ "type": "https://modeldesk.io/problems/change-validation-failed"}The caller is an agent acting for a person and the model’s organization has not enabled the agent’s AI platform, answered as AgentPlatformNotEnabledProblem.
A Problem answered when an agent acting for a person reached a model whose owning organization has not enabled the AI platform the agent runs on, which its token names. Model content reaches the platform an agent runs on, so the organization decides: until an organization admin turns the platform on in the organization’s AI agent platforms setting, every route on the model refuses the agent, conditional reads and the events stream included, and the model list and every page that names other models leave the organization’s models out. A change of the setting applies to new requests within a minute; an events stream that is already open ends at its token’s expiry, at most ten minutes later.
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
Stable constant a client branches on, which is what tells this 403 from the plain one the same routes answer for a model the caller may not read.
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
{ "type": "https://modeldesk.io/problems/agent-platform-not-enabled"}No such model, or one the caller may not read; or the model at that ref holds no such element, or no internal dependency its root declares under dependencyId with its snapshot held, or no model under modelId the caller may read, each answered with the plain problem. Or ref names a ref that is not there for the caller, answered as RefNotFoundProblem.
A Problem answered when a ref the request reads at is not there for the caller, on a resource they may read: a ref id that names nothing, a ref of another resource, and another user’s draft, which reads exactly as a ref that does not exist. The draft routes answer it too when the caller holds no draft.
A 404, as a missing resource is, and told apart from one by its type. A resource the caller cannot read keeps the plain answer it always had, whatever ref was named, so this one never says anything about a resource the caller could not see. To a client it means that the ref it was reading, typically a draft committed or discarded in another session, is gone while the resource stays: it goes back to the branch. The problem names no ref, so the answer for an id that names nothing and for another user’s draft is the same, byte for byte.
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
Stable constant a client branches on, which is what tells this 404 from a resource that is missing or not the caller’s to read.
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
{ "type": "https://modeldesk.io/problems/ref-not-found"}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" } ]}