Skip to content

Branching API Reference

All branching endpoints require authentication via service key, client key, or JWT token.

Base path: /api/v1/admin/branches

POST /api/v1/admin/branches

Terminal window
curl -X POST http://localhost:8080/api/v1/admin/branches \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "feature-login",
"parent_branch_id": null,
"data_clone_mode": "schema_only",
"type": "preview",
"expires_in": "24h"
}'

Request Body:

FieldTypeRequiredDescription
namestringYesBranch name (1-100 chars)
parent_branch_iduuidNoParent branch ID (defaults to main)
data_clone_modestringNoschema_only, full_clone, or seed_data
typestringNopreview or persistent
expires_instringNoDuration like 24h, 7d
github_pr_numberintNoAssociated GitHub PR number
github_pr_urlstringNoGitHub PR URL
github_repostringNoGitHub repository (owner/repo)

Response: 201 Created

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "feature-login",
"slug": "feature-login",
"database_name": "branch_feature_login",
"status": "creating",
"type": "preview",
"data_clone_mode": "schema_only",
"created_at": "2024-01-15T10:00:00Z",
"expires_at": "2024-01-16T10:00:00Z"
}

GET /api/v1/admin/branches

Terminal window
curl http://localhost:8080/api/v1/admin/branches \
-H "Authorization: Bearer $TOKEN"

Query Parameters:

ParamTypeDescription
statusstringFilter by status
typestringFilter by type
created_byuuidFilter by creator
limitintMax results (default 50)
offsetintPagination offset

Response: 200 OK

{
"branches": [
{
"id": "...",
"name": "feature-login",
"slug": "feature-login",
"status": "ready",
"type": "preview",
"created_at": "2024-01-15T10:00:00Z"
}
],
"total": 5
}

GET /api/v1/admin/branches/:id

The :id can be either a UUID or a slug.

Terminal window
curl http://localhost:8080/api/v1/admin/branches/feature-login \
-H "Authorization: Bearer $TOKEN"

Response: 200 OK

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "feature-login",
"slug": "feature-login",
"database_name": "branch_feature_login",
"status": "ready",
"type": "preview",
"data_clone_mode": "schema_only",
"parent_branch_id": null,
"created_by": "user-123",
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:15Z",
"expires_at": "2024-01-16T10:00:00Z"
}

DELETE /api/v1/admin/branches/:id

Terminal window
curl -X DELETE http://localhost:8080/api/v1/admin/branches/feature-login \
-H "Authorization: Bearer $TOKEN"

Response: 204 No Content

Errors:

  • 403 Forbidden - Cannot delete main branch
  • 403 Forbidden - No admin access to branch
  • 404 Not Found - Branch not found

POST /api/v1/admin/branches/:id/reset

Resets the branch to its parent state (drops and recreates the database).

Terminal window
curl -X POST http://localhost:8080/api/v1/admin/branches/feature-login/reset \
-H "Authorization: Bearer $TOKEN"

Response: 200 OK

{
"id": "...",
"status": "ready",
"updated_at": "2024-01-15T12:00:00Z"
}

GET /api/v1/admin/branches/:id/activity

Terminal window
curl http://localhost:8080/api/v1/admin/branches/feature-login/activity \
-H "Authorization: Bearer $TOKEN"

Query Parameters:

ParamTypeDescription
limitintMax results (default 50, max 100)

Response: 200 OK

{
"activity": [
{
"id": "...",
"action": "created",
"user_id": "user-123",
"details": {"data_clone_mode": "schema_only"},
"created_at": "2024-01-15T10:00:00Z"
}
]
}

GET /api/v1/admin/branches/stats/pools

Returns connection pool statistics for all branches (for debugging/monitoring).

Terminal window
curl http://localhost:8080/api/v1/admin/branches/stats/pools \
-H "Authorization: Bearer $TOKEN"

Response: 200 OK

{
"pools": {
"feature-login": {
"total_conns": 10,
"idle_conns": 8,
"acquired_conns": 2
}
}
}

GET /api/v1/admin/branches/github/configs

Terminal window
curl http://localhost:8080/api/v1/admin/branches/github/configs \
-H "Authorization: Bearer $TOKEN"

POST /api/v1/admin/branches/github/configs

Terminal window
curl -X POST http://localhost:8080/api/v1/admin/branches/github/configs \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"repository": "owner/repo",
"webhook_secret": "your-webhook-secret",
"auto_create_on_pr": true,
"auto_delete_on_merge": true,
"default_data_clone_mode": "schema_only"
}'

DELETE /api/v1/admin/branches/github/configs/:repository

Terminal window
curl -X DELETE "http://localhost:8080/api/v1/admin/branches/github/configs/owner%2Frepo" \
-H "Authorization: Bearer $TOKEN"

List all database branches.

Terminal window
fluxbase branch list [flags]
Flags:
-o, --output string Output format: table, json, yaml (default "table")
--status string Filter by status
--type string Filter by type

Get details of a specific branch.

Terminal window
fluxbase branch get <name-or-id> [flags]
Flags:
-o, --output string Output format: table, json, yaml (default "table")

Create a new database branch.

Terminal window
fluxbase branch create <name> [flags]
Flags:
--from string Parent branch slug or ID
--clone-mode string Data clone mode: schema_only, full_clone (default "schema_only")
--type string Branch type: preview, persistent (default "preview")
--expires-in string Expiration duration (e.g., 24h, 7d)

Delete a database branch.

Terminal window
fluxbase branch delete <name-or-id> [flags]
Flags:
--force Skip confirmation

Reset a branch to its parent state.

Terminal window
fluxbase branch reset <name-or-id> [flags]
Flags:
--force Skip confirmation

Show the status of a branch.

Terminal window
fluxbase branch status <name-or-id>

Show the activity log for a branch.

Terminal window
fluxbase branch activity <name-or-id> [flags]
Flags:
--limit int Maximum number of entries (default 50)

Show connection pool statistics.

Terminal window
fluxbase branch stats
CodeErrorDescription
branching_disabled503Branching is not enabled
branch_not_found404Branch does not exist
branch_exists409Branch with this name already exists
cannot_delete_main403Cannot delete the main branch
cannot_reset_main403Cannot reset the main branch
max_branches_reached403Maximum branches limit reached
access_denied403No permission for this operation
validation_error400Invalid request parameters