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

# Deploy Agent

> Deploy an agent to the platform.

    Called by CLI after pushing the container image to the registry.
    Creates or updates agent, branch, and version records.

    The deployment is asynchronous - poll GET /branches/{branch_id}
    for status updates until status is READY or FAILED.

    **Flow:**
    1. CLI builds and pushes image to registry (using /registry/auth)
    2. CLI calls POST /agents/deploy with image details
    3. Platform creates records and triggers K8s deployment
    4. Container starts and calls POST /versions/register
    5. CLI polls GET /branches/{id} for status

<Note>
  The deployment is asynchronous. After calling this endpoint, poll `GET /branches/{branch_id}`
  for status updates until status is `READY` or `FAILED`.
</Note>


## OpenAPI

````yaml openapi.json POST /agents/deploy
openapi: 3.1.0
info:
  title: Sb0 API
  version: 0.1.0
servers: []
security: []
paths:
  /agents/deploy:
    post:
      tags:
        - Branches
        - Agents
      summary: Deploy Agent
      description: |-
        Deploy an agent to the platform.

            Called by CLI after pushing the container image to the registry.
            Creates or updates agent, branch, and version records.

            The deployment is asynchronous - poll GET /branches/{branch_id}
            for status updates until status is READY or FAILED.

            **Flow:**
            1. CLI builds and pushes image to registry (using /registry/auth)
            2. CLI calls POST /agents/deploy with image details
            3. Platform creates records and triggers K8s deployment
            4. Container starts and calls POST /versions/register
            5. CLI polls GET /branches/{id} for status
      operationId: deploy
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeployRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeployResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    DeployRequest:
      description: |-
        Request model for deploying an agent.

        Called by CLI after pushing the container image to the registry.
      properties:
        acp_type:
          $ref: '#/components/schemas/ACPType'
          default: async
          description: ACP server type (sync or async)
        agent_name:
          description: >-
            Agent name in 'namespace_slug/agent_name' format (lowercase
            alphanumeric, hyphens, underscores)
          pattern: ^[a-z0-9][a-z0-9_-]*/[a-z0-9][a-z0-9_-]*$
          title: Agent Name
          type: string
        are_tasks_sticky:
          anyOf:
            - type: boolean
            - type: 'null'
          description: >-
            If true, running tasks stay on their original version until
            completion during this deploy. If false or None, tasks are migrated
            to the new version immediately.
          title: Are Tasks Sticky
        author_email:
          description: Git commit author email
          title: Author Email
          type: string
        author_name:
          description: Git commit author name
          title: Author Name
          type: string
        branch:
          description: Git branch name (e.g., 'main', 'feature/new-tool')
          title: Branch
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
          description: Agent description (used when creating new agent)
          title: Description
        git_hash:
          description: Git commit hash (short or full)
          maxLength: 40
          minLength: 7
          title: Git Hash
          type: string
        git_message:
          anyOf:
            - maxLength: 500
              type: string
            - type: 'null'
          description: Git commit message (truncated if too long)
          title: Git Message
        image_url:
          description: >-
            Full container image URL (e.g.,
            'us-east4-docker.pkg.dev/proj/repo/agent:hash')
          title: Image Url
          type: string
        is_dirty:
          default: false
          description: Whether the working directory had uncommitted changes at deploy time
          title: Is Dirty
          type: boolean
        replicas:
          default: 1
          description: Desired replica count (1-10)
          maximum: 10
          minimum: 1
          title: Replicas
          type: integer
        resources:
          additionalProperties: true
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            Resource requests and limits (e.g., {'requests': {'cpu': '100m',
            'memory': '256Mi'}, 'limits': {'cpu': '1000m', 'memory': '1Gi'}})
          title: Resources
        sdk_type:
          $ref: '#/components/schemas/SDKType'
          default: claude_agent_sdk
          description: SDK type for agent runtime
        source_filesystem_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Filesystem snapshot containing the deploy source for Builder
            reopenability
          title: Source Filesystem Id
      required:
        - agent_name
        - branch
        - git_hash
        - image_url
        - author_name
        - author_email
      title: DeployRequest
      type: object
    DeployResponse:
      description: >-
        Immediate response from deploy request.


        CLI polls GET /branches/{branch_id} or GET /versions/{version_id} for
        status updates.
      properties:
        agent_id:
          description: Agent ID (created or existing)
          title: Agent Id
          type: string
        branch_id:
          description: Branch ID for this git branch
          title: Branch Id
          type: string
        message:
          description: Human-readable status message
          title: Message
          type: string
        tasks_migrated:
          anyOf:
            - type: integer
            - type: 'null'
          description: Number of tasks migrated from old version (if any)
          title: Tasks Migrated
        version_id:
          description: New version ID
          title: Version Id
          type: string
        version_status:
          $ref: '#/components/schemas/VersionStatus'
          description: Initial version status
      required:
        - agent_id
        - branch_id
        - version_id
        - version_status
        - message
      title: DeployResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ACPType:
      description: Type of ACP server.
      enum:
        - sync
        - async
      title: ACPType
      type: string
    SDKType:
      description: SDK type for agent runtime.
      enum:
        - claude_agent_sdk
        - codex_agent_sdk
      title: SDKType
      type: string
    VersionStatus:
      description: Status of a version in its lifecycle.
      enum:
        - DEPLOYING
        - ACTIVE
        - FAILED
        - UNHEALTHY
        - DRAINING
        - RETIRED
        - ROLLED_BACK
      title: VersionStatus
      type: string
    ValidationError:
      properties:
        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

````