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

# Send a follow-up turn to a terminal run

> Sends the next user message into a terminal run's conversation — the API twin of typing another message in the Erstan chat UI. Always poll the `runId` **returned by this call**: a completed chat-lane run of an interactive agent usually continues under the same `runId` with full conversation context, while failed/cancelled chat runs fork a fresh execution on the same thread, and agents that use post-run continuation (non-interactive agents and graphs with dedicated human-input nodes) fork the conversational post-run shell — including follow-up questions about completed structured runs. Only the same API key that started the run may continue it. Waiting runs keep their exact interaction contract (`/reply`, `/approval`); a run that is still executing returns `run_still_active`, and Builder Preview tests and structured runs of interactive agents return `run_not_continuable`.



## OpenAPI

````yaml /openapi/public-api.yaml post /v1/public/runs/{runId}/continue
openapi: 3.1.0
info:
  title: Erstan Public Agent API
  version: 1.2.0
  description: >-
    Start published Erstan agents from external systems and poll for results.
    API keys carry scopes (`agents:list`, `agents:read`, `agents:write`,
    `agents:run`, `runs:read`, `tasks:execute`, `documents:read`,
    `documents:write`, `files:read`, `files:write`). Agent access follows the
    key creator's current workspace and team permissions. Project and team
    allowlists (`allowedProjectIds`, `allowedTeamIds`) further restrict task and
    document and file access. Agent draft authoring and task/document/file tools
    are exposed through the MCP server at `/v1/mcp` rather than REST routes.
servers:
  - url: https://api.erstan.com
    description: Public endpoint
security:
  - PublicApiKey: []
tags:
  - name: Agents
    description: >-
      Discover and run published agents available to the key creator under their
      current permissions.
  - name: Runs
    description: Read run status and results.
  - name: MCP
    description: >-
      Model Context Protocol server for external clients. Agent Builder tools
      use `agents:read`, `agents:write`, or both, plus the key creator's live
      Erstan permissions. Task and content tools also apply project/team
      allowlists.
paths:
  /v1/public/runs/{runId}/continue:
    post:
      tags:
        - Runs
      summary: Send a follow-up turn to a terminal run
      description: >-
        Sends the next user message into a terminal run's conversation — the API
        twin of typing another message in the Erstan chat UI. Always poll the
        `runId` **returned by this call**: a completed chat-lane run of an
        interactive agent usually continues under the same `runId` with full
        conversation context, while failed/cancelled chat runs fork a fresh
        execution on the same thread, and agents that use post-run continuation
        (non-interactive agents and graphs with dedicated human-input nodes)
        fork the conversational post-run shell — including follow-up questions
        about completed structured runs. Only the same API key that started the
        run may continue it. Waiting runs keep their exact interaction contract
        (`/reply`, `/approval`); a run that is still executing returns
        `run_still_active`, and Builder Preview tests and structured runs of
        interactive agents return `run_not_continuable`.
      operationId: continuePublicAgentRun
      parameters:
        - name: runId
          in: path
          required: true
          description: >-
            Terminal run ID returned by `POST /v1/public/agents/{agentId}/runs`
            or a previous continue call.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunContinueRequest'
            examples:
              followUp:
                value:
                  message: Approve the proposed change set and create the sales orders.
                  idempotencyKey: quote-chat-98342-turn-2
              withAttachment:
                value:
                  message: Here is the corrected workbook; re-run the checks.
                  attachments:
                    - name: corrected-orders.xlsx
                      type: >-
                        application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                      base64: UEsDBBQAAAAI...
                  idempotencyKey: quote-chat-98342-turn-3
      responses:
        '200':
          description: Existing accepted turn returned for a matching idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunContinueResponse'
        '202':
          description: >-
            Follow-up turn accepted. `runId` in the response is authoritative
            for polling — it matches the continued run for same-run
            continuations and is a new id when the turn forked a post-run or
            thread continuation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunContinueResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            The run is not a completed chat run ready for a follow-up turn, or
            another turn was accepted concurrently.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            The turn was valid but could not be queued; the completed state is
            unchanged and the caller may retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - PublicApiKey: []
components:
  schemas:
    RunContinueRequest:
      type: object
      additionalProperties: false
      required:
        - message
      description: >-
        Request body for sending a follow-up conversation turn to a terminal
        run.
      properties:
        message:
          type: string
          minLength: 1
          maxLength: 20000
          description: Next user message for the conversation.
        attachments:
          type: array
          description: >-
            Optional attachments supplied with this turn. Each item needs
            `name`, `type`, and either `base64` or `storageKey`.
          items:
            $ref: '#/components/schemas/Attachment'
        idempotencyKey:
          type: string
          maxLength: 200
          description: Reuse to prevent duplicate turns on retries of the same follow-up.
    RunContinueResponse:
      type: object
      additionalProperties: false
      required:
        - runId
        - agentId
        - laneId
        - status
      properties:
        runId:
          type: string
          format: uuid
          description: >-
            Run to poll for this turn — the same id for same-run continuations,
            a new id when the turn forked.
        agentId:
          type: string
        laneId:
          type: string
          nullable: true
        status:
          type: string
          description: '`running` once the follow-up turn is queued.'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                $ref: '#/components/schemas/ErrorDetail'
            requestId:
              type: string
    Attachment:
      type: object
      additionalProperties: false
      required:
        - name
        - type
      properties:
        name:
          type: string
        type:
          type: string
          description: Content type, such as `application/pdf`.
        base64:
          type: string
          description: Base64-encoded file content.
        storageKey:
          type: string
          description: Existing Erstan storage key, when already uploaded.
      anyOf:
        - required:
            - base64
        - required:
            - storageKey
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        field:
          type: string
        code:
          type: string
        message:
          type: string
  responses:
    BadRequest:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, expired, revoked, or inactive API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: >-
        The API key lacks scope or the creator lacks current permission for the
        requested operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: The requested agent or run was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    PublicApiKey:
      type: http
      scheme: bearer
      bearerFormat: ers_live API key
      description: >-
        Workspace API key created in Erstan Settings. Keys carry scopes
        (`agents:list`, `agents:read`, `agents:write`, `agents:run`,
        `runs:read`, `tasks:execute`, `documents:read`, `documents:write`,
        `files:read`, `files:write`). Agent access follows the key creator's
        current workspace, team, and agent permissions. Agent draft creation
        requires `agents:write`; update, validation, and publishing require both
        `agents:read` and `agents:write`; draft testing also requires
        `agents:run`. Keys with `tasks:execute` must include at least one
        allowed project or team (`allowedProjectIds` / `allowedTeamIds`); keys
        with document or file scopes must include at least one allowed team.
        Empty allowlists mean no access — the API fails closed.

````