---
title: "Create a database branch"
method: POST
path: "/api/v1/databases/{databaseId}/branches"
tags: ["Databases"]
---

# Create a database branch

`POST /api/v1/databases/{databaseId}/branches`

## Request

- Base URL: `https://app.khotan.com`
- URL: `https://app.khotan.com/api/v1/databases/{databaseId}/branches`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Branches a ready database synchronously and responds 201 with the persisted record whether provisioning ends ready or failed; branch on the returned status. Omit parentBranchId to branch from the database root. Expiration: omit expiresAt and noExpiry for the ephemeral default, pass expiresAt (ISO 8601) for an explicit expiry, or noExpiry true for a non-expiring branch. This operation is not idempotent.

## Path parameters

- `databaseId` string, required

## Request body

- object
  - `name` string, required
  - `parentBranchId` string, nullable
  - `initSource` 'parent-data' | 'schema-only', required
  - `parentTimestamp` string, date-time, nullable
  - `expiresAt` string, date-time, nullable
  - `noExpiry` boolean, nullable

## Response `201`

The persisted branch record, in ready or failed status.

- object
  - `id` string, required
  - `databaseId` string, required
  - `parentBranchId` string, nullable, required
  - `name` string, required
  - `status` 'creating' | 'ready' | 'failed', required
  - `initSource` 'parent-data' | 'schema-only', required
  - `parentTimestamp` string, nullable, required
  - `expiresAt` string, nullable, required
  - `endpointHost` string, nullable, required
  - `createdAt` string, required
  - `updatedAt` string, required
  - `readyAt` string, nullable, required
  - `failedAt` string, nullable, required
  - `failureState` object, nullable, required
    - `code` 'provider_unavailable' | 'provider_rejected' | 'internal_error', required
    - `message` string, required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Authentication is missing or invalid.
- `404`: The resource was not found.
- `429`: Too many requests; retry after the indicated delay.

---

[API](https://skmtc.dev/khotan/apis/khotan-api.md) - [All operations](https://skmtc.dev/khotan/apis/khotan-api/llms.txt) - [OpenAPI document](https://skmtc.dev/khotan/apis/khotan-api/revisions/90b512a53e42?raw)
