Skip to content

Stage a row change

POST
/datasets/{datasetId}/draft/changes
curl --request POST \
--url https://api.modeldesk.io/datasets/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/draft/changes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "written": [ { "rowId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "values": { "additionalProperty": [ "example" ] }, "refs": { "additionalProperty": [ { "datasetId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "rowId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }, "platformRefs": { "additionalProperty": [ { "kind": "MODEL", "resourceId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "elementId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }, "parts": { "additionalProperty": [ { "partId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "values": { "additionalProperty": [ "example" ] }, "refs": { "additionalProperty": [ { "datasetId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "rowId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }, "platformRefs": { "additionalProperty": [ { "kind": "MODEL", "resourceId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "elementId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }, "parts": { "additionalProperty": [] } } ] } } ], "removed": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "draftHeadId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "changeRequestId": "example", "message": "example", "dryRun": false, "branchId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'

Stage one change of rows into the caller’s own draft of the dataset, creating the draft on the default branch if they hold none. One call is one staged change, the grain undo pops. The rows are held to what a row batch is held to — at most 5000 rows, no row said twice, references only into declared datasets, and the dataset’s row cap once the draft lands — and are judged against the draft as it will stand: a reference to a row the draft wrote resolves, one to a row it removed does not. Rows that do not conform are staged all the same and reported in flagged.

Guarded by compare-and-set: draftHeadId must be the draft’s current head, or, before the caller holds a draft, the head of the dataset’s default branch. A stale head is answered 409 with the gap, as a model’s staged change is: a caller whose answer was lost and who sends the change again against the head it had finds its own changeRequestId among the commits, and knows the change is in.

datasetId
required
string format: uuid
Media typeapplication/json

One change to stage on the caller’s draft of a dataset: the rows to write and drop, the draft head it was written against, and the caller’s own key for it. A row id both written and removed is a 400, and so is a change that writes and removes nothing.

There is no dry run here. dryRun: true is refused with 400, a violation on dryRun that gives the reason, so a client that only meant to try a change never stages it. A model’s dry run answers a delta, which describes content and reads the same whether or not it was kept; this route answers the draft resource itself, and a dry run of it would have to answer with a draft, a head and a change count that do not exist.

object
written

The rows to write, each whole — a row is replaced by what the change carries.

Array<object>

One entry of a dataset. Both maps are keyed by the data schema’s source element ids, never by a name: the element id is what survives a rename, and it is what lets a model mapping induce a dataset migration later.

object
rowId
required

The row’s stable identity, minted once and surviving every edit.

string format: uuid
values

Value-property source element id to the terms the row holds for it.

object
key
additional properties
Array
refs

Reference-property source element id to the rows it points at.

object
key
additional properties
Array<object>

A pointer to a row, in this dataset or in one this dataset declares a dependency on.

object
datasetId
required
string format: uuid
rowId
required
string format: uuid
platformRefs

Reference-property source element id to the models, model elements and datasets it points at, for a property whose target type is represented by things the platform holds. Such a property holds these and never row references. Absent when the row holds none. A write that leaves platformRefs out keeps the ones the row holds, as a client that knows nothing of them writes every row; one that sends {} clears them. The two fields are told apart each on its own.

object
key
additional properties
Array<object>

A pointer to a thing the platform holds: a model, an element of a model, or a dataset. A model or element is read at the state the dataset pins the model at; a dataset as it stands.

object
kind
required
string
Allowed values: MODEL ELEMENT DATASET
resourceId
required

The model, for a model or an element; the dataset, for a dataset.

string format: uuid
elementId

The element of the model; present exactly for an ELEMENT.

string format: uuid
parts

Containment-property source element id to the parts the row holds inside itself, for a property whose target type has no identity of its own (a contact point, a period). Such a property holds parts and never row references. Absent when the row holds none. A write that leaves parts out keeps the parts the row holds, as a client that knows nothing of parts writes every row; one that sends it, empty included, leaves the row holding what it sent.

object
key
additional properties
Array<object>

One part a row holds inside itself: an occurrence of a containment property whose target type has no identity of its own. Its maps are keyed as a row’s are, and it holds parts of its own to whatever depth the model nests them.

object
partId

The part’s identity inside its row, so a change to one part is told from a change to another. Send it back unchanged on every write of the row; a part written without one gets a new one, and two parts of one row under one id are a 400.

string format: uuid
values

Value-property source element id to the terms the part holds for it.

object
key
additional properties
Array
refs

Reference-property source element id to the rows it points at.

object
key
additional properties
Array<object>

A pointer to a row, in this dataset or in one this dataset declares a dependency on.

object
datasetId
required
string format: uuid
rowId
required
string format: uuid
platformRefs

Reference-property source element id to the models, model elements and datasets the part points at, for a property whose target type is represented by things the platform holds. A part is written whole, so a part sent without them holds none. Absent when the part holds none.

object
key
additional properties
Array<object>

A pointer to a thing the platform holds: a model, an element of a model, or a dataset. A model or element is read at the state the dataset pins the model at; a dataset as it stands.

object
kind
required
string
Allowed values: MODEL ELEMENT DATASET
resourceId
required

The model, for a model or an element; the dataset, for a dataset.

string format: uuid
elementId

The element of the model; present exactly for an ELEMENT.

string format: uuid
parts

Containment-property source element id to the parts this part holds.

object
key
additional properties
Array<object> recursive
removed

The rows to drop.

Array<string>
draftHeadId
required

The draft head the change was written against, or, before the caller holds a draft, the head of the dataset’s default branch.

string format: uuid
changeRequestId
required

The caller’s own key for this change, stored on the staged change. A caller whose answer was lost finds it among the commits of the 409 its retry is answered with.

string
<= 200 characters
message

What the change is, in the caller’s words. Optional, and capped as a landing’s message is. Stored as the staged change’s message and served wherever the draft’s chain is listed: the gap a 409 carries and a rebase’s dropped. A blank message is stored as none. It never reaches the branch: the landing commit carries the message its own request sends.

string
<= 2000 characters
dryRun

Declared only to be refused: a dataset’s change has no dry run, and true is answered 400 with a violation on dryRun saying so, rather than dropped and the change staged.

boolean
branchId

The branch the change is meant for. Omitted, the change goes to the caller’s draft, or to main while they hold none. While the caller holds no draft, the change opens one on this branch and draftHeadId is compared with this branch’s head. A caller holds one draft per dataset, so naming a branch their draft does not target is refused with 409.

string format: uuid

The change is staged

Media typeapplication/json

Where the draft stands after a change was staged or undone, and the rows that move left not conforming.

object
draft
required

One user’s private staging ref on a branch of the model. updatedAt is derived rather than stored: the newer of the draft’s creation and its head commit, so it moves with every staged change.

object
id
required

The draft’s ref id, which is also what ?ref= takes on the read routes.

string format: uuid
targetRefId
required

The branch the draft lands on.

string format: uuid
baselineCommitId
required

The target branch’s head the draft started from.

string format: uuid
headCommitId
required

The draft’s own head, equal to the baseline while nothing is staged.

string format: uuid
changeCount
required

How many changes are staged: the length of the draft’s chain from its head down to its baseline. Computed per read rather than stored, and 0 on a draft nothing has been staged into. A change is the undo grain, so five edits to one element count as five.

integer
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
movesBaseTo

For a dataset draft that moves the dataset to another release of its base, that release’s name; the dataset is pinned to it once the draft lands.

string
handoff

A draft’s most recent handoff for review, set by POST /models/{modelId}/draft/handoff. Absent on a draft never handed off. Neither a commit nor a staged change: it goes with the draft when the draft is committed or discarded, and a staged change, an undo or a rebase leaves it in place.

object
summary
required

The author’s own words about the draft. Written by whoever handed it off, often an agent, so a client renders it as plain text and never as markup.

string
<= 2000 characters
headCommitId
required

The draft head when it was handed off. A headCommitId on the draft other than this one means the draft changed after the handoff.

string format: uuid
at
required

When the draft was handed off.

string format: date-time
flagged

Row id to what is wrong with it. For a staged change, the written rows that do not conform; they were staged all the same. For an undo, the rows moved back onto a revision whose recorded verdict flags them. Absent when there are none.

object
key
additional properties

How a row stands against its dataset’s data schema. A row that does not conform is flagged and kept, never dropped: reference data arrives incomplete and is corrected in place.

object
valid

Whether no violation is an error. A row whose violations are all warnings is valid and still carries them.

boolean
violations

Absent when nothing is wrong with the row.

Array<object>

One way in which a row does not conform.

object
code
required
string
Allowed values: TOO_FEW_VALUES TOO_MANY_VALUES VALUE_NOT_IN_TYPE PROPERTY_NOT_DECLARED REFERENCE_TARGET_MISSING REFERENCE_DATASET_NOT_DECLARED REFERENCE_MODEL_NOT_DECLARED REFERENCE_TARGET_WRONG_TYPE REFERENCE_TARGET_NOT_SELECTABLE OTHER
propertyId

The schema property’s source element id — the same key the row’s own maps use, so a caller marks the offending cell without a lookup. Absent for a violation about the row itself. For a violation inside a part, the row’s column that holds the part, with path leading from there to the field.

string format: uuid
valueIndex

Which value of the property; absent when the violation is the property’s as a whole. For a violation inside a part, which value of the field path ends at.

integer
path

For a violation inside a part, the way from propertyId down to the field, outermost part first: contactpunt[2].email is one step, the part at index 1 and its property email. Absent for a violation of one of the row’s own fields.

Array<object>

One step of a violation’s way into a part: the part at a position among the parts of the property reached so far, and the property of that part the way goes on to.

object
index
required

The part’s position among that property’s parts, from 0.

integer
partId
required
string format: uuid
propertyId

The part’s property the way goes on to; absent where the violation is about the part.

string format: uuid
message
required
string
severity

How much the violation weighs; the row is kept and flagged either way. A value outside a code list is a WARNING unless the list is marked strict; everything else is an ERROR.

string
Allowed values: WARNING ERROR
inPlatformRefs

For a reference property, which of its lists the violation is about: true for its references to models, model elements and datasets (platformRefs), which valueIndex then counts in; false for its references to rows (refs) where that needs saying beside the other. Absent for its references to rows, as every violation from before the other list existed reads. Inside a part as at the row: beside path, it says which list of the field path ends at.

boolean

Example

{
"flagged": {
"additionalProperty": {
"violations": [
{
"code": "TOO_FEW_VALUES",
"severity": "WARNING"
}
]
}
}
}
Draft-Ref
required
string format: uuid

The draft the change is staged in, so a caller whose change opened it learns its id without a second call. Always sent: a staged row change always leaves a draft.

The change writes and removes nothing, breaks a batch limit, references a dataset the dataset does not depend on, points into a model it does not pin or at a dataset of another owner or one the caller cannot read, would take the dataset past its row cap or the draft past its own, or the draft’s chain is full.

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

The dataset is theirs to read but not to change.

Media typeapplication/problem+json
Any of:

A Problem answered when an organization feature the request needs is not open to the caller on this resource. A 403, as an access refusal is, and told apart from one by its type: a caller refused a feature can still read the resource, and only loses what the feature offers. feature says which: on a draft route it is a feature an action inside the staged change needs, such as alignment for an ALIGNMENT_CREATE, and only that change is refused.

object
type
required

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
type
required

Stable constant a client branches on, which is what tells this 403 from an access refusal.

string format: uri
Allowed values: https://modeldesk.io/problems/feature-not-enabled
feature
required

The organization feature the caller lacks, spelled as it is on the organization, such as alignment or catalog. Where any of several features would admit the caller, the first of them is named.

string
organizationId

The organization the refusal was judged against. Absent for a resource no organization owns (one a user owns, or one nobody owns), which no organization feature can open: the refusal then names no one.

string format: uuid

Example

{
"type": "https://modeldesk.io/problems/feature-not-enabled",
"feature": "alignment"
}

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

The draftHeadId is no longer the current head. The problem carries the gap, so a caller that finds its own changeRequestId in commits knows its change was staged and does not send it twice. Also the answer, without a gap, to a change whose rows hold parts in an environment that does not write them yet, and, as a plain problem, to a change pointing at models, model elements or datasets in an environment that does not write those yet.

Media typeapplication/problem+json
Any of:

A Problem that additionally carries the gap, answered when the draftHeadId a dataset draft write was written against is no longer the current head, and when a landing finds the branch moved past the draft’s baseline. It is the model’s DraftHeadConflictProblem with the gap in the dataset’s own words: each commit as the dataset’s history lists one, counting the rows its own change touched.

object
type
required

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
type
required
string format: uri
Allowed values: https://modeldesk.io/problems/draft-head-conflict
conflict
required
object
branchId
required

The ref the head belongs to: the caller’s draft, or the branch it targets while there is none and when a landing is refused.

string format: uuid
baselineCommitId
required

The head the caller sent, which is no longer the current one; for a refused landing, the baseline the draft is still based on.

string format: uuid
currentHeadCommitId

The head as it now stands.

string format: uuid
ancestor
required

Whether the head the caller sent is still on the chain below the current one. False when an undo popped it or a rebase rewrote the chain; a client that reads false re-reads the draft.

boolean
commits

The chain from the current head down to the head the caller sent, exclusive, newest first. Absent when ancestor is false.

Array<object>

One commit of a dataset’s history. What a commit points at stays opaque; how many rows it touched is what a reader wants from it. This is the shape every route but the history reads carries (a landing’s answer, a stale head’s gap, a rebase’s dropped changes); the listing adds the size of a landing’s record (DatasetCommitLogView) and the single read the record itself (DatasetCommitRecordView).

object
id
required
string format: uuid
datasetId
required
string format: uuid
parentIds

None for the first commit, one for an ordinary one, two for a merge.

Array<string>
createdAt
string format: date-time
createdBy
object
id
required
string format: uuid
type
required

USER is a person, MACHINE a service account, and SYSTEM the platform itself, whose commits (metamodel seeding and re-pins) the commit log hides unless asked for them.

string
Allowed values: USER ORGANIZATION SYSTEM MACHINE
name

The display name, where one is known: a person’s from their account, a service account’s as stored with what it wrote. Left out for the platform and for a person whose account holds no name.

string
message

What the commit records about the change. Absent on a staged change sent without one.

string
requestId
string
rowsChanged

How many rows the commit wrote or removed. For a change staged on a draft, listed in a stale head’s gap or among a rebase’s dropped changes, the rows that one change touched.

integer

Example

{
"type": "https://modeldesk.io/problems/draft-head-conflict",
"commits": [
{
"createdBy": {
"type": "USER"
}
}
]
}

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