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

# Invoke an agent (async)

> Queue an agent invocation as a background job. Returns `202 Accepted` immediately with a `job_id`. The agent runs in the background — no connection held open, no timeout risk. Poll `GET /v1/agent/jobs/{job_id}` for the result, or provide a `callback_url` to receive a webhook when the job completes.



## OpenAPI

````yaml POST /v1/agent/invoke/async
openapi: 3.1.0
info:
  title: Kairn API
  version: 1.0.0
  description: >-
    The Kairn API. All requests require an `X-API-Key` header with your tenant
    API key.
servers:
  - url: https://api.kairn.sh
    description: Production
security:
  - ApiKey: []
tags:
  - name: Agent
    description: Invoke agents and stream responses.
  - name: Memory
    description: Read and write per-user agent memory.
  - name: Souls
    description: Manage agent identities.
  - name: Skills
    description: Manage custom skills (instructions and webhook tools).
  - name: Mandates
    description: Schedule autonomous agent tasks.
  - name: Invocations
    description: Inspect past agent runs.
  - name: Sessions
    description: Access multi-turn conversation history.
  - name: Audit
    description: Audit log for all agent activity.
paths:
  /v1/agent/invoke/async:
    post:
      tags:
        - Agent
      summary: Invoke an agent (async)
      description: >-
        Queue an agent invocation as a background job. Returns `202 Accepted`
        immediately with a `job_id`. The agent runs in the background — no
        connection held open, no timeout risk. Poll `GET
        /v1/agent/jobs/{job_id}` for the result, or provide a `callback_url` to
        receive a webhook when the job completes.
      operationId: invoke-async
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AsyncInvokeRequest'
      responses:
        '202':
          description: Job queued successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncInvokeResponse'
        '400':
          description: Invalid request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit or monthly quota exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AsyncInvokeRequest:
      type: object
      required:
        - user_id
        - soul
        - input
      properties:
        user_id:
          type: string
          description: Your user's ID.
          example: user_123
        soul:
          type: string
          description: The soul name to invoke.
          example: advisor
        role:
          type: string
          default: default
          description: Memory and session scope. Defaults to `default`.
        input:
          type: string
          description: The task or message for the agent.
          example: Research our top 5 competitors and summarise findings.
        session_id:
          type: string
          description: Session ID for conversation continuity.
        callback_url:
          type: string
          format: uri
          description: >-
            Optional URL to POST the result to when the job completes. Receives
            the same shape as the poll response.
    AsyncInvokeResponse:
      type: object
      properties:
        job_id:
          type: string
          description: Unique job ID. Use to poll status.
          example: 2e4edc0c-8597-4e04-bf0a-c16349c6d35e
        status:
          type: string
          enum:
            - pending
          description: Always `pending` on creation.
        poll_url:
          type: string
          description: Convenience URL for polling this job.
          example: /v1/agent/jobs/2e4edc0c-8597-4e04-bf0a-c16349c6d35e
    Error:
      type: object
      properties:
        error:
          type: string
        error_type:
          type: string
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key

````

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