Skip to content

Paste elements from another model

POST
/models/{modelId}/element-paste
curl --request POST \
--url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/element-paste \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "sourceModelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "elementIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "rootIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "targetOwner": { "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "relation": "example" }, "mode": "COPY" }'

Copy elements, each with the subtree it owns, from a source model into this one as a single commit. The caller needs read access to the source model, and both models must share a metamodel.

modelId
required
string format: uuid
Media typeapplication/json
object
sourceModelId
required
string format: uuid
elementIds
required

The selected root elements; their owned subtrees are resolved server-side.

Array<string>
>= 1 items
rootIds

Read only when the paste is staged, as ELEMENT_PASTE on POST /models/{modelId}/draft/changes: the ids the copies of the selected elements are created under, one per entry of elementIds and in the same order, so a later action of the same change can address a copy. Omitted, the server mints them. An element selected twice is copied once, under the id at the position it was first selected at. A list that does not pair one to one with elementIds, or that names an id twice, is refused; so is an id the target already holds. POST /models/{modelId}/element-paste ignores the field and mints every id itself, as its other creations do.

Array<string>
targetOwner

Where the copies land. Omitted pastes them at the model root.

object
id
required
string format: uuid
relation
required
string
mode
required

CUT records that the caller intends to remove the originals afterwards, which is a separate delete on the source model; the paste itself never removes anything.

string
Allowed values: COPY CUT

The pasted root elements, and how many references could not be carried over

Media typeapplication/json
object
elements
required

The pasted root elements, as created in the target model.

Array<object>
object
id
required
string format: uuid
type
required
string
external
boolean
attributes
object
key
additional properties
array
relations
object
key
additional properties
object
key
additional properties
Array<object>
object
id
required
string format: uuid
owned
required
boolean
modelId

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.

string format: uuid
extensionLayer

The values the element holds that its type declares no property for; absent when none.

Array

A value an element holds under no binding its type declares, kept so a round trip loses nothing.

One of: discriminator: kind
attribute
object
kind
required
string
Allowed value: attribute
key
string
lexicalValue
string
typeIdentifier
string
qualifiers
object
key
additional properties
string
lineage

Where an element was derived from: the source and rules models, and per property the source values it read.

object
sourceModels
Array<object>
object
modelId
string format: uuid
commitId
string format: uuid
rulesModels
Array<object>
object
modelId
string format: uuid
commitId
string format: uuid
generatedBy
object
id
required
string format: uuid
owned
required
boolean
modelId

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.

string format: uuid
properties
Array<object>
object
propertyName
string
propertyType
string
Allowed values: ATTRIBUTE RELATION
sources
Array<object>
object
sourceModelId
string format: uuid
sourceElementId
string format: uuid
sourceProperty
string
propertyType
string
Allowed values: ATTRIBUTE RELATION
role
string
Allowed values: PRIMARY VALUE_READ
usedRule
object
id
required
string format: uuid
owned
required
boolean
modelId

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.

string format: uuid
droppedReferenceCount
required

References that could not be carried over because their target lies outside the copied set and outside the target model.

integer

Example

{
"elements": [
{
"extensionLayer": [
{
"kind": "attribute"
}
],
"lineage": {
"properties": [
{
"propertyType": "ATTRIBUTE",
"sources": [
{
"propertyType": "ATTRIBUTE",
"role": "PRIMARY"
}
]
}
]
}
}
]
}

Bad request — a selection larger than the bounds allow, a source model of a different metamodel, or a target whose bindings do not accept a pasted type. Nothing is written.

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 — the target model, or a source model or element that no longer exists. A source model the caller may not read is reported the same way, revealing nothing about whether it exists.

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"
}
]
}