> ## 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.

# Edit branch



## OpenAPI

````yaml https://api.specular.dev/openapi.json patch /branches/{id}
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/{id}:
    patch:
      tags:
        - Branches
      summary: Edit branch
      parameters:
        - schema:
            type: string
          in: path
          name: id
          required: true
          description: Branch ID
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: New branch name
                git:
                  type: object
                  properties:
                    branch:
                      type: string
                      description: >-
                        Git branch name to switch to (must exist on remote, only
                        for custom git projects)
                  required:
                    - branch
      responses:
        '200':
          description: Branch updated successfully
          content:
            application/json:
              schema:
                description: Branch updated 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
                        nullable: true
                      appUrl:
                        type: string
                        nullable: true
                      openApiSpec:
                        type: string
                        nullable: true
                        description: OpenAPI spec in YAML format
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Bad request
                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: Branch not found
          content:
            application/json:
              schema:
                description: Branch not found
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                description: Internal server error
                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)'

````