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

# Enqueue an async document agent job

> Create a long-running document agent job. Returns immediately with a `job_id` — use GET /document/agent/jobs/{job_id} to poll for the result or GET /document/agent/jobs/{job_id}/stream for live SSE updates.

Recommended for production workloads, batch evaluation pipelines, or anything that may run longer than ~10 minutes. The job runs on a background worker pool with 30-minute hard timeout, per-user concurrency caps, and automatic refunds on failure.



## OpenAPI

````yaml /openapi-docs.yaml post /document/agent/jobs
openapi: 3.1.0
info:
  title: Nia AI API
  version: 1.1.0
  description: >-
    Nia AI API provides a single, consistent `sources` resource for all indexed
    content.


    ## Core Resources


    **Sources** (`/sources`)

    - `repository`

    - `documentation`

    - `research_paper`

    - `huggingface_dataset`

    - `local_folder`


    **Search** (`/search`)

    - `mode`: query | web | deep | universal


    Legacy endpoints are deprecated and will be removed in a future version.
    Prefer `/sources` and `/search` for new integrations.
servers:
  - url: https://apigcp.trynia.ai/v2
    description: Production API
  - url: http://localhost:8000/v2
    description: Local development
security:
  - ApiKeyAuth: []
tags:
  - name: Auth
    description: API-first signup, login, and API key bootstrapping
  - name: Sources
    description: >-
      Unified source management (repositories, documentation, papers, datasets,
      local folders)
  - name: Search
    description: Unified search endpoint with mode discriminator
  - name: Context Sharing
    description: Cross-agent context management and retrieval
  - name: Categories
    description: Category management for organizing indexed sources
  - name: GitHub Search
    description: Live GitHub search and repository exploration
  - name: Advisor
    description: Context-aware code advisor against indexed documentation
  - name: Dependencies
    description: Dependency analysis and documentation subscription
  - name: Usage
    description: Usage tracking and bulk operations
paths:
  /document/agent/jobs:
    post:
      tags:
        - Usage
      summary: Enqueue an async document agent job
      description: >-
        Create a long-running document agent job. Returns immediately with a
        `job_id` — use GET /document/agent/jobs/{job_id} to poll for the result
        or GET /document/agent/jobs/{job_id}/stream for live SSE updates.


        Recommended for production workloads, batch evaluation pipelines, or
        anything that may run longer than ~10 minutes. The job runs on a
        background worker pool with 30-minute hard timeout, per-user concurrency
        caps, and automatic refunds on failure.
      operationId: create_document_agent_job_v2_document_agent_jobs_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentQueryRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentAgentJobResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DocumentQueryRequest:
      properties:
        source_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Id
          description: Data source ID of a single indexed document
        source_ids:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 50
            - type: 'null'
          title: Source Ids
          description: List of data source IDs for multi-document queries (max 50)
        query:
          type: string
          maxLength: 10000
          minLength: 1
          title: Query
          description: Question to ask about the document(s)
        json_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Json Schema
          description: JSON Schema for structured output
        model:
          type: string
          title: Model
          description: Model to use (claude-opus-4-7, claude-sonnet-4-5-20250929, etc.)
          default: claude-opus-4-7
        thinking_enabled:
          type: boolean
          title: Thinking Enabled
          description: Enable extended thinking
          default: true
        thinking_budget:
          type: integer
          maximum: 50000
          minimum: 1000
          title: Thinking Budget
          description: >-
            Token budget for thinking (ignored for adaptive models like Opus
            4.7)
          default: 10000
        stream:
          type: boolean
          title: Stream
          description: Stream response as SSE events
          default: false
      type: object
      required:
        - query
      title: DocumentQueryRequest
      description: Request for the v2 document/agent endpoint.
    DocumentAgentJobResponse:
      properties:
        job_id:
          type: string
          title: Job Id
          description: Workflow run id — pass to GET/stream/cancel endpoints
        status:
          type: string
          title: Status
          description: Initial status — usually 'queued'
        created_at:
          type: string
          title: Created At
        message:
          type: string
          title: Message
      type: object
      required:
        - job_id
        - status
        - created_at
        - message
      title: DocumentAgentJobResponse
      description: Returned by POST /document/agent/jobs.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key must be provided in the Authorization header

````