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

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "mappings": [
      {
        "gitBranch": "main",
        "xataBranch": "main"
      },
      {
        "gitBranch": "gitBranch1",
        "xataBranch": "xataBranch1"
      }
      {
        "gitBranch": "xataBranch2",
        "xataBranch": "xataBranch2"
      }
  ]
}
Status CodeDescriptionExample Response/Type Definition
200OK
type GetGitBranchesMapping = {
    mapping: {
        gitBranch: string;
        xataBranch: string;
    }[];
};
400Bad Request
type GetGitBranchesMapping = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
5XXUnexpected Error
defaultUnexpected Error
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:

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

Request Body Type Definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
Status CodeDescriptionExample Response/Type Definition
201Operation was successful with warnings
{
  "warning": "Git branch [fix/bug123] was already present in the mapping and was overwritten."
}
204Operation was successful without warnings
400Bad Request
type AddGitBranchesEntry = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
5XXUnexpected Error
defaultUnexpected Error
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:

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

Expected Parameters

NameDescriptionInRequiredSchema
gitBranchThe Git Branch to remove from the mappingquerystring
Status CodeDescriptionExample Response/Type Definition
204OK
400Bad Request
type RemoveGitBranchesEntry = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404The git branch was not found in the mapping
5XXUnexpected Error
defaultUnexpected Error