> ## 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 Create Pr

> Agent-driven PR opening proxy.

The git skill calls this from inside the pod. The backend:
  * authenticates via the per-pod proxy token (same as the
    Anthropic proxy);
  * resolves the token → pod → task → project;
  * verifies the requested repository belongs to that project and
    the head branch exists on origin (the branch-resolution
    sidecar should have already created it);
  * opens the PR via the GitHub App installation that owns the
    repo's owner so the PR appears authored by CodeCobra;
  * persists a TaskPullRequest row so /api/tasks/{id} surfaces
    the PR immediately.



## OpenAPI

````yaml /openapi.json post /api/agent/pr/create
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/pr/create:
    post:
      tags:
        - public
      summary: Agent Create Pr
      description: |-
        Agent-driven PR opening proxy.

        The git skill calls this from inside the pod. The backend:
          * authenticates via the per-pod proxy token (same as the
            Anthropic proxy);
          * resolves the token → pod → task → project;
          * verifies the requested repository belongs to that project and
            the head branch exists on origin (the branch-resolution
            sidecar should have already created it);
          * opens the PR via the GitHub App installation that owns the
            repo's owner so the PR appears authored by CodeCobra;
          * persists a TaskPullRequest row so /api/tasks/{id} surfaces
            the PR immediately.
      operationId: agent_create_pr_api_agent_pr_create_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentPRCreateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentPRCreateResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    AgentPRCreateRequest:
      description: Body sent by the agent's git skill to open a PR for the current task.
      properties:
        body:
          default: ''
          title: Body
          type: string
        head_branch:
          title: Head Branch
          type: string
        repository:
          title: Repository
          type: string
        title:
          title: Title
          type: string
      required:
        - repository
        - head_branch
        - title
      title: AgentPRCreateRequest
      type: object
    AgentPRCreateResponse:
      properties:
        pr_number:
          title: Pr Number
          type: integer
        pr_state:
          default: open
          title: Pr State
          type: string
        pr_url:
          title: Pr Url
          type: string
      required:
        - pr_url
        - pr_number
      title: AgentPRCreateResponse
      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

````