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

# Task Create

> Create a scheduled command for the current organization and user.



## OpenAPI

````yaml post /api/task
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/task:
    post:
      tags:
        - Task
      summary: Task Create
      description: Create a scheduled command for the current organization and user.
      operationId: task_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskCreate'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    TaskCreate:
      properties:
        name:
          type: string
          title: Name
          description: Command display name.
        prompt:
          type: string
          title: Prompt
          description: Prompt / command text to run via Copilot chat.
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Optional Copilot agent id to @-mention for the run.
        chat_model:
          anyOf:
            - $ref: '#/components/schemas/ChatModelRef'
            - type: 'null'
          description: Optional chat model override {provider, model}.
        mentions:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Mentions
          description: Optional mention snapshot (agent/mcp) for the headless run.
        visibility:
          $ref: '#/components/schemas/Visibility'
          description: 'Command visibility: ''private'' or ''public'''
          default: private
        schedule:
          $ref: '#/components/schemas/Schedule'
          description: Schedule information for the command
        state:
          $ref: '#/components/schemas/TaskState'
          description: 'Command state: ''enabled'' or ''disabled'''
          default: enabled
        thread_policy:
          $ref: '#/components/schemas/ThreadPolicy'
          description: Whether each run creates a new chat thread or appends to thread_id
          default: new_each_run
        thread_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Thread Id
          description: Thread to append to when thread_policy is 'append'
      type: object
      required:
        - name
        - prompt
      title: TaskCreate
      description: Scheduled command create/update payload (reuses /api/task paths).
    Task:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Unique identifier for the command
        name:
          type: string
          title: Name
          description: Command display name.
        prompt:
          type: string
          title: Prompt
          description: Prompt / command text.
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Optional Copilot agent id.
        chat_model:
          anyOf:
            - $ref: '#/components/schemas/ChatModelRef'
            - type: 'null'
          description: Optional model override.
        mentions:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Mentions
        created_by:
          type: string
          title: Created By
          description: User who created the command (email)
        visibility:
          $ref: '#/components/schemas/Visibility'
          default: private
        schedule:
          $ref: '#/components/schemas/Schedule'
        state:
          $ref: '#/components/schemas/TaskState'
          default: enabled
        thread_policy:
          $ref: '#/components/schemas/ThreadPolicy'
          default: new_each_run
        thread_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Thread Id
        next_run:
          type: string
          format: date-time
          title: Next Run
          description: Next scheduled execution time (UTC)
          default: '1970-01-01T00:00:00'
        last_run_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Run At
        last_run_status:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Run Status
        last_run_thread_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Run Thread Id
      type: object
      required:
        - name
        - prompt
        - created_by
      title: Task
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatModelRef:
      properties:
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
      type: object
      title: ChatModelRef
    Visibility:
      type: string
      enum:
        - private
        - public
      title: Visibility
    Schedule:
      properties:
        frequency:
          $ref: '#/components/schemas/ScheduleFrequency'
          description: 'Schedule frequency: ''manual'', ''daily'', or ''weekly'''
        hour:
          type: string
          title: Hour
          description: Hour of the day in HH:MM to run the command
          default: '09:00'
        day:
          type: string
          title: Day
          description: Day of the week for weekly schedules
          default: Monday
        timezone:
          type: string
          title: Timezone
          description: IANA timezone for schedule evaluation
          default: UTC
      type: object
      required:
        - frequency
      title: Schedule
    TaskState:
      type: string
      enum:
        - disabled
        - enabled
      title: TaskState
    ThreadPolicy:
      type: string
      enum:
        - new_each_run
        - append
      title: ThreadPolicy
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ScheduleFrequency:
      type: string
      enum:
        - manual
        - daily
        - weekly
      title: ScheduleFrequency
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.