Skip to content

Get a commit's diff

GET
/models/{modelId}/commits/{commitId}/diff
curl --request GET \
--url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/commits/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/diff \
--header 'Authorization: Bearer <token>'

Get the element-level diff for a commit compared to its parent. For initial commits (no parent), all elements are returned as ADDED.

modelId
required
string format: uuid
commitId
required
string format: uuid
ref
string format: uuid

The ref to read at, a model_branch document id. When omitted, the model’s main branch is read.

OK

Media typeapplication/json
object
commitId
required
string format: uuid
parentCommitId

Null for initial commits.

string format: uuid
elements
required
Array<object>
object
elementId
required
string format: uuid
elementName

Element name resolved at commit time.

string
elementType
required
string
diffType
required
string
Allowed values: ADDED MODIFIED REMOVED
attributes

Changed attributes only.

object
key
additional properties
object
before

Attribute values before the change. Null for ADDED elements.

Array
after

Attribute values after the change. Null for REMOVED elements.

Array
relations

Changed relations only.

object
key
additional properties

One relation that differs between the two states. before and after carry the relation whole, so a reader can show the targets it kept beside the ones it gained or lost, and a relation whose targets were only reordered differs in them alone. An empty list is omitted: an ADDED element’s relation carries no before, a REMOVED element’s no after.

object
before

Element IDs of the relation’s targets before the change, in order.

Array<string>
after

Element IDs of the relation’s targets after the change, in order.

Array<string>
addedTargets

Element IDs of newly added relation targets.

Array<string>
removedTargets

Element IDs of removed relation targets.

Array<string>
resolvedNames

Display label by element ID for every element the diff names: each entry, every target a changed relation holds before or after the change, and the elements its diagram actions name. An element neither state nor the current model holds is left out.

object
key
additional properties
string

Example

{
"elements": [
{
"diffType": "ADDED"
}
]
}

The model does not exist or is not the caller’s to read, or the commit is not on the ref read, answered with the plain problem. Or ref names a ref that is not there for the caller, answered as RefNotFoundProblem: an unknown id, a ref of another model and another user’s draft all get that answer, in the same words, and only on a model the caller may read.

Media typeapplication/problem+json
Any of:

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
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 404 from a resource that is missing or not the caller’s to read.

string format: uri
Allowed values: https://modeldesk.io/problems/ref-not-found

Example

{
"type": "https://modeldesk.io/problems/ref-not-found"
}

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