> ## Documentation Index
> Fetch the complete documentation index at: https://cognitio-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Send async message

> Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.



## OpenAPI

````yaml /openapi.json post /session/{sessionID}/prompt_async
openapi: 3.1.1
info:
  title: cognitio
  description: cognitio api
  version: 1.0.0
servers: []
security: []
paths:
  /session/{sessionID}/prompt_async:
    post:
      summary: Send async message
      description: >-
        Create and send a new message to a session asynchronously, starting the
        session if needed and returning immediately.
      operationId: session.prompt_async
      parameters:
        - in: query
          name: directory
          schema:
            type: string
        - in: query
          name: workspace
          schema:
            type: string
        - in: path
          name: sessionID
          schema:
            type: string
            pattern: ^ses.*
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                messageID:
                  type: string
                  pattern: ^msg.*
                model:
                  type: object
                  properties:
                    providerID:
                      type: string
                    modelID:
                      type: string
                  required:
                    - providerID
                    - modelID
                agent:
                  type: string
                noReply:
                  type: boolean
                tools:
                  description: >-
                    @deprecated tools and permissions have been merged, you can
                    set permissions on the session itself now
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: boolean
                format:
                  $ref: '#/components/schemas/OutputFormat'
                system:
                  type: string
                variant:
                  type: string
                parts:
                  type: array
                  items:
                    anyOf:
                      - $ref: '#/components/schemas/TextPartInput'
                      - $ref: '#/components/schemas/FilePartInput'
                      - $ref: '#/components/schemas/AgentPartInput'
                      - $ref: '#/components/schemas/SubtaskPartInput'
              required:
                - parts
      responses:
        '204':
          description: Prompt accepted
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      x-codeSamples:
        - lang: js
          source: |-
            import { createCognitioClient } from "@cognitio/sdk

            const client = createCognitioClient()
            await client.session.prompt_async({
              ...
            })
components:
  schemas:
    OutputFormat:
      anyOf:
        - $ref: '#/components/schemas/OutputFormatText'
        - $ref: '#/components/schemas/OutputFormatJsonSchema'
    TextPartInput:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        type:
          type: string
          const: text
        text:
          type: string
        synthetic:
          type: boolean
        ignored:
          type: boolean
        time:
          type: object
          properties:
            start:
              type: number
            end:
              type: number
          required:
            - start
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - type
        - text
    FilePartInput:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        type:
          type: string
          const: file
        mime:
          type: string
        filename:
          type: string
        url:
          type: string
        source:
          $ref: '#/components/schemas/FilePartSource'
      required:
        - type
        - mime
        - url
    AgentPartInput:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        type:
          type: string
          const: agent
        name:
          type: string
        source:
          type: object
          properties:
            value:
              type: string
            start:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            end:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
          required:
            - value
            - start
            - end
      required:
        - type
        - name
    SubtaskPartInput:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        type:
          type: string
          const: subtask
        prompt:
          type: string
        description:
          type: string
        agent:
          type: string
        model:
          type: object
          properties:
            providerID:
              type: string
            modelID:
              type: string
          required:
            - providerID
            - modelID
        spawnMode:
          type: string
          enum:
            - fresh
            - inherit
        command:
          type: string
      required:
        - type
        - prompt
        - description
        - agent
    BadRequestError:
      type: object
      properties:
        data: {}
        errors:
          type: array
          items:
            type: object
            propertyNames:
              type: string
            additionalProperties: {}
        success:
          type: boolean
          const: false
      required:
        - data
        - errors
        - success
    NotFoundError:
      type: object
      properties:
        name:
          type: string
          const: NotFoundError
        data:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - name
        - data
    OutputFormatText:
      type: object
      properties:
        type:
          type: string
          const: text
      required:
        - type
    OutputFormatJsonSchema:
      type: object
      properties:
        type:
          type: string
          const: json_schema
        schema:
          $ref: '#/components/schemas/JSONSchema'
        retryCount:
          default: 2
          type: integer
          minimum: 0
          maximum: 9007199254740991
      required:
        - type
        - schema
    FilePartSource:
      anyOf:
        - $ref: '#/components/schemas/FileSource'
        - $ref: '#/components/schemas/SymbolSource'
        - $ref: '#/components/schemas/ResourceSource'
    JSONSchema:
      type: object
      propertyNames:
        type: string
      additionalProperties: {}
    FileSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: file
        path:
          type: string
      required:
        - text
        - type
        - path
    SymbolSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: symbol
        path:
          type: string
        range:
          $ref: '#/components/schemas/Range'
        name:
          type: string
        kind:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - text
        - type
        - path
        - range
        - name
        - kind
    ResourceSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: resource
        clientName:
          type: string
        uri:
          type: string
      required:
        - text
        - type
        - clientName
        - uri
    FilePartSourceText:
      type: object
      properties:
        value:
          type: string
        start:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        end:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - value
        - start
        - end
    Range:
      type: object
      properties:
        start:
          type: object
          properties:
            line:
              type: number
            character:
              type: number
          required:
            - line
            - character
        end:
          type: object
          properties:
            line:
              type: number
            character:
              type: number
          required:
            - line
            - character
      required:
        - start
        - end

````

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