Models#

Shared request and response types used across the v2 API. See the error model for how failures are reported.

ErrorCode#

A stable, machine-readable error code in SCREAMING_SNAKE_CASE. Clients branch on this value, never on the human-readable title/detail prose. The baseline codes below cover the standard HTTP failure categories; endpoint-specific codes (e.g. BRANCH_NOT_FOUND) are appended to this enum alongside the endpoints that emit them, which is an additive, non-breaking change under the v2 stability policy (§5.1).

Enum values

Value
VALIDATION_FAILED
UNAUTHENTICATED
PERMISSION_DENIED
NOT_FOUND
METHOD_NOT_ALLOWED
CONFLICT
UNPROCESSABLE
RATE_LIMITED
INTERNAL
SERVICE_UNAVAILABLE
OPERATION_FAILED

Problem#

A structured error body returned for every non-2xx response, following RFC 9457 (Problem Details for HTTP APIs). This is the single error model for the entire v2 API — there are no ad-hoc error shapes.

FieldTypeRequiredDescription
typestringnoA URI identifying the problem type; when dereferenced it points at human-readable documentation for the error.
titlestringyesA short, human-readable summary of the problem type.
statusintegeryesThe HTTP status code, repeated in the body for convenience.
detailstringnoA human-readable explanation specific to this occurrence of the problem.
instancestringnoA URI reference identifying the specific occurrence (typically the request path).
codestringyesA stable, machine-readable error code in SCREAMING_SNAKE_CASE. Clients branch on this value, never on the human-readable title/detail prose. The baseline codes below cover the standard HTTP failure categories; endpoint-specific codes (e.g. BRANCH_NOT_FOUND) are appended to this enum alongside the endpoints that emit them, which is an additive, non-breaking change under the v2 stability policy (§5.1).
request_idstringyesThe request identifier, echoed on every response. Include it when contacting support so a request can be traced end-to-end.

Meta#

Response metadata carried alongside the primary data payload. All fields are optional; list endpoints populate next_page_token for cursor pagination (§5.6).

FieldTypeRequiredDescription
next_page_tokenstringnoOpaque cursor for the next page of a list response. Absent or empty when there are no further results; otherwise pass it back as the page_token query parameter to fetch the next page.

Envelope#

The success envelope wrapping every 2xx response body (§5.4): the resource or list of resources under data, with optional meta. This is the single success shape for the API — there are no unenveloped success bodies. Endpoints narrow data to a concrete resource via allOf (see the section comment above); the base leaves data unconstrained so that composition works.

FieldTypeRequiredDescription
dataobject,arrayyesThe primary response payload — a resource, or an array of resources for list endpoints.
metaobjectnoResponse metadata carried alongside the primary data payload. All fields are optional; list endpoints populate next_page_token for cursor pagination (§5.6).

DatabaseRef#

A minimal reference to a database — owner and name only. Used wherever the API points at another database (a fork’s parent, a network’s root, an item in the forks list) without re-embedding the full Database resource.

FieldTypeRequiredDescription
ownerstringyesThe user or organization that owns the referenced database.
namestringyesThe referenced database’s name.

CreateDatabaseRequest#

Body for POST /api/v2/databases. owner names the user or organization that will own the new database; the caller’s credentials must allow creating under that owner.

FieldTypeRequiredDescription
ownerstringyesThe user or organization that will own the database.
namestringyesThe database name. Must be unique within the owner and conform to DoltHub’s naming rules (letters, digits, -, _; cannot start or end with -).
descriptionstringnoOptional human-readable description.
visibilitystringyesWhether the database is publicly readable. Defaults are not applied — clients must declare the intended visibility on create.

CreatePullRequest#

Body for POST /api/v2/databases/{owner}/{database}/pulls. to_branch.database must equal the URL’s {owner}/{database} (the PR opens against this repo); from_branch.database is usually the same but may point at a fork for cross-fork PRs.

FieldTypeRequiredDescription
titlestringyesThe pull request’s title.
descriptionstringnoOptional pull-request body (markdown).
from_branchobjectyesA reference to a branch within a specific database. Carries the database so callers can disambiguate cross-fork pull requests, where from_branch and to_branch may live in different repositories.
to_branchobjectyesA reference to a branch within a specific database. Carries the database so callers can disambiguate cross-fork pull requests, where from_branch and to_branch may live in different repositories.

CreatePullCommentRequest#

Body for POST /api/v2/databases/{owner}/{database}/pulls/{pull_number}/comments. Carries only the comment text; author and timestamps are server-assigned.

FieldTypeRequiredDescription
bodystringyesThe comment text (markdown).

MergePullRequest#

Body for POST /api/v2/databases/{owner}/{database}/pulls/{pull_number}/merge. Currently empty — the merge takes no parameters today. The empty object exists so the schema is closed under additionalProperties (mistyped fields fail loud rather than getting silently dropped) and so we have a stable place to add the conflict-resolution strategy when that ships.

Type: object


CreateForkRequest#

Body for POST /api/v2/databases/{owner}/{database}/forks. The URL identifies the source database; owner is the user or organization that will own the new fork. The new fork inherits the source database’s name. Forking into a namespace the caller does not own returns 403.

FieldTypeRequiredDescription
ownerstringyesThe user or organization that will own the new fork.

UpdatePullRequest#

Body for PATCH /api/v2/databases/{owner}/{database}/pulls/{pull_number}. Every field is optional; the caller supplies whichever fields they’re changing and the server only updates those. At least one field must be present. state is restricted to the writable transitions (openclosed); to merge, use the merge operation.

FieldTypeRequiredDescription
titlestringnoNew title; omit to leave unchanged.
descriptionstringnoNew description body (markdown); omit to leave unchanged.
statestringnoNew state. Merging is a separate operation; this field can’t transition to merged.

CreateBranchRequest#

Body for POST /api/v2/databases/{owner}/{database}/branches. from is a discriminated union — one of { branch } or { commit } — that names the source revision the new branch will point at.

FieldTypeRequiredDescription
namestringyesThe new branch’s name.
fromobjectyes

CreateTagRequest#

Body for POST /api/v2/databases/{owner}/{database}/tags. from is the same { branch | commit } discriminated union used by CreateBranchRequest. Supplying message produces an annotated tag; omitting it produces a lightweight tag.

FieldTypeRequiredDescription
namestringyesThe new tag’s name, unique within the database.
fromobjectyes
messagestringnoOptional annotation message. Present → annotated tag; absent → lightweight tag.

CreateReleaseRequest#

Body for POST /api/v2/databases/{owner}/{database}/releases. Releases pin to a specific commit (commit_sha), not a moving branch. The release is published under tag; create_tag_if_not_exists lets the backend create that tag implicitly when it doesn’t already exist, otherwise the tag must already point at commit_sha.

FieldTypeRequiredDescription
tagstringyesThe tag the release is published under, unique within the database.
titlestringyesHuman-readable title.
commit_shastringyesThe commit hash the release points at.
descriptionstringnoOptional release notes body (markdown).
create_tag_if_not_existsbooleannoWhen true and no tag named tag exists, create one pointing at commit_sha. Defaults to false — the caller is responsible for tag creation otherwise.

ImportFileType#

Source file format for an import.

Enum values

Value
csv
psv
xlsx
json
sql
yaml

ImportOperation#

How the imported rows are applied to the target table. create requires the table not to exist; overwrite replaces it; update upserts into an existing table; replace truncates then inserts.

Enum values

Value
create
overwrite
update
replace

CompletedPart#

One part of a multipart upload, identified by its part number and the ETag the storage backend returned.

FieldTypeRequiredDescription
part_numberintegeryesThe 1-based part number this entry corresponds to.
etagstringyesThe ETag returned by the storage backend for this part.

ImportUploadPart#

A single part in an upload session — the part number plus the pre-signed URL to PUT it to.

FieldTypeRequiredDescription
part_numberintegeryesThe 1-based part number.
urlstringyesPre-signed URL the client should upload this part to.

ImportUpload#

A multipart upload session. The client PUTs each file chunk to the matching parts[].url, collects the storage backend’s ETag for each, and then calls createImport with the token, contents_key, and the collected CompletedParts.

FieldTypeRequiredDescription
tokenstringyesOpaque upload-session token. Pass verbatim to createImport.
contents_keystringyesStorage key the assembled file will live at. Pass verbatim to createImport.
partsarrayyesOne entry per part, in part-number order.
http_methodstringyesHTTP method to use when uploading each part. Currently always PUT.
headersobjectyesHeaders the client must include on each part upload (e.g. proxy-auth, signed-headers added by the storage backend). Usually empty; clients should iterate every entry and add each name with all of its values to the part-upload request. Each header may have multiple values.

CreateImportUploadRequest#

Body for POST /api/v2/databases/{owner}/{database}/imports/uploads. Asks the server to mint a multipart upload session for a file of content_length bytes split into num_parts parts; the response carries the pre-signed URLs to upload to.

FieldTypeRequiredDescription
content_lengthintegeryesTotal size of the file being uploaded, in bytes.
num_partsintegeryesNumber of parts the client will split the upload into.
file_typestringyesSource file format for an import.

CreateImportRequest#

Body for POST /api/v2/databases/{owner}/{database}/imports. Wraps a completed multipart upload (token, contents_key, completed_parts) into an import job that loads the file into table_name on branch_name. Returns 202 + an OperationRef.

FieldTypeRequiredDescription
branch_namestringyesThe branch to import onto.
table_namestringyesThe destination table.
file_namestringyesThe original file name (used for the commit message and import description).
file_sizeintegeryesSize of the uploaded file in bytes; must match the content_length from createImportUpload.
file_typestringyesSource file format for an import.
import_operationstringyesHow the imported rows are applied to the target table. create requires the table not to exist; overwrite replaces it; update upserts into an existing table; replace truncates then inserts.
tokenstringyesUpload-session token from createImportUpload.
contents_keystringyesContents key from createImportUpload.
completed_partsarrayyesOne entry per uploaded part, in any order.
file_parts_md5stringyesMD5 of the concatenated per-part MD5s, base64-encoded. Some backends require this for integrity verification of the assembled file.
primary_keysarrayyesPrimary-key column names. May be empty when the destination table already exists (its existing primary keys are used). Required (possibly empty) so a missing field fails fast rather than mis-importing as no-primary-key.
commit_messagestringnoOverride the default commit message the import produces.
pull_request_branch_namestringnoWhen set, the import lands on this branch (created from branch_name) and a pull request is opened against branch_name. When unset, the import lands directly on branch_name.
column_mapobjectnoOptional mapping from source column names to destination column names. Useful when the file’s columns don’t match the target table’s columns.

OperationStatus#

The lifecycle state of an async operation.

Enum values

Value
queued
running
succeeded
failed

OperationType#

The kind of work this operation performs.

Enum values

Value
import
merge
sql_write
fork
dolt_ci

OperationError#

Error details recorded when an operation reaches the failed status.

FieldTypeRequiredDescription
statusintegeryesHTTP-equivalent status code for the failure.
codestringyesA stable, machine-readable error code in SCREAMING_SNAKE_CASE. Clients branch on this value, never on the human-readable title/detail prose. The baseline codes below cover the standard HTTP failure categories; endpoint-specific codes (e.g. BRANCH_NOT_FOUND) are appended to this enum alongside the endpoints that emit them, which is an additive, non-breaking change under the v2 stability policy (§5.1).
titlestringyesA short, human-readable summary of the failure.
detailstringnoA human-readable explanation of the failure, sourced from the underlying operation error message when available.

Operation#

A long-running async operation. Every async mutation returns an OperationRef; poll GET /api/v2/operations/{id} until status is succeeded or failed. The id is opaque — pass it back to the poll endpoint verbatim.

FieldTypeRequiredDescription
idstringyesOpaque operation identifier. Pass verbatim to GET /api/v2/operations/{id}.
typestringyesThe kind of work this operation performs.
statusstringyesThe lifecycle state of an async operation.
created_atstringyesWhen the operation was enqueued.
cancelablebooleanyesReserved for a future cancel endpoint. Always false today — no POST /api/v2/operations/{id}/cancel exists yet.
errorobjectnoError details recorded when an operation reaches the failed status.
resultobjectnoPresent when status is succeeded. Shape depends on type: import/merge{ pull_id }; sql_write{ commit_sha }; fork{ database: { owner, name } }.

OperationRef#

A reference to an in-progress async operation, returned in 202 responses. Pass id to GET /api/v2/operations/{id} to poll for completion.

FieldTypeRequiredDescription
idstringyesThe operation ID.
hrefstringyesAbsolute URL of the poll endpoint.

Database#

A DoltHub database and its public metadata. v2 exposes the database’s own fields; caller-specific state (your role on it, whether you’ve starred it) is not part of this resource.

FieldTypeRequiredDescription
ownerstringyesThe user or organization that owns the database.
namestringyesThe database name, unique within the owner.
descriptionstringnoThe database’s short description.
visibilitystringyesWhether the database is publicly readable or private.
fork_network_countintegeryesThe total number of databases in this database’s fork network — transitive, counting forks-of-forks. The /forks endpoint returns immediate children only, so fork_network_count may exceed the length of that list.
star_countintegeryesThe number of users who have starred the database.
size_bytesintegeryesThe on-disk size of the database, in bytes.
last_write_atstringnoWhen the database last received a write.
parentobjectnoThe database this one was forked from. Omitted when this database is not a fork — i.e., it is the root of its fork network.
network_rootobjectnoThe original database at the root of this database’s fork network. Omitted when this database is itself the root (no ancestors).

Branch#

A branch in a database — a named pointer to a head commit. v2 exposes the branch’s identity (name) and the head it currently points at; the head commit’s full metadata (message, author, parents) belongs to the commit resource, not the branch list.

FieldTypeRequiredDescription
namestringyesThe branch name, unique within the database.
head_commit_shastringyesThe hash of the commit the branch currently points at.
last_updated_atstringnoWhen the head commit was committed; absent if the backend didn’t report it.

Tag#

A tag in a database — a named, optionally annotated pointer to a specific commit. v2 exposes the tag’s identity and the commit it targets; the target commit’s full metadata (message, author, parents) belongs to the commit resource, not the tag list.

FieldTypeRequiredDescription
namestringyesThe tag name, unique within the database.
commit_shastringyesThe hash of the commit the tag points at.
messagestringnoThe tag’s annotation message; omitted when the tag has none.
tagged_atstringnoWhen the tag was created; absent if the backend didn’t report it.

Release#

A named release of a database — a title and notes attached to a specific commit, often but not always paired with a tag of the same name. v2 exposes the release’s public fields; the internal release id is omitted (the tag is the user-facing identifier).

FieldTypeRequiredDescription
tagstringyesThe tag the release is published under, unique within the database.
titlestringyesThe release’s human-readable title.
commit_shastringyesThe hash of the commit the release points at.
descriptionstringnoThe release notes body (markdown). Omitted when the release has none.
created_atstringyesWhen the release was first published.
updated_atstringyesWhen the release was last edited; equals created_at for never-edited releases.

PullSummary#

The lean list shape of a pull request — title, state, creator, timestamps. Companion to the canonical Pull resource returned by the per-pull GET, which adds structured from_branch / to_branch references (fork-aware owner / database) needed to disambiguate cross-fork PRs.

FieldTypeRequiredDescription
pull_numberintegeryesThe per-database sequential identifier (à la GitHub PR numbers).
titlestringyesThe pull request’s human-readable title.
descriptionstringnoThe pull request description (markdown). Omitted when the pull has none.
statestringyesThe pull request’s lifecycle state.
created_atstringyesWhen the pull request was created.
creatorstringyesThe username of the user who created the pull request.

BranchRef#

A reference to a branch within a specific database. Carries the database so callers can disambiguate cross-fork pull requests, where from_branch and to_branch may live in different repositories.

FieldTypeRequiredDescription
databaseobjectyesA minimal reference to a database — owner and name only. Used wherever the API points at another database (a fork’s parent, a network’s root, an item in the forks list) without re-embedding the full Database resource.
branch_namestringyesThe branch name within the referenced database.

Pull#

The canonical pull-request resource. Same public fields as the list PullSummary plus structured from_branch / to_branch references that carry the database the branch lives in (necessary for cross-fork pulls, where the source branch lives in a different repository).

FieldTypeRequiredDescription
pull_numberintegeryesThe per-database sequential identifier (à la GitHub PR numbers).
titlestringyesThe pull request’s human-readable title.
descriptionstringnoThe pull request description (markdown). Omitted when the pull has none.
statestringyesThe pull request’s lifecycle state.
from_branchobjectyesA reference to a branch within a specific database. Carries the database so callers can disambiguate cross-fork pull requests, where from_branch and to_branch may live in different repositories.
to_branchobjectyesA reference to a branch within a specific database. Carries the database so callers can disambiguate cross-fork pull requests, where from_branch and to_branch may live in different repositories.
created_atstringyesWhen the pull request was created.
creatorstringyesThe username of the user who created the pull request.

PullComment#

A top-level comment on a pull request. Diff-line comments and review comments are modeled as separate resources (not in v2 yet).

FieldTypeRequiredDescription
comment_idstringyesThe opaque per-comment identifier, unique within the pull request.
authorstringyesThe username of the comment’s author.
bodystringyesThe comment text (markdown).
created_atstringyesWhen the comment was first posted.
updated_atstringyesWhen the comment was last edited (equals created_at if never edited).

QueryColumn#

One column in a query result’s schema.

FieldTypeRequiredDescription
namestringyesThe column name.
typestringyesThe column’s SQL type — e.g. VARCHAR(255), BIGINT, DATETIME(6). Clients parsing typed values are expected to read this and coerce cells accordingly.
is_primary_keybooleannoWhether the column is part of the source table’s primary key.
source_tablestringnoThe table this column came from. Empty for expressions or virtual columns (e.g. COUNT(*)).

QueryResult#

The result of a runSqlReadQuery call. SQL-level conditions (success, error, timeout, row-limit) live in status and message — they are query-level, not transport-level.

FieldTypeRequiredDescription
columnsarrayyesThe result schema — one entry per column, in the row’s cell order.
rowsarrayyesThe result rows. Each row is an array of cell values, ordered to match the columns schema. Non-NULL cells are serialized as strings regardless of the underlying SQL type; clients can parse per columns[i].type to coerce typed values. NULL cells are serialized as JSON null. BLOB-typed cells are returned as the placeholder string "<binary>" (the backend does not stream binary bytes over this endpoint); clients can detect blob columns via columns[i].type.
statusstringyesThe query’s execution status. success is the only status that guarantees rows and columns are fully populated.
messagestringnoServer-supplied message describing the status. Always populated for non-success statuses; usually empty on success.
warningsarraynoSQL-level warnings emitted by the query engine (e.g. truncated values).

EmailAddress#

An email address registered to a DoltHub user.

FieldTypeRequiredDescription
addressstringyesThe email address.
is_primarybooleanyesWhether this is the user’s primary email address.
is_verifiedbooleanyesWhether this email address has been verified.

User#

A DoltHub user. GET /api/v2/user returns the authenticated user’s profile. v2 returns only the public-facing profile fields — internal flags (super-admin, two-factor settings, API tokens) are never included.

FieldTypeRequiredDescription
usernamestringyesThe user’s DoltHub username (unique handle).
display_namestringnoThe user’s display name. May be empty.
biostringnoThe user’s bio. May be empty.
locationstringnoThe user’s stated location. May be empty.
website_urlstringnoThe user’s website URL. May be empty.
profile_pic_urlstringnoURL of the user’s profile picture. May be empty.
email_addressesarrayyesThe user’s registered email addresses.