Skip to content

Discard your draft

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

Discard the caller’s own draft with everything staged on it. Without draftHeadId there is no head check: discard means all of it, whatever it has grown to since the caller last looked, and a session that was still staging meets the ordinary 409 on its next change. With it, the discard is gated on that head, so a client that delays its discard to offer an undo loses nothing staged in the meantime.

404 when the caller holds no draft, so a repeated discard is harmless rather than ambiguous.

modelId
required
string format: uuid
draftHeadId
string format: uuid

The draft head the caller last saw. When given, the draft is deleted only while that is still its head: a change another session or an agent staged since keeps the draft and answers 409. When omitted, the draft is deleted whatever it holds.

The draft and everything staged on it are gone

The model is theirs to read but not to change, answered with the plain problem. Or the caller is an agent acting for a person who did not grant it the right to commit, and the draft holds a staged change its own session did not make, the person’s or another agent’s, answered as AgentChangeNotOwnProblem with the draft kept: without that grant an agent takes back only what it staged itself. Its discard is held to the head whose changes were judged, so a change staged in between keeps the draft and answers 409. Or the caller is an agent acting for a person, and the organization that owns the model has not enabled the agent’s AI platform, answered as AgentPlatformNotEnabledProblem. Or the caller is an agent acting for a person, and the request reaches further than the maximum level the organization that owns the model lets agents reach, answered as AgentLevelNotAllowedProblem with nothing written, whatever the agent was granted.

Media typeapplication/problem+json
Any of:

A Problem answered when an agent acting for a person made a request that reaches further than the maximum level the organization that owns the model lets agents reach, set in the organization’s AI agent platforms setting: staging into a draft or working on a branch where the maximum is read, a merge, a landing on a branch that is not an agent’s own, or taking back or landing another’s staged change where it is propose, and anything that reaches people outside the organization where it is below publish. The person’s grant does not lift it, since a grant spans the person’s organizations and the maximum is each organization’s own; an organization admin can raise it. Nothing was written. A change of the setting applies to new requests within a minute.

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 the plain one the same routes answer for a model the caller may not change, and from the refusals a permission the person grants lifts.

string format: uri
Allowed values: https://modeldesk.io/problems/agent-level-not-allowed

Example

{
"type": "https://modeldesk.io/problems/agent-level-not-allowed"
}

The model does not exist, answered with the plain problem, or the caller holds no draft on it, answered as RefNotFoundProblem: to a client that is the news a read at a gone ref brings, that the draft it was working in, perhaps committed or discarded in another session, is no longer there. A repeated discard therefore says there is nothing here rather than reporting a second success.

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

The draft has moved past draftHeadId, so something was staged that the caller has not seen, and nothing was deleted. The draft still holds all of it; the caller reads it again and discards once more if that is still what they want. A draft committed or discarded in another session after this call looked it up and before it deleted it answers this too, because the gated delete cannot tell a draft that is gone from one that moved; reading the draft again then answers 404 with RefNotFoundProblem.

Media typeapplication/problem+json

A Problem answered when a change was staged between the read a landing was built from and the delete that would have ended the draft. Nothing was written, and nothing was lost: the draft still holds everything, the new change included. The caller reads it again and commits once more, which lands the longer chain.

A head-gated discard answers it when the draft moved past draftHeadId, and a handoff when the draft moved between the read of it and the write of the handoff; neither deletes or stores anything, and the caller reads the draft again and asks once more.

Distinct from DraftHeadConflictProblem, which reports being behind the branch and carries the commits to catch up on. Here there is nothing to catch up on, so there is no gap.

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 409 from the other two the same route answers with.

string format: uri
Allowed values: https://modeldesk.io/problems/draft-moved
code
required

Stable constant a client branches on, beside the problem’s own type.

string
Allowed values: draft-moved
draftRefId
required

The draft that moved: the caller’s own draft ref, never the branch it targets. It is the id of the Draft this request was built from.

string format: uuid
expectedHeadCommitId
required

The head the request was built from (the landing’s, the discard’s draftHeadId or the head the handoff read), which is no longer the draft’s.

string format: uuid

Example

{
"type": "https://modeldesk.io/problems/draft-moved",
"code": "draft-moved"
}

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