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

# Continue a thread with a user message

> Appends a user message to an existing thread to continue it. The effect depends on the current thread state: a completed/failed/waiting thread is re-queued and re-run with the message appended; a still-running or queued thread receives the message on its next turn (right after the pending tool response). Threads waiting for approval, handed off to a subagent, or still being created cannot be continued this way.



## OpenAPI

````yaml POST /v1/agents/threads/{threadId}/messages
openapi: 3.0.0
info:
  title: Devic.ai Public API
  description: >-
    Devic.ai is an AI platform that allows you to create, manage, and use AI
    agents for various tasks.
  version: 1.0.0
  contact:
    name: Devic.ai Support
    url: https://devic.ai
  x-logo:
    url: https://devic.ai/logo.png
    altText: Devic.ai Logo
  x-summary: Public API for interacting with Devic.ai platform
servers:
  - url: https://api.devic.ai
    description: Production server
  - url: https://staging-api.devic.ai
    description: Staging server
security:
  - bearerAuth: []
tags:
  - name: Projects
    description: Group agents, assistants, documents and costs into projects
  - name: Documents
    description: >-
      Knowledge base documents: create, version, attach and index markdown
      content for RAG
  - name: Document Folders
    description: Organise knowledge base documents into folders and attach them in bulk
  - name: Files
    description: Upload files and obtain shareable download URLs to attach to messages
  - name: Agents
    description: Endpoints related to AI agents and their operations
  - name: Assistants
    description: Endpoints for interacting with assistants and their specializations
  - name: Tool Servers
    description: Endpoints for managing tool servers and their tool definitions
  - name: Health
    description: API health check endpoints
  - name: Documentation
    description: Endpoints for retrieving markdown documentation
  - name: Integrations
    description: Connect third-party apps and turn them into tools
  - name: Triggers
    description: Start an agent or an assistant from an app event
  - name: Tenant Integrations
    description: Apps that each end user connects for themselves
  - name: Memory
    description: What an assistant remembers between conversations
  - name: Skills
    description: Reusable instruction packs for agents and assistants
  - name: Speech to Text
    description: Audio transcription
  - name: Tenants
    description: Tenants, subtenants and their usage
  - name: MCP Gateway
    description: One MCP endpoint over many servers, with visibility per user
  - name: Tenant Sessions
    description: Tokens that prove which end user is calling
paths:
  /v1/agents/threads/{threadId}/messages:
    post:
      tags:
        - Agents
      summary: Continue a thread with a user message
      description: >-
        Appends a user message to an existing thread to continue it. The effect
        depends on the current thread state: a completed/failed/waiting thread
        is re-queued and re-run with the message appended; a still-running or
        queued thread receives the message on its next turn (right after the
        pending tool response). Threads waiting for approval, handed off to a
        subagent, or still being created cannot be continued this way.
      operationId: addThreadMessage
      parameters:
        - name: threadId
          required: true
          in: path
          description: The ID of the thread to continue
          schema:
            type: string
        - name: devic-api-source
          required: false
          in: header
          schema:
            type: string
          description: >-
            Free-text label recorded with the call, to tell apart the
            integrations that use the same key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddThreadMessageDto'
      responses:
        '200':
          description: Message added to the thread
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThreadResponseDto'
        '401':
          description: Unauthorized - Invalid or missing token
        '404':
          description: Thread not found
        '409':
          description: Thread is in a state that cannot be continued with a message
        '429':
          description: Too Many Requests - Rate limit exceeded
        '500':
          description: Internal Server Error
      security:
        - bearerAuth: []
components:
  schemas:
    AddThreadMessageDto:
      type: object
      properties:
        message:
          description: >-
            The user message to append to the thread to continue it (string or
            object). Behaviour depends on the current thread state: a
            running/queued thread receives it on its next turn (after the
            pending tool response); a completed/failed/waiting thread is
            re-queued to run again with the message appended.
          example: Also include a summary of the previous steps
          oneOf:
            - type: string
            - type: object
      required:
        - message
    ThreadResponseDto:
      type: object
      properties:
        tokenUsage:
          type: object
          description: Enhanced token usage with cost breakdown
          properties:
            inputTokens:
              type: number
              example: 1250
            outputTokens:
              type: number
              example: 450
            inputCachedTokens:
              type: number
              example: 320
            outputCachedTokens:
              type: number
              example: 80
            totalTokens:
              type: number
              example: 1700
            totalCachedTokens:
              type: number
              example: 400
            cost:
              type: object
              properties:
                inputCost:
                  type: number
                  example: 0.00125
                outputCost:
                  type: number
                  example: 0.0045
                inputCachedCost:
                  type: number
                  example: 0.00016
                outputCachedCost:
                  type: number
                  example: 0.008
                totalCost:
                  type: number
                  example: 0.00641
            provider:
              type: string
              example: open-ai
            model:
              type: string
              example: gpt-4o-mini-2024-07-18
        metadata:
          type: object
          description: >-
            Thread metadata containing prompt template parameters and tenant
            token
          properties:
            propmptTemplateParams:
              type: object
              description: >-
                Parameters used for template variable substitution in the agent
                system prompt (e.g., {{customerName}} becomes "John Doe")
            tenantToken:
              type: string
              description: Token used for authentication in tool calling operations
        tenantId:
          type: string
          description: Tenant ID for multi-tenant environments
          example: tenant-123
        isSubthread:
          type: boolean
          description: Whether this thread is a subthread created by a parent handoff
          example: false
        parentThreadId:
          type: string
          description: ID of the parent thread (if this is a subthread)
          example: 64f5a5b8c123456789abcdef
        parentAgentId:
          type: string
          description: ID of the parent agent (if this is a subthread)
          example: 64f5a5b8c123456789abcdef
        subThreadToolCallId:
          type: string
          description: Tool call ID in the parent thread that triggered this subthread
          example: call_abc123
        pendingHandOffSubThreadIds:
          description: IDs of subthreads still executing (for parent threads)
          type: array
          items:
            type: string
        handOffSubThreadIds:
          description: All subthread IDs ever created during handoffs (for parent threads)
          type: array
          items:
            type: string
        tasks:
          description: List of task for the thread execution
          type: array
          items:
            $ref: '#/components/schemas/TaskDto'
        pendingAsyncToolCalls:
          type: array
          description: >-
            Pending async tool calls awaiting an external response. Each entry
            exposes the callbackUrl the external system must POST the response
            to.
          items:
            type: object
            properties:
              toolCallId:
                type: string
              toolName:
                type: string
              sentAt:
                type: number
              resolved:
                type: boolean
              callbackUrl:
                type: string
        pausedReason:
          type: string
          description: >-
            Reason the thread is paused (e.g. waiting for an async tool
            response).
        pausedUntil:
          type: number
          description: >-
            Epoch milliseconds when a paused thread is scheduled to resume. Only
            set while the thread is paused with a scheduled resume.
          example: 1721551200000
        pausedTimestampMS:
          type: number
          description: Epoch milliseconds when the thread was paused.
          example: 1721550000000
        coreMemories:
          description: >-
            Audit trail of the core-memory blocks this thread saw: one snapshot
            (render revision + the injected entries as structured JSON) per
            distinct revision, including mid-run edits. Present only for agents
            with core memory enabled.
          type: array
          items:
            type: string
        recalledMemories:
          description: >-
            Structured recall events of this thread: the automatic
            long-term-memory recall at run start plus every memory-tool lookup,
            each with the query and the facts/entities it surfaced. Present only
            for agents with long-term memory enabled.
          type: array
          items:
            type: string
    TaskDto:
      type: object
      properties: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use JWT token for authentication

````