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

# Queue or wait for a manual task run



## OpenAPI

````yaml /docs/reference/openapi.json post /background/tasks/{task_id}/run
openapi: 3.1.0
info:
  description: >-
    The HTTP API of an agent served with `omniserve run --agent agent.py`: runs,
    approvals, budgets, background tasks, sessions and the evidence of every
    run.
  title: OmniServe
  version: latest
servers:
  - description: omniserve run, locally
    url: http://localhost:8000
security: []
paths:
  /background/tasks/{task_id}/run:
    post:
      tags:
        - Background
      summary: Queue or wait for a manual task run
      operationId: run_background_task_background_tasks__task_id__run_post
      parameters:
        - in: path
          name: task_id
          required: true
          schema:
            title: Task Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/BackgroundTaskRunRequest'
                - type: 'null'
              title: Body
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BackgroundRun'
          description: Successful Response
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
          description: Not Found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
          description: Service Unavailable
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BackgroundRunTimeoutResponse'
          description: Run did not finish before request timeout
components:
  schemas:
    BackgroundTaskRunRequest:
      description: Queue a manual run, optionally waiting for terminal state.
      properties:
        query:
          anyOf:
            - type: string
            - type: 'null'
          description: Optional one-off query override for this run
          title: Query
        wait:
          default: false
          description: Wait for the run to reach a terminal status before returning
          title: Wait
          type: boolean
      title: BackgroundTaskRunRequest
      type: object
    BackgroundRun:
      additionalProperties: false
      properties:
        agent_id:
          title: Agent Id
          type: string
        attempt:
          default: 0
          title: Attempt
          type: integer
        cancel_requested_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Cancel Requested At
        claimed_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Claimed At
        due_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Due At
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        finished_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Finished At
        heartbeat_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Heartbeat At
        lease_expires_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Lease Expires At
        lease_generation:
          default: 0
          title: Lease Generation
          type: integer
        lease_owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Lease Owner
        lease_token:
          anyOf:
            - type: string
            - type: 'null'
          title: Lease Token
        max_attempts:
          default: 1
          title: Max Attempts
          type: integer
        metadata:
          additionalProperties: true
          title: Metadata
          type: object
        occurrence_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Occurrence Id
        query_snapshot:
          title: Query Snapshot
          type: string
        queued_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Queued At
        result_preview:
          anyOf:
            - type: string
            - type: 'null'
          title: Result Preview
        run_id:
          title: Run Id
          type: string
        session_id:
          title: Session Id
          type: string
        started_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Started At
        status:
          $ref: '#/components/schemas/RunStatus'
          default: queued
        task_id:
          title: Task Id
          type: string
        trigger_metadata:
          additionalProperties: true
          title: Trigger Metadata
          type: object
        trigger_type:
          $ref: '#/components/schemas/TriggerType'
        triggered_at:
          format: date-time
          title: Triggered At
          type: string
        workspace_path:
          title: Workspace Path
          type: string
      required:
        - task_id
        - agent_id
        - query_snapshot
        - trigger_type
        - session_id
        - workspace_path
      title: BackgroundRun
      type: object
    HttpErrorResponse:
      description: Response shape produced by FastAPI HTTPException.
      properties:
        detail:
          description: Error detail
          title: Detail
      required:
        - detail
      title: HttpErrorResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    BackgroundRunTimeoutResponse:
      description: HTTPException response for background run wait timeout.
      properties:
        detail:
          $ref: '#/components/schemas/BackgroundRunTimeoutDetail'
      required:
        - detail
      title: BackgroundRunTimeoutResponse
      type: object
    RunStatus:
      enum:
        - queued
        - claimed
        - running
        - retrying
        - completed
        - failed
        - cancelled
        - timeout
        - skipped
        - awaiting_approval
        - awaiting_budget
      title: RunStatus
      type: string
    TriggerType:
      enum:
        - manual
        - interval
        - cron
        - once
      title: TriggerType
      type: string
    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
    BackgroundRunTimeoutDetail:
      description: Detail payload for a background run wait timeout.
      properties:
        message:
          description: Timeout message
          title: Message
          type: string
        request_timeout_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: Outer HTTP request timeout
          title: Request Timeout Seconds
        run_id:
          description: Run that can be inspected later
          title: Run Id
          type: string
        status:
          description: Latest run status
          title: Status
          type: string
        task_id:
          description: Task that created the run
          title: Task Id
          type: string
        wait_timeout_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: Background run wait budget applied to the request
          title: Wait Timeout Seconds
      required:
        - message
        - run_id
        - task_id
        - status
      title: BackgroundRunTimeoutDetail
      type: object

````