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

# Agent Move Task Branch

> Move the task's working branch for one repository, carrying any
uncommitted work — the chat-side equivalent of the composer's branch
selector, for when the user explicitly asks the agent.

Persists the new selection (so the UI selector follows), then re-runs
the workspace ensure whose /git/setup call requests the safe carry.
On a carry conflict the previous selection is restored and the caller
gets the conflict facts to relay — never a half-applied state.



## OpenAPI

````yaml /openapi.json post /api/agent/task/branch
openapi: 3.1.0
info:
  description: >-
    Public CodeCobra API. Authenticate by sending a personal API key in the
    `Authorization: Bearer <key>` header. Generate keys from Settings → API keys
    in the CodeCobra dashboard.
  title: CodeCobra Public API
  version: 1.0.0
servers: []
security: []
paths:
  /api/agent/task/branch:
    post:
      tags:
        - public
      summary: Agent Move Task Branch
      description: |-
        Move the task's working branch for one repository, carrying any
        uncommitted work — the chat-side equivalent of the composer's branch
        selector, for when the user explicitly asks the agent.

        Persists the new selection (so the UI selector follows), then re-runs
        the workspace ensure whose /git/setup call requests the safe carry.
        On a carry conflict the previous selection is restored and the caller
        gets the conflict facts to relay — never a half-applied state.
      operationId: agent_move_task_branch_api_agent_task_branch_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentBranchMoveRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    AgentBranchMoveRequest:
      properties:
        branch:
          anyOf:
            - type: string
            - type: 'null'
          title: Branch
        repository:
          title: Repository
          type: string
      required:
        - repository
      title: AgentBranchMoveRequest
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object

````