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

# Create a branch

> Start an async branch create and get an operation handle

Branch creation is asynchronous: the create call returns an operation handle, and polling that operation gives you the branch's connection details.

All three body fields are required. For Postgres branches, `service_type` is `postgres` — not the connector type `postgresql`.

The response is `202 Accepted` with an operation handle:

```json theme={null}
{
  "operation_id": "op_123",
  "status": "pending",
  "type": "branch_create",
  "resource_id": "br_123"
}
```

Poll the operation until it finishes. On `completed`, its `result` holds the branch details:

```bash theme={null}
curl -H "Authorization: Bearer $ARDENT_TOKEN"   "https://api.tryardent.com/v1/operations/op_123?wait=10"
```

```json theme={null}
{
  "id": "op_123",
  "status": "completed",
  "result": {
    "branch_id": "br_123",
    "name": "pr-123",
    "connector_id": "conn_123",
    "service_type": "postgres",
    "status": "active",
    "branch_url": "postgresql://user:***@pr-123-postgres.routing.tryardent.com:5432/db?sslmode=require&channel_binding=disable",
    "pooled_branch_url": null,
    "pooled_branch_prisma_url": null,
    "created_at": "2026-06-01T12:00:00Z",
    "read_ready_at": "2026-06-01T12:00:05Z",
    "write_ready_at": "2026-06-01T12:00:05Z",
    "masked_ready_at": null
  }
}
```

See [Operations](/api/operations) for the polling model and the `?wait=` parameter.

<Warning>
  Treat `branch_url` as sensitive, and use it exactly as returned — including `sslmode=require` and `channel_binding=disable`. A `completed` operation can still return a null `result` or a null `branch_url`, so confirm `result.branch_url` is present and non-empty before using it. If it's missing, fail closed: never fall back to the main connection string or any other configured URL.
</Warning>

Retries are safe. Send an `X-Idempotency-Key` header with the create request; re-sending the same connector, service type, and name resumes the original request instead of creating a duplicate.

Create can fail with: `400` (a required field is missing), `409` (this create is already in flight, or the idempotency key was reused for a different request), `422` (the connector's engine isn't ready to branch), or `503` (Ardent could not start the work — retry).


## OpenAPI

````yaml openapi.public.json POST /v1/branch/create
openapi: 3.1.0
info:
  description: >-
    Public Ardent API. Generated by scripts/export_public_openapi.py — do not
    edit by hand.
  title: Ardent API
  version: v1
servers:
  - url: https://api.tryardent.com
security: []
paths:
  /v1/branch/create:
    post:
      tags:
        - v1-branching
      summary: Create Service Branch
      operationId: create_service_branch_v1_branch_create_post
      parameters:
        - description: >-
            Makes retries safe: re-sending the same connector, service type, and
            name resumes the original request instead of creating a duplicate.
          in: header
          name: X-Idempotency-Key
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              description: >-
                Body of POST /v1/branch/create.


                Spec-only today: the handler parses the raw body by hand so a
                missing

                field keeps returning the documented 400, not Pydantic's 422.
                Keep the

                fields in sync with the hand parsing below.
              properties:
                connector_id:
                  description: Connector to branch from.
                  title: Connector Id
                  type: string
                name:
                  description: Branch name, unique per connector.
                  title: Name
                  type: string
                service_type:
                  description: >-
                    Service to branch; `postgres`, not the connector type
                    `postgresql`.
                  title: Service Type
                  type: string
              required:
                - connector_id
                - service_type
                - name
              title: BranchCreateRequest
              type: object
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OperationHandle'
          description: >-
            Create accepted. Poll `GET /v1/operations/{operation_id}` for the
            branch details. Idempotent replays carry an `X-Idempotency-Replay:
            true` response header.
        '400':
          description: >-
            A required field is missing, or the branch name or idempotency key
            is invalid.
        '409':
          description: >-
            This create is already in flight, or the idempotency key was reused
            for a different request.
        '422':
          description: The connector's engine isn't ready to branch.
        '503':
          description: Ardent could not start the work — safe to retry.
      security:
        - bearerAuth: []
components:
  schemas:
    OperationHandle:
      properties:
        operation_id:
          description: Operation to poll at `GET /v1/operations/{operation_id}`.
          title: Operation Id
          type: string
        resource_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            ID of the resource being created or acted on (the branch ID for
            branch create).
          title: Resource Id
        status:
          $ref: '#/components/schemas/OperationStatus'
          description: Status at acceptance time.
        type:
          $ref: '#/components/schemas/OperationType'
          description: The kind of work this operation tracks, for example `branch_create`.
      required:
        - operation_id
        - status
        - type
        - resource_id
      title: OperationHandle
      type: object
    OperationStatus:
      enum:
        - pending
        - running
        - completed
        - failed
      title: OperationStatus
      type: string
    OperationType:
      enum:
        - connector_engine_setup
        - connector_reset
        - connector_deep_reset
        - connector_discovery
        - connector_delete
        - connector_secret_purge
        - connector_rollout
        - connector_replication_rollback
        - connector_debezium_cutover
        - connector_debezium_shadow_cleanup
        - environment_deploy
        - environment_destroy
        - branch_create
        - branch_delete
      title: OperationType
      type: string
  securitySchemes:
    bearerAuth:
      description: >-
        Ardent API key (sk-ard_live_… / sk-ard_test_…) or a dashboard session
        token.
      scheme: bearer
      type: http

````