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
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_name | The Database Name | path | ✅ | string |
Resolve a Git Branch to a Xata Branch
GEThttps://{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](/docs/api-reference/dbs/db_name/gitBranches), 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: ```json // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg ``` Example response: ```json { "branch": "main", "reason": { "code": "DEFAULT_BRANCH", "message": "Default branch for this database (main)" } } ```
Expected parameters
Name | Description | In | Required | Schema |
---|---|---|---|---|
gitBranch | The Git Branch | query | - | string |
fallbackBranch | Default branch to fallback to | query | - | string |