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_nameThe Database Namepathstring

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:

Example response:

Expected Parameters

NameDescriptionInRequiredSchema
gitBranchThe Git Branchquery-string
fallbackBranchDefault branch to fallback toquery-string
Status CodeDescriptionExample Response/Type Definition
200OK
{
  "branch": "main",
  "reason": {
    "code": "DEFAULT_BRANCH",
    "message": "Default branch for this database (main)"
  }
}
400Bad Request
type ResolveBranch = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
5XXUnexpected Error