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

# Create branch



## OpenAPI

````yaml https://api.specular.dev/openapi.json post /branches/
openapi: 3.0.0
info:
  title: Specular API
  description: Backend-as-a-Service API for managing projects and branches
  version: 1.0.0
servers:
  - url: https://api.specular.dev
    description: Production server
  - url: http://localhost:3000
    description: Development server
security:
  - bearerAuth: []
paths:
  /branches/:
    post:
      tags:
        - Branches
      summary: Create branch
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - projectId
              properties:
                name:
                  type: string
                  description: Branch name
                projectId:
                  type: string
                  description: Project ID
                git:
                  type: object
                  description: Git configuration (required if project has custom git)
                  required:
                    - branch
                  properties:
                    branch:
                      type: string
                      description: Git branch name (must exist in repository)
        required: true
      responses:
        '201':
          description: Branch created successfully
          content:
            application/json:
              schema:
                description: Branch created successfully
                type: object
                properties:
                  branch:
                    type: object
                    properties:
                      id:
                        type: string
                      projectId:
                        type: string
                      name:
                        type: string
                      state:
                        type: string
                        enum:
                          - idle
                          - building
                          - merging
                          - merged
                          - deleted
                          - archived
                        description: >-
                          Branch state: idle (ready to use), building (actively
                          building), merging (being merged), merged (merge
                          complete), deleted (soft deleted), archived (due to
                          inactivity)
                      gitBranchName:
                        type: string
                        nullable: true
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                      mcpUrl:
                        type: string
                      appUrl:
                        type: string
        '400':
          description: Bad request (e.g., project is deleted)
          content:
            application/json:
              schema:
                description: Bad request (e.g., project is deleted)
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                description: Authentication required
                type: object
                properties:
                  error:
                    type: string
        '404':
          description: Project not found
          content:
            application/json:
              schema:
                description: Project not found
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Bearer authentication with API key (format: Bearer sk_xxx)'

````