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

# Add a message to a session

> Adds a user message and optionally waits for agent completion. Supports text, images, and file attachments. This feature is enabled for selected organizations only.



## OpenAPI

````yaml https://api.factory.ai/api/v0/openapi.json post /api/v0/sessions/{sessionId}/messages
openapi: 3.0.1
info:
  title: Factory Public API
  description: >-
    Public API for Factory platform. Requires authentication via the
    `Authorization: Bearer` header.
  version: 0.1.0
servers:
  - url: https://api.factory.ai/
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v0/sessions/{sessionId}/messages:
    post:
      tags:
        - Sessions
      summary: Add a message to a session
      description: >-
        Adds a user message and optionally waits for agent completion. Supports
        text, images, and file attachments. This feature is enabled for selected
        organizations only.
      operationId: postMessage
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostMessageRequestBody'
      responses:
        '200':
          description: Response for status 200
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage200ResponseBody'
        '400':
          description: Response for status 400
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage400ResponseBody'
        '401':
          description: Response for status 401
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage401ResponseBody'
        '403':
          description: Response for status 403
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage403ResponseBody'
        '404':
          description: Response for status 404
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage404ResponseBody'
        '500':
          description: Response for status 500
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage500ResponseBody'
        '503':
          description: Response for status 503
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMessage503ResponseBody'
components:
  schemas:
    PostMessageRequestBody:
      type: object
      properties:
        text:
          type: string
          description: Message text content
        images:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - base64
              data:
                type: string
              mediaType:
                type: string
                enum:
                  - image/jpeg
                  - image/png
                  - image/gif
                  - image/webp
            required:
              - type
              - data
              - mediaType
            additionalProperties: false
          description: Optional base64-encoded images
        files:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - base64
                  mediaType:
                    type: string
                    enum:
                      - application/pdf
                  data:
                    type: string
                  parsedData:
                    type: string
                  name:
                    type: string
                  path:
                    type: string
                required:
                  - type
                  - mediaType
                  - data
                additionalProperties: false
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  mediaType:
                    type: string
                    enum:
                      - text/plain
                  data:
                    type: string
                  name:
                    type: string
                  mime:
                    type: string
                required:
                  - type
                  - mediaType
                  - data
                additionalProperties: false
          description: Optional file attachments (PDFs, text files)
        computerId:
          type: string
          description: >-
            Computer ID to route the message to; falls back to the
            session.computerId if omitted
      required:
        - text
      additionalProperties: false
    PostMessage200ResponseBody:
      type: object
      properties:
        messageId:
          type: string
          description: ID of the created user message
        status:
          type: string
          enum:
            - idle
            - pending
            - running
          description: Agent status after message submission
      required:
        - messageId
        - status
      additionalProperties: false
    PostMessage400ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    PostMessage401ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    PostMessage403ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    PostMessage404ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    PostMessage500ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
    PostMessage503ResponseBody:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
        status:
          type: number
          description: HTTP status code
        title:
          type: string
          description: HTTP status title
        metadata:
          type: object
          additionalProperties: {}
          description: Additional error metadata
      required:
        - detail
        - status
        - title
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Factory API key or JWT token for authentication

````