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

# Generate Plan Async

> Generate a task plan asynchronously using Temporal workflow.

This endpoint:
1. Creates an execution record in the database
2. Submits a Temporal workflow for plan generation
3. Returns execution_id for tracking progress
4. Client can stream results via /api/v1/executions/{execution_id}/stream

Flow:
1. POST /api/v1/plans/generate → get execution_id
2. GET /api/v1/executions/{execution_id}/stream → stream progress and final plan
3. Use plan from execution.plan_json with existing /api/v1/tasks/plan/execute

Benefits:
- Non-blocking: API responds immediately
- Progress tracking: Stream real-time updates
- Persistence: Plan stored in DB for later execution
- Resilient: Temporal handles retries and failures



## OpenAPI

````yaml https://control-plane.kubiya.ai/api/openapi.json post /api/v1/plans/generate
openapi: 3.1.0
info:
  title: Agent Control Plane API
  description: Multi-tenant agent orchestration with Temporal workflows
  version: 1.0.0
servers: []
security:
  - BearerAuth: []
tags:
  - name: health
    description: 🏥 **Health & Status** - Check API health and availability
  - name: authentication
    description: 🔐 **Authentication** - Token validation and auth management
  - name: agents
    description: 🤖 **Agents** - Create and manage AI agents with custom capabilities
  - name: skills
    description: 🛠️ **Tool Sets** - Manage agent skills and tool configurations
  - name: integrations
    description: 🔌 **Integrations** - Connect to external services (Kubiya managed)
  - name: custom-integrations
    description: >-
      ⚙️ **Custom Integrations** - User-defined integration instances with env
      vars, secrets, and files
  - name: integration-templates
    description: >-
      📦 **Integration Templates** - Pre-configured templates for common
      services (PostgreSQL, Redis, MongoDB, etc.)
  - name: secrets
    description: 🔑 **Secrets** - Secure credential storage and retrieval
  - name: teams
    description: 👥 **Teams** - Team management and collaboration
  - name: workflows
    description: 📊 **Workflows** - Multi-step automation and orchestration
  - name: executions
    description: ▶️ **Executions** - Track and monitor workflow runs
  - name: jobs
    description: ⏰ **Jobs** - Scheduled and webhook-triggered tasks
  - name: policies
    description: 🛡️ **Policies** - Access control and security policies
  - name: analytics
    description: 📈 **Analytics** - Usage metrics and performance monitoring
  - name: projects
    description: 📁 **Projects** - Project organization and management
  - name: environments
    description: 🌍 **Environments** - Environment configuration (dev, staging, prod)
  - name: models
    description: 🧠 **Models** - LLM model configuration and management
  - name: runtimes
    description: ⚡ **Runtimes** - Agent execution runtime environments
  - name: workers
    description: 👷 **Workers** - Worker registration and heartbeat monitoring
  - name: storage
    description: 💾 **Storage** - File storage and cloud integration
  - name: context-graph
    description: 🕸️ **Context Graph** - Knowledge graph and context management
  - name: temporal-workflows
    description: >-
      ⚙️ **Temporal Workflows** - Background workflows for context graph
      ingestion, connector operations, and scheduled jobs
  - name: templates
    description: 📝 **Templates** - Reusable configuration templates
paths:
  /api/v1/plans/generate:
    post:
      tags:
        - Async Plan Generation
      summary: Generate Plan Async
      description: >-
        Generate a task plan asynchronously using Temporal workflow.


        This endpoint:

        1. Creates an execution record in the database

        2. Submits a Temporal workflow for plan generation

        3. Returns execution_id for tracking progress

        4. Client can stream results via
        /api/v1/executions/{execution_id}/stream


        Flow:

        1. POST /api/v1/plans/generate → get execution_id

        2. GET /api/v1/executions/{execution_id}/stream → stream progress and
        final plan

        3. Use plan from execution.plan_json with existing
        /api/v1/tasks/plan/execute


        Benefits:

        - Non-blocking: API responds immediately

        - Progress tracking: Stream real-time updates

        - Persistence: Plan stored in DB for later execution

        - Resilient: Temporal handles retries and failures
      operationId: generate_plan_async_api_v1_plans_generate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskPlanRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanGenerationResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    TaskPlanRequest:
      properties:
        description:
          type: string
          title: Description
          description: Task description
        priority:
          type: string
          enum:
            - low
            - medium
            - high
            - critical
          title: Priority
          description: Task priority
          default: medium
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Id
          description: Associated project ID
        agents:
          items:
            $ref: '#/components/schemas/AgentInfo'
          type: array
          title: Agents
          description: Available agents (outer context from CLI)
        teams:
          items:
            $ref: '#/components/schemas/TeamInfo'
          type: array
          title: Teams
          description: Available teams (outer context from CLI)
        environments:
          items:
            $ref: '#/components/schemas/EnvironmentInfo'
          type: array
          title: Environments
          description: Available execution environments
        worker_queues:
          items:
            $ref: '#/components/schemas/WorkerQueueInfo'
          type: array
          title: Worker Queues
          description: Available worker queues
        refinement_feedback:
          anyOf:
            - type: string
            - type: 'null'
          title: Refinement Feedback
          description: User feedback for plan refinement
        conversation_context:
          anyOf:
            - type: string
            - type: 'null'
          title: Conversation Context
          description: Conversation history for context
        previous_plan:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Previous Plan
          description: Previous plan for refinement
        iteration:
          type: integer
          title: Iteration
          description: Planning iteration number
          default: 1
        planning_strategy:
          anyOf:
            - type: string
              enum:
                - claude_code_sdk
                - agno
            - type: 'null'
          title: Planning Strategy
          description: Planning strategy to use (claude_code_sdk or agno)
          default: claude_code_sdk
        quick_mode:
          type: boolean
          title: Quick Mode
          description: Use fast planning for --local mode (Haiku vs Sonnet)
          default: false
      type: object
      required:
        - description
      title: TaskPlanRequest
      description: Request to plan a task
    PlanGenerationResponse:
      properties:
        execution_id:
          type: string
          title: Execution Id
          description: Unique execution identifier
        workflow_id:
          type: string
          title: Workflow Id
          description: Temporal workflow identifier
        status:
          type: string
          title: Status
          description: Current execution status
        message:
          type: string
          title: Message
          description: Human-readable status message
      type: object
      required:
        - execution_id
        - workflow_id
        - status
        - message
      title: PlanGenerationResponse
      description: Response model for async plan generation
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentInfo:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        model_id:
          type: string
          title: Model Id
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        capabilities:
          items:
            type: string
          type: array
          title: Capabilities
          description: Agent capabilities
        status:
          type: string
          title: Status
          description: Agent status
          default: active
      type: object
      required:
        - id
        - name
        - model_id
      title: AgentInfo
      description: Lightweight agent info from CLI
    TeamInfo:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        agent_count:
          type: integer
          title: Agent Count
          description: Number of agents in team
          default: 0
        status:
          type: string
          title: Status
          description: Team status
          default: active
      type: object
      required:
        - id
        - name
      title: TeamInfo
      description: Lightweight team info from CLI
    EnvironmentInfo:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Display Name
          description: Display name for environment
        status:
          type: string
          title: Status
          description: Environment status
          default: active
      type: object
      required:
        - id
        - name
      title: EnvironmentInfo
      description: Environment info from CLI
    WorkerQueueInfo:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        environment_id:
          type: string
          title: Environment Id
          description: Associated environment ID
        status:
          type: string
          title: Status
          description: Worker queue status
          default: active
        active_workers:
          type: integer
          title: Active Workers
          description: Number of active workers (key for queue selection!)
          default: 0
      type: object
      required:
        - id
        - name
        - environment_id
      title: WorkerQueueInfo
      description: Worker queue info from CLI
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your Kubiya API token (format: Bearer <token>)'

````