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

# Patch Task

> Update an empty task. Currently supports moving the task into a
different project, which:

  * verifies the task has zero user messages (otherwise the move is
    rejected — a task with a conversation is bound to its project),
  * verifies the caller can access the destination project,
  * flips ``task.project_id`` + clears project-bound state
    (selected_branches, github_branch, active_odoo_credential_ids,
    machine_url/agent_secret) so the next pod claim starts clean,
  * tears down the existing pod (if any) so the operator's pool
    reclaims its slot — the task page's existing ensure-pod call
    on the next render will reprovision against the new project's
    image + repos.



## OpenAPI

````yaml /openapi.json patch /api/tasks/{task_id}
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/tasks/{task_id}:
    patch:
      tags:
        - public
      summary: Patch Task
      description: |-
        Update an empty task. Currently supports moving the task into a
        different project, which:

          * verifies the task has zero user messages (otherwise the move is
            rejected — a task with a conversation is bound to its project),
          * verifies the caller can access the destination project,
          * flips ``task.project_id`` + clears project-bound state
            (selected_branches, github_branch, active_odoo_credential_ids,
            machine_url/agent_secret) so the next pod claim starts clean,
          * tears down the existing pod (if any) so the operator's pool
            reclaims its slot — the task page's existing ensure-pod call
            on the next render will reprovision against the new project's
            image + repos.
      operationId: patch_task_api_tasks__task_id__patch
      parameters:
        - in: path
          name: task_id
          required: true
          schema:
            format: uuid
            title: Task Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskUpdateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    TaskUpdateRequest:
      description: |-
        Fields a user can change on an existing task. Only project_id is
        supported today — it's the "I picked the wrong project for this
        task before sending anything" escape hatch wired up to the task
        header's ProjectSwitcher.
      properties:
        auto_fix_ci:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Auto Fix Ci
        project_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          title: Project Id
      title: TaskUpdateRequest
      type: object
    TaskResponse:
      properties:
        app_ready:
          default: true
          title: App Ready
          type: boolean
        auto_fix_ci:
          default: false
          title: Auto Fix Ci
          type: boolean
        context_pct:
          anyOf:
            - type: number
            - type: 'null'
          title: Context Pct
        context_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Context Tokens
        context_window:
          anyOf:
            - type: integer
            - type: 'null'
          title: Context Window
        cost_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Cost Usd
        created_at:
          format: date-time
          title: Created At
          type: string
        github_branch:
          anyOf:
            - type: string
            - type: 'null'
          title: Github Branch
        has_plan:
          default: false
          title: Has Plan
          type: boolean
        id:
          format: uuid
          title: Id
          type: string
        machine_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Machine Url
        mode:
          enum:
            - plan
            - build
          title: Mode
          type: string
        name:
          title: Name
          type: string
        plan_version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Plan Version
        project_id:
          format: uuid
          title: Project Id
          type: string
        provisioning_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Provisioning Error
        pull_requests:
          default: []
          items:
            $ref: '#/components/schemas/PullRequestResponse'
          title: Pull Requests
          type: array
        selected_branches:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Selected Branches
        updated_at:
          format: date-time
          title: Updated At
          type: string
        user_id:
          format: uuid
          title: User Id
          type: string
        workspace_state:
          default: pending
          enum:
            - ready
            - pending
            - error
          title: Workspace State
          type: string
      required:
        - id
        - name
        - project_id
        - user_id
        - mode
        - created_at
        - updated_at
      title: TaskResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    PullRequestResponse:
      properties:
        fix_ci_stuck:
          default: false
          title: Fix Ci Stuck
          type: boolean
        head_branch:
          anyOf:
            - type: string
            - type: 'null'
          title: Head Branch
        id:
          format: uuid
          title: Id
          type: string
        pr_number:
          title: Pr Number
          type: integer
        pr_state:
          title: Pr State
          type: string
        pr_url:
          title: Pr Url
          type: string
        repository_id:
          format: uuid
          title: Repository Id
          type: string
        repository_name:
          title: Repository Name
          type: string
      required:
        - id
        - repository_id
        - repository_name
        - pr_url
        - pr_number
        - pr_state
      title: PullRequestResponse
      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
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http

````