> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Databases API

> Branches of a database for tests, previews and pull requests, plus Sleep when idle and waking a database.

Branches of a database for tests, previews and pull requests, plus Sleep when idle and waking a database. Base URL: `https://api.stackshift.cloud/api/v1`

Authentication: `bearer`. SDK-backed operations are traced to official source files in the coverage report. Routes without an SDK wrapper are explicitly marked contract-only.

| Method | SDK route | SDK method | Request type | Response type |
| - | - | - | - | - |
| `GET` | `/databases/{databaseId}/branches` | `DatabaseBranchesClient.list` | `None` | `DatabaseBranchList` |
| `POST` | `/databases/{databaseId}/branches` | `DatabaseBranchesClient.create` | `DatabaseBranchCreateInput` | `DatabaseBranchOperation` |
| `GET` | `/databases/{databaseId}/branches/options` | `DatabaseBranchesClient.options` | `None` | `DatabaseBranchOptions` |
| `GET` | `/databases/{databaseId}/branches/{branchId}/changes` | `DatabaseBranchesClient.changes` | `None` | `DatabaseBranchChanges` |
| `POST` | `/databases/{databaseId}/branches/{branchId}/scheduled-jobs/resume` | `DatabaseBranchesClient.resumeScheduledJobs` | `DatabaseBranchResumeScheduledJobsInput` | `DatabaseScheduledJobList` |
| `POST` | `/databases/{databaseId}/branches/{branchId}/retry` | `DatabaseBranchesClient.retry` | `DatabaseBranchRetryInput` | `DatabaseBranchOperation` |
| `GET` | `/databases/{databaseId}/branches/operations/{operationId}` | `DatabaseBranchesClient.operation` | `None` | `DatabaseBranchOperation` |
| `GET` | `/databases/{databaseId}/branches/{branchId}` | `DatabaseBranchesClient.get` | `None` | `DatabaseBranch` |
| `PATCH` | `/databases/{databaseId}/branches/{branchId}` | `DatabaseBranchesClient.update` | `DatabaseBranchUpdateInput` | `DatabaseBranch` |
| `DELETE` | `/databases/{databaseId}/branches/{branchId}` | `DatabaseBranchesClient.delete` | `DatabaseBranchDeleteOptions` | `DatabaseBranchOperation` |
| `POST` | `/databases/{databaseId}/branches/{branchId}/reset` | `DatabaseBranchesClient.reset` | `DatabaseBranchActionOptions` | `DatabaseBranchOperation` |
| `POST` | `/databases/{databaseId}/branches/{branchId}/promote` | `DatabaseBranchesClient.promote` | `DatabaseBranchPromoteInput` | `DatabaseBranchOperation` |
| `PUT` | `/databases/{databaseId}/sleep` | `DatabasesClient.sleep` | `DatabaseSleepInput` | `DatabaseSleep` |
| `POST` | `/databases/{databaseId}/wake` | `DatabasesClient.wake` | `DatabaseWakeOptions` | `DatabaseSleep` |
| `GET` | `/databases/{databaseId}/scheduled-jobs` | `DatabasesClient.scheduledJobs` | `None` | `DatabaseScheduledJobList` |
| `GET` | `/databases/{databaseId}/wake-events` | `DatabasesClient.wakeEvents` | `DatabaseWakeEventOptions` | `DatabaseWakeEventList` |
| `GET` | `/databases/{databaseId}/billing` | `DatabasesClient.billing` | `None` | `DatabaseBilling` |
| `GET` | `/databases/{databaseId}/branch-usage` | `DatabasesClient.branchUsage` | `None` | `DatabaseBranchUsage` |
| `POST` | `/databases/{databaseId}/branch-usage/pay` | `DatabasesClient.payBranchUsage` | `None` | `DatabaseBranchUsageCheckout` |
| `POST` | `/databases/{databaseId}/move-to-instant-branches` | `DatabasesClient.moveToInstantBranches` | `None` | `DatabaseInstantBranchesMove` |
| `GET` | `/databases/{databaseId}/move-to-instant-branches` | `DatabasesClient.instantBranchesMove` | `None` | `DatabaseInstantBranchesMove` |
| `GET` | `/databases/{databaseId}/credentials` | `DatabaseBranchesClient.url` | `DatabaseBranchUrlOptions` | `DatabaseCredentials` |

## Error envelope

Non-2xx responses use the StackShift response envelope. Check `success: false`, then read the structured `error` value and HTTP status. SDK clients surface the status, code, message, and details through their native error type.

## Examples

These static examples show the verified route and authentication boundary. Use the official SDK method shown in each heading so serialization and response unwrapping remain consistent with the contract.

### `GET /databases/{databaseId}/branches`

```bash theme={null}
curl -X GET "https://api.stackshift.cloud/api/v1/databases/example-id/branches"   -H "Authorization: Bearer $STACKSHIFT_API_KEY"
```

The SDK serializes any supported query options for this operation.

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "branches": [
      {
        "id": "example-id",
        "name": "example",
        "parent_database_id": "example-id",
        "root_database_id": "example-id",
        "depth": 1,
        "mechanism": "instant",
        "source": {
          "kind": "now"
        },
        "state": "creating",
        "created_by": "user",
        "seed": {
          "scheduled_jobs_paused": 1,
          "subscriptions_disabled": 1,
          "replication_slots_dropped": 1,
          "other_logins_reset": 1
        },
        "created_at": "2026-08-03T00:00:00Z",
        "updated_at": "2026-08-03T00:00:00Z"
      }
    ],
    "allowance": {
      "used": 1,
      "limit": 1,
      "account_used": 1,
      "account_limit": 1,
      "awake_used": 1,
      "awake_limit": 1,
      "max_ttl_hours": 1
    }
  }
}
```

### `POST /databases/{databaseId}/branches`

```bash theme={null}
curl -X POST "https://api.stackshift.cloud/api/v1/databases/example-id/branches"   -H "Authorization: Bearer $STACKSHIFT_API_KEY"   -H "Content-Type: application/json"   --data '{"name":"example"}'
```

The request body is derived from `DatabaseBranchCreateInput` in the official SDK contract.

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "id": "example-id",
    "branch_database_id": "example-id",
    "parent_database_id": "example-id",
    "kind": "create",
    "status": "pending",
    "phase": "example",
    "created_at": "2026-08-03T00:00:00Z",
    "updated_at": "2026-08-03T00:00:00Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.