Branches API
Manage database branches and their settings
The Branches API allows you to manage your database branches, including listing, creating, updating, and deleting branches. All endpoints require authentication via API key or OIDC.
Authentication
All endpoints require authentication. You can authenticate using:
- API Key: Include your API key in the
Authorization
header:Authorization: Bearer <your-api-key>
- OIDC: Use OIDC tokens for authentication
Required scopes for different operations:
- branch:read: Read branch information and list branches
- branch:write: Create, update, and delete branches
- credentials:read: Access branch credentials
- metrics:read: Access branch metrics
List branches
Retrieves a list of all branches within a project.
GET /organizations/{organizationID}/projects/{projectID}/branches
Summary
Returns a paginated list of branches in a project with basic metadata including ID, name, creation date, region, and public access settings.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
Response
Status: 200 OK
{
"branches": [
{
"id": "br_123",
"name": "main",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z",
"region": "us-east-1",
"publicAccess": false,
"description": "Main production branch",
"parentID": null
}
]
}
Response schema
Field | Type | Description |
---|---|---|
branches | array | Array of branch objects |
id | string | Unique identifier for the branch |
name | string | Human-readable name for the branch |
createdAt | string (date-time) | Timestamp when the branch was created |
updatedAt | string (date-time) | Timestamp when the branch was last updated |
region | string | Geographic region where the branch is deployed |
publicAccess | boolean | Whether the branch allows public access without authentication |
description | string | Optional description of the branch purpose or contents |
parentID | string | Identifier of the parent branch if derived, null otherwise |
Create branch
Creates a new branch within a project. Branches can be created from scratch or derived from an existing parent branch.
POST /organizations/{organizationID}/projects/{projectID}/branches
Summary
Creates a new database branch with specified configuration. If a parent branch is specified, the new branch inherits the parent's configuration and data. Otherwise, a new cluster is created with the specified configuration.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
Request body
{
"name": "staging-branch",
"description": "Staging environment for testing",
"parentID": "br_123",
"configuration": {
"image": "postgresql:17",
"instanceType": "small",
"instances": 1,
"region": "us-east-1"
},
"scaleToZero": {
"enabled": true,
"idleTime": 300
}
}
Request body parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | string | Yes | Human-readable name for the new branch (max 50 characters, pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9- ]*$ ) |
description | string | No | Optional description for the branch purpose or contents (max 50 characters) |
parentID | string | No | If present, the branch will inherit the parent branch configuration and data |
configuration | ClusterConfiguration | No | Configuration for the underlying database cluster if not inheriting from a parent |
scaleToZero | ScaleToZeroConfiguration | No | Scale to zero configuration for the branch |
Response
Status: 201 Created
{
"id": "br_456",
"name": "staging-branch",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z",
"region": "us-east-1",
"publicAccess": false,
"description": "Staging environment for testing",
"parentID": "br_123",
"connectionString": "postgresql://xata_user:password@host:port/database"
}
Response schema
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the created branch |
name | string | Name of the branch |
createdAt | string (date-time) | Timestamp when the branch was created |
updatedAt | string (date-time) | Timestamp when the branch was last updated |
region | string | Geographic region where the branch is deployed |
publicAccess | boolean | Whether the branch allows public access |
description | string | Description of the branch |
parentID | string | Identifier of the parent branch if derived |
connectionString | string | Database connection string for the branch |
Get branch
Retrieves detailed information about a specific branch.
GET /organizations/{organizationID}/projects/{projectID}/branches/{branchID}
Summary
Returns comprehensive information about a branch including its configuration, status, connection details, and operational state.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
branchID | string | Yes | Unique identifier for the branch |
Response
Status: 200 OK
{
"id": "br_123",
"name": "main",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z",
"region": "us-east-1",
"publicAccess": false,
"description": "Main production branch",
"parentID": null,
"connectionString": "postgresql://xata_user:password@host:port/database",
"configuration": {
"image": "postgresql:17",
"instanceType": "small",
"instances": 1,
"region": "us-east-1"
},
"status": {
"instanceCount": 1,
"instanceReadyCount": 1,
"instances": [
{
"id": "inst_123",
"status": "ready",
"region": "us-east-1",
"createdAt": "2024-01-01T00:00:00Z"
}
],
"lifecycle": {
"phase": "running",
"message": "Branch is operational"
}
},
"scaleToZero": {
"enabled": true,
"idleTime": 300
}
}
Response schema
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the branch |
name | string | Human-readable name for the branch |
createdAt | string (date-time) | Timestamp when the branch was created |
updatedAt | string (date-time) | Timestamp when the branch was last updated |
region | string | Geographic region where the branch is deployed |
publicAccess | boolean | Whether the branch allows public access |
description | string | Description of the branch |
parentID | string | Identifier of the parent branch if derived |
connectionString | string | Database connection string for the branch |
configuration | ClusterConfiguration | Configuration details for the underlying database cluster |
status | BranchStatus | Current operational status of the branch |
scaleToZero | ScaleToZeroConfiguration | Scale to zero configuration for the branch |
Update branch
Updates the configuration of a branch.
PATCH /organizations/{organizationID}/projects/{projectID}/branches/{branchID}
Summary
Updates branch metadata such as name and description. Note that cluster configuration changes require creating a new branch.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
branchID | string | Yes | Unique identifier for the branch |
Request body
{
"name": "updated-branch-name",
"description": "Updated description for the branch"
}
Request body parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | string | No | New name for the branch |
description | string | No | New description for the branch |
Response
Status: 200 OK
{
"id": "br_123",
"name": "updated-branch-name",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z",
"region": "us-east-1",
"publicAccess": false,
"description": "Updated description for the branch",
"parentID": null,
"connectionString": "postgresql://xata_user:password@host:port/database"
}
Delete branch
Permanently deletes a branch and all its associated data.
DELETE /organizations/{organizationID}/projects/{projectID}/branches/{branchID}
Summary
Permanently removes a branch and all associated data. This action cannot be undone and will terminate all active connections.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
branchID | string | Yes | Unique identifier for the branch |
Response
Status: 204 No Content
No response body is returned on successful deletion.
Get branch credentials
Retrieves credentials for accessing a branch database.
GET /organizations/{organizationID}/projects/{projectID}/branches/{branchID}/credentials
Summary
Returns database credentials (username and password) for connecting to a specific branch. These credentials can be used with the connection string returned by the branch details endpoint.
Path parameters
Parameter | Type | Required | Description |
---|---|---|---|
organizationID | string | Yes | Unique identifier for the organization |
projectID | string | Yes | Unique identifier for the project |
branchID | string | Yes | Unique identifier for the branch |
Query parameters
Parameter | Type | Required | Description |
---|---|---|---|
username | string | No | Username that the credentials are requested for (optional) |
Response
Status: 200 OK
{
"username": "xata_user",
"password": "secure_password_123"
}
Response schema
Field | Type | Description |
---|---|---|
username | string | Username for accessing the branch database |
password | string | Password for accessing the branch database |
Branch Metrics
For detailed metrics and monitoring data for branches, see the Metrics API documentation.
The Metrics API provides comprehensive performance monitoring including CPU, memory, and disk usage across branch instances with support for multiple aggregation types and time-series data.
Error Handling
The API uses standard HTTP status codes and returns error responses in the following format:
{
"id": "error_identifier",
"message": "Human-readable error message explaining the issue"
}
Common error responses
Status | Error Type | Description |
---|---|---|
400 | BadRequestError | Request was malformed or contained invalid parameters |
401 | AuthorizationError | Authentication failed or is missing |
404 | GenericError | Requested resource does not exist |
5XX | GenericError | Server error occurred |
Schema Reference
Core Data Models
BranchListMetadata
Basic branch information returned when listing branches.
Field | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the branch |
name | string | Yes | Human-readable name for the branch |
createdAt | string (date-time) | Yes | Timestamp when the branch was created |
updatedAt | string (date-time) | Yes | Timestamp when the branch was last updated |
region | string | Yes | Geographic region where the branch is deployed |
publicAccess | boolean | Yes | Whether the branch allows public access without authentication |
description | string | No | Optional description of the branch purpose or contents |
parentID | string | No | Identifier of the parent branch if this is a derived branch, null otherwise |
BranchMetadata
Complete branch information including configuration and status details.
Field | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the branch |
name | string | Yes | Human-readable name for the branch |
createdAt | string (date-time) | Yes | Timestamp when the branch was created |
updatedAt | string (date-time) | Yes | Timestamp when the branch was last updated |
region | string | Yes | Geographic region where the branch is deployed |
status | BranchStatus | Yes | Current operational status of the branch |
connectionString | string | Yes | Database connection string for accessing this branch |
configuration | ClusterConfiguration | Yes | Configuration details for the underlying database cluster |
publicAccess | boolean | Yes | Whether the branch allows public access without authentication |
scaleToZero | ScaleToZeroConfiguration | Yes | Scale to zero configuration for the branch |
description | string | No | Optional description of the branch purpose or contents |
parentID | string | No | Identifier of the parent branch if this is a derived branch, null otherwise |
BranchShortMetadata
Simplified branch information returned for create/update operations.
Field | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the branch |
name | string | Yes | Human-readable name for the branch |
createdAt | string (date-time) | Yes | Timestamp when the branch was created |
updatedAt | string (date-time) | Yes | Timestamp when the branch was last updated |
region | string | Yes | Geographic region where the branch is deployed |
publicAccess | boolean | Yes | Whether the branch allows public access without authentication |
connectionString | string | No | Database connection string for accessing this branch |
description | string | No | Optional description of the branch purpose or contents |
parentID | string | No | Identifier of the parent branch if this is a derived branch, null otherwise |
ClusterConfiguration
Database cluster configuration including image, instance type, and region.
Field | Type | Required | Description |
---|---|---|---|
image | string | Yes | Database image to use (e.g., "postgresql:17") |
instanceType | string | Yes | Instance type for the database cluster |
instances | integer | Yes | Number of database instances |
region | string | Yes | Geographic region for deployment |
ScaleToZeroConfiguration
Configuration for automatic scaling to zero when branches are idle.
Field | Type | Required | Description |
---|---|---|---|
enabled | boolean | Yes | Whether scale to zero is enabled |
idleTime | integer | Yes | Time in seconds before scaling to zero when idle |
BranchStatus
Operational status information including instance counts and lifecycle state.
Field | Type | Required | Description |
---|---|---|---|
instanceCount | integer | Yes | Total number of instances for the branch |
instanceReadyCount | integer | Yes | Number of instances that are ready |
instances | array | Yes | Array of instance objects with status information |
lifecycle | object | Yes | Lifecycle information including phase and message |
BranchCredentials
Database access credentials for a specific branch.
Field | Type | Required | Description |
---|---|---|---|
username | string | Yes | Username for accessing the branch database |
password | string | Yes | Password for accessing the branch database |
BranchCreationDetails
Details required when creating a new branch.
Field | Type | Required | Description |
---|---|---|---|
name | string | Yes | Human-readable name for the new branch |
description | string | No | Optional description for the branch purpose or contents (max 50 characters, pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9- ]*$ ) |
parentID | string | No | If present, the branch will inherit the parent branch configuration and data |
configuration | ClusterConfiguration | No | Configuration for the underlying database cluster if not inheriting from a parent |
scaleToZero | ScaleToZeroConfiguration | No | Scale to zero configuration for the branch |
BranchUpdateDetails
Details that can be updated for an existing branch.
Field | Type | Required | Description |
---|---|---|---|
name | string | No | New name for the branch |
description | string | No | New description for the branch |
InstanceMetadata
Information about a specific database instance.
Field | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the instance |
status | string | Yes | Current status of the instance |
region | string | Yes | Geographic region where the instance is deployed |
createdAt | string (date-time) | Yes | Timestamp when the instance was created |
LifecycleInfo
Lifecycle information for a branch.
Field | Type | Required | Description |
---|---|---|---|
phase | string | Yes | Current lifecycle phase (e.g., "running", "starting", "stopping") |
message | string | Yes | Human-readable message describing the current state |