Resolve the branch to use

https://{your-workspace-slug}.{region}.xata.sh/dbs/db_name/resolveBranch

This endpoint is typically used by the Xata SDKs to resolve the correct branch to use in a particular situation. The main input is the git branch.

Expected parameters

NameDescriptionInRequiredSchema
db_name

The Database Name

pathstring

Resolve a Git Branch to a Xata Branch

GET
https://{your-workspace-slug}.{region}.xata.sh/dbs/db_name/resolveBranch

In order to resolve the database branch, the following algorithm is used:

  • if the gitBranch was provided and is found in the git branches mapping, the associated Xata branch is returned
  • else, if a Xata branch with the exact same name as gitBranch exists, return it
  • else, if fallbackBranch is provided and a branch with that name exists, return it
  • else, return the default branch of the DB (main or the first branch)

Example call:

// GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg

Example response:

{
  "branch": "main",
  "reason": {
    "code": "DEFAULT_BRANCH",
    "message": "Default branch for this database (main)"
  }
}

Expected parameters

NameDescriptionInRequiredSchema
gitBranch

The Git Branch

query-string
fallbackBranch

Default branch to fallback to

query-string

Responses

{
    "branch": "main",
    "reason": {
        "code": "DEFAULT_BRANCH",
        "message": "Default branch for this database (main)"
    }
}