Mapping of git to Xata branches

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

This path allows managing the mapping between git and Xata branches, which is used by the /dbs/{db_name}/resolveBranch endpoint to resolve git branches to the associated Xata branches.

Expected parameters

NameDescriptionInRequiredSchema
db_name

The Database Name

path✅string

List Git Branches Mapping

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

Lists all the git branches in the mapping, and their associated Xata branches.

Example response:

{
  "mappings": [
      {
        "gitBranch": "main",
        "xataBranch": "main"
      },
      {
        "gitBranch": "gitBranch1",
        "xataBranch": "xataBranch1"
      }
      {
        "gitBranch": "xataBranch2",
        "xataBranch": "xataBranch2"
      }
  ]
}

Responses

type GetGitBranchesMapping = {
    mapping: {
        gitBranch: string;
        xataBranch: string;
    }[];
};
POST
https://{your-workspace-slug}.{region}.xata.sh/dbs/db_name/gitBranches

Adds an entry to the mapping of git branches to Xata branches. The git branch and the Xata branch must be present in the body of the request. If the Xata branch doesn't exist, a 400 error is returned.

If the git branch is already present in the mapping, the old entry is overwritten, and a warning message is included in the response. If the git branch is added and didn't exist before, the response code is 204. If the git branch existed and it was overwritten, the response code is 201.

Example request:

// POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
{
  "gitBranch": "fix/bug123",
  "xataBranch": "fix_bug"
}

Request Body Type Definition

type AddGitBranchesEntry = {
    /**
     * The name of the Git branch.
     */
    gitBranch: string;
    /**
     * The name of the Xata branch.
     */
    xataBranch: BranchName;
};
 
/**
 * @maxLength 255
 * @minLength 1
 * @pattern [a-zA-Z0-9_\-~]+
 */
type BranchName = string;

Responses

{
    "warning": "Git branch [fix/bug123] was already present in the mapping and was overwritten."
}
DELETE
https://{your-workspace-slug}.{region}.xata.sh/dbs/db_name/gitBranches

Removes an entry from the mapping of git branches to Xata branches. The name of the git branch must be passed as a query parameter. If the git branch is not found, the endpoint returns a 404 status code.

Example request:

// DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123

Expected parameters

NameDescriptionInRequiredSchema
gitBranch

The Git Branch to remove from the mapping

query✅string

Responses

type RemoveGitBranchesEntry = void;