Skip to content

Create a dataset branch

POST
/datasets/{datasetId}/branches
curl --request POST \
--url https://api.modeldesk.io/datasets/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/branches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "example", "from": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'

Create a branch at the current head of another branch of the dataset, main when from is omitted. The new branch holds the rows that head holds, so reading the dataset’s rows with the branch’s name as ref answers what the source held. The name keeps the rules a model branch’s name keeps.

datasetId
required
string format: uuid
Media typeapplication/json

What creating a branch takes. Nothing in it is required by the schema, so that every bad name, a missing one too, is refused with InvalidBranchNameProblem naming its rule.

object
name

The new branch’s name, brought to Unicode’s composed form (NFC) and trimmed before it is checked and stored. It must then be 1 to 100 characters long, hold no control character, invisible formatting character, line break or character Unicode does not assign, not be main in any case, and not start with draft/ or gen/. A missing name is refused as empty, as an empty one is. It must differ from every other branch’s name in more than case.

string
from

The branch whose current head the new branch starts at. Omitted means the model’s main branch.

string format: uuid

Example generated

{
"name": "example",
"from": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
}

Created

Media typeapplication/json

One branch of a model: its name, when it was created, whether it is the model’s main branch, the commit it points at and who made that commit, how many drafts target it and how many of its commits main does not reach.

object
id
required

The branch’s ref id, which is what ?ref= takes on the read routes and branchId on a staged change.

string format: uuid
name
required

The name the branch was created with. A branch is never renamed.

string
createdAt
required
string format: date-time
main
required

True for the model’s main branch only: the one every read without a ref reads, the one releases are cut from, and the one that cannot be deleted.

boolean
head
required

The commit the branch points at, in the shape a walked commit is listed in.

object
id
required
string format: uuid
parentId

Absent on the initial commit.

string format: uuid
authorId
required
string format: uuid
message

The author’s description of the change. Absent on a commit made without one. For a staged change it is the message that was sent, absent when it was blank or left out.

string
requestId

The key of the request that produced the commit, absent on a commit made without one. For a staged change it is the changeRequestId that was sent.

string
createdAt
required
string format: date-time
actionTypes
required

The deduped, sorted type values of the commit’s actions. Empty rather than absent on a commit that records none.

Array<string>
closureRecorded

Present, and true, on a merge commit whose actionTypes include a dependency or metamodel-pin type for every change it made to the model’s dependencies and metamodel pin. A merge commit names the elements it changed as element actions whatever they are, so one without it says nothing about those: a client has to assume they may have moved. Absent on every other commit, whose actionTypes always tell.

boolean
headAuthor
required

Who made the head commit, named as the commit log names the author of the same commit in createdBy: a person by the name on their account, a service account by the name it had when it committed, and the platform (SYSTEM) without a name.

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

How many drafts target the branch, whoever owns them. Deleting the branch deletes every one of them, so a client can say how many go before it asks.

integer
unmergedCommitCount
required

How many commits on the branch main does not reach, every parent of a merge followed. Zero for main and for a branch main has merged. Deleting the branch leaves them to garbage collection and is refused without force while there are any, so a client can say how many go before it asks.

integer

Example

{
"headAuthor": {
"type": "USER"
}
}

The name breaks one of the rules a branch name keeps, answered as InvalidBranchNameProblem with the rule it broke.

Media typeapplication/problem+json
Any of:

A Problem answered when a branch name breaks one of the rules a branch name keeps. Only the first broken rule is named.

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 400 from the plain one a body that cannot be read is refused with.

string format: uri
Allowed values: https://modeldesk.io/problems/invalid-branch-name
rule
required

The rule the name broke. empty: missing, or nothing is left once it is trimmed. too-long: over 100 characters once composed and trimmed. control-character: it holds a control character, an invisible formatting character such as a bidi override or a zero-width space, a line or paragraph separator, a code point Unicode does not assign, or half of a surrogate pair. reserved-prefix: it starts with draft/ or gen/. reserved-name: it is main, in any case.

string
Allowed values: empty too-long control-character reserved-prefix reserved-name

Example

{
"type": "https://modeldesk.io/problems/invalid-branch-name",
"rule": "empty"
}

The dataset is theirs to read but not to change.

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 does not exist or is not the caller’s to read, answered with the plain problem, or from names no branch of it, answered as RefNotFoundProblem. A draft is not a branch, so naming one reads as naming nothing.

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

Another branch of the dataset already has this name, compared without regard to case, answered as BranchNameTakenProblem; or the dataset already holds as many branches as one may, answered as BranchLimitReachedProblem with the limit. Nothing was created.

Media typeapplication/problem+json
Any of:

A Problem answered when another branch of the model already has the name a new branch asked for, compared without regard to case. The name is well formed; picking another one is all it takes.

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.

string format: uri
Allowed values: https://modeldesk.io/problems/branch-name-taken

Example

{
"type": "https://modeldesk.io/problems/branch-name-taken"
}

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