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.

List branches

Retrieves a list of all branches within a project.

GET /organizations/{organizationID}/projects/{projectID}/branches

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project

Response

{
  "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 branch",
      "parentID": null
    }
  ]
}

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

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project

Request body

{
  "name": "new-branch",
  "description": "Development branch",
  "parentID": "br_123",
  "configuration": {
    "image": "postgresql:16",
    "instanceType": "standard",
    "instances": 1,
    "region": "us-east-1",
    "storage": 10
  }
}

Request body parameters

ParameterTypeDescription
namestringHuman-readable name for the new branch
descriptionstringOptional description for the branch purpose or contents (max 50 characters)
parentIDstringIf present, the branch will inherit the parent branch configuration and data
configurationobjectConfiguration for the underlying database cluster if not inheriting from a parent

Response

{
  "id": "br_456",
  "name": "new-branch",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-01T00:00:00Z",
  "region": "us-east-1",
  "publicAccess": false,
  "description": "Development branch",
  "parentID": "br_123",
  "connectionString": "postgresql://..."
}

Get branch

Retrieves detailed information about a specific branch.

GET /organizations/{organizationID}/projects/{projectID}/branches/{branchID}

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project
branchIDstringUnique identifier for the branch

Response

{
  "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 branch",
  "parentID": null,
  "connectionString": "postgresql://...",
  "configuration": {
    "image": "postgresql:16",
    "instanceType": "standard",
    "instances": 1,
    "region": "us-east-1",
    "storage": 10
  },
  "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"
    }
  }
}

Update branch

Updates the configuration of a branch.

PATCH /organizations/{organizationID}/projects/{projectID}/branches/{branchID}

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project
branchIDstringUnique identifier for the branch

Request body

{
  "name": "updated-branch",
  "description": "Updated description"
}

Response

{
  "id": "br_123",
  "name": "updated-branch",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-01T00:00:00Z",
  "region": "us-east-1",
  "publicAccess": false,
  "description": "Updated description",
  "parentID": null,
  "connectionString": "postgresql://..."
}

Delete branch

Permanently deletes a branch and all its associated data. This action cannot be undone.

DELETE /organizations/{organizationID}/projects/{projectID}/branches/{branchID}

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project
branchIDstringUnique identifier for the branch

Response

Returns a 204 status code with no content on success.

Get branch metrics

Retrieves metrics for a specific branch over a time period.

POST /organizations/{organizationID}/projects/{projectID}/branches/{branchID}/metrics

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
projectIDstringUnique identifier for the project
branchIDstringUnique identifier for the branch

Request body

{
  "start": "2024-01-01T00:00:00Z",
  "end": "2024-01-01T23:59:59Z",
  "metric": "cpu",
  "instances": ["inst_123", "inst_456"],
  "aggregations": ["avg", "max", "min"]
}

Request body parameters

ParameterTypeDescription
startstring (date-time)Start time for the metrics query
endstring (date-time)End time for the metrics query
metricstringMetric name to query. Options: cpu, memory, disk
instancesarrayList of instance IDs to query
aggregationsarrayList of aggregations to apply. Options: avg, max, min

Response

{
  "start": "2024-01-01T00:00:00Z",
  "end": "2024-01-01T23:59:59Z",
  "metric": "cpu",
  "unit": "percentage",
  "series": [
    {
      "instance": "inst_123",
      "aggregation": "avg",
      "data": [
        {
          "timestamp": "2024-01-01T00:00:00Z",
          "value": 25.5
        },
        {
          "timestamp": "2024-01-01T01:00:00Z",
          "value": 30.2
        }
      ]
    }
  ]
}

Metric types

  • cpu: CPU usage percentage
  • memory: Memory usage in bytes
  • disk: Disk usage in bytes

Aggregation types

  • avg: Average value over the time interval
  • max: Maximum value over the time interval
  • min: Minimum value over the time interval