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

# End a v2 conversation through the close pipeline (admin)

> conv_* replacement for the retired ``POST /v1/runtime/end_session``.

The legacy endpoint drove ``Runtime.end_session(triggered_by="admin")``,
which under ``PersistStrategy.PER_TURN`` (every HTTP channel) reduced to the
same unified close pipeline ``SessionService.close_session`` now owns: flip
to CLOSED, stamp the meta close-out columns + retention, and enqueue the
post-session finalize chain (PII scrub → summarize + memory-sync). So this
is a straight call to ``close_session`` — there is no separate v2 ``Runtime``
to construct.

The conversation id is taken from the PATH and org-scoped (cross-org /
missing → 404 inside ``close_session`` → ``get_session_for_org``); the legacy
body's ``session_id`` / ``end_user_id`` / ``agent_id`` / ``channel`` fields
are accepted for wire-compat but ignored. ``reason`` defaults to
``AGENT_INITIATED`` (the same RESOLVED outcome category the legacy admin
close used when no explicit reason was supplied).

Response mirrors the legacy ``TurnResult`` shape (``messages=[]``,
``status="ended"``) — the admin UI ignores the body and only awaits the 200.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/v2/conversations/{conversation_id}/end_session
openapi: 3.1.0
info:
  title: Feather API
  description: >-
    Unified customer experience platform API. Manages identity, conversations,
    memory, agents, procedures, policies, model routing, knowledge bases,
    integrations, and runtime execution.
  version: 1.21.0
servers:
  - url: https://api-sandbox.featherhq.com
    description: Sandbox
  - url: http://localhost:8000
    description: Local dev
security: []
paths:
  /v1/v2/conversations/{conversation_id}/end_session:
    post:
      tags:
        - runtime v2
      summary: End a v2 conversation through the close pipeline (admin)
      description: >-
        conv_* replacement for the retired ``POST /v1/runtime/end_session``.


        The legacy endpoint drove ``Runtime.end_session(triggered_by="admin")``,

        which under ``PersistStrategy.PER_TURN`` (every HTTP channel) reduced to
        the

        same unified close pipeline ``SessionService.close_session`` now owns:
        flip

        to CLOSED, stamp the meta close-out columns + retention, and enqueue the

        post-session finalize chain (PII scrub → summarize + memory-sync). So
        this

        is a straight call to ``close_session`` — there is no separate v2
        ``Runtime``

        to construct.


        The conversation id is taken from the PATH and org-scoped (cross-org /

        missing → 404 inside ``close_session`` → ``get_session_for_org``); the
        legacy

        body's ``session_id`` / ``end_user_id`` / ``agent_id`` / ``channel``
        fields

        are accepted for wire-compat but ignored. ``reason`` defaults to

        ``AGENT_INITIATED`` (the same RESOLVED outcome category the legacy admin

        close used when no explicit reason was supplied).


        Response mirrors the legacy ``TurnResult`` shape (``messages=[]``,

        ``status="ended"``) — the admin UI ignores the body and only awaits the
        200.
      operationId: endV2ConversationSession
      parameters:
        - name: conversation_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Conversation Id
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/EndSessionRequest'
                - type: 'null'
              title: Body
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TurnResult'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    EndSessionRequest:
      properties:
        end_user_id:
          type: string
          format: uuid
          title: End User Id
        session_id:
          type: string
          format: uuid
          title: Session Id
        agent_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Agent Id
        channel:
          type: string
          title: Channel
          default: api
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
      type: object
      required:
        - end_user_id
        - session_id
      title: EndSessionRequest
      description: >-
        Admin-triggered runtime end-session.


        Distinct from ``POST /v1/sessions/{id}/close`` which only flips the DB

        status. This drives the full ``Runtime.end_session`` pipeline (AOP

        cleanup, memory flush, OTel ``session.end`` span,
        ``triggered_by=admin``).


        ``session_id`` is required: ``Runtime.from_authenticated`` falls through

        to ``get_or_create_active_session`` when it's missing, which would mint

        a fresh ACTIVE session purely to end it on the same request. Requiring

        the caller to name the target session prevents that ghost-session path

        and forces a clear 422 instead of a misleading 200.


        ``farewell_text`` is intentionally omitted: the runtime ignores it

        under ``PersistStrategy.PER_TURN`` (used by every HTTP channel today),

        so accepting it would silently drop the value. Callers that want a

        user-visible farewell should send a final ``POST /v1/runtime/turn``

        with the goodbye message before calling this endpoint.
    TurnResult:
      properties:
        session_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Session Id
        messages:
          items:
            $ref: '#/components/schemas/AssistantMessage'
          type: array
          title: Messages
        status:
          $ref: '#/components/schemas/SessionStatus'
        handoff:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Handoff
        call_transfer:
          anyOf:
            - $ref: '#/components/schemas/CallTransferIntent'
            - type: 'null'
        dtmf_input:
          anyOf:
            - $ref: '#/components/schemas/DtmfInputSpec'
            - type: 'null'
        session_status:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Status
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        model_used:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Used
        token_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Token Count
        latency_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Latency Ms
      type: object
      required:
        - status
      title: TurnResult
      description: |-
        Universal post-turn snapshot returned by ``Runtime.run_turn``.

        Every channel sees the same fields:

        - ``session_id``: the session this turn ran against. Always populated
          when a real ``Runtime`` produced the result (the caller may have
          passed ``session_id=None`` and asked the runtime to resolve / create
          the active session — this is how it learns which one was used).
          Optional in the type for the benefit of test fixtures that mint
          ``TurnResult``s by hand without a Runtime.
        - ``messages``: 1 message for API/voice; *N* (Plan 5) for SMS chunked.
        - ``status``: snapshot of ``Runtime._status`` at end-of-turn. The caller
          uses this to decide whether to call ``end_session``.
        - ``handoff``: populated when AOP reached a HandoffNode. The dict shape
          mirrors the existing ``AOPExecutionResult.handoff_config`` for
          forward-compat — Plan 3 does not re-type it.
        - ``error``: when AOP execution fails, this is the
          ``AOPExecutionResult.execution_error`` string the pipeline stamped
          (e.g. ``"node_execution_failed: ValidationError: ..."``,
          ``"routing_error: <node_id>"``, ``"unknown_node_type"``); falls
          back to the legacy ``"max_steps_exceeded"`` label only when the
          pipeline didn't attach a reason. ``repr(exc)`` for an uncaught
          exception in ``_execute``. ``None`` on success / handoff /
          policy-violation.
        - ``model_used`` / ``token_count`` / ``latency_ms``: aggregate metrics
          surfaced for telemetry; ``None`` when the turn made no LLM call.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
        message:
          type: string
          title: Message
      type: object
      required:
        - error
        - message
      title: ErrorResponse
      description: Standard error response returned by all API error handlers.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AssistantMessage:
      properties:
        turn_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Turn Id
        content:
          type: string
          title: Content
        sequence:
          type: integer
          title: Sequence
          default: 0
        producing_assistant_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Producing Assistant Id
      type: object
      required:
        - content
      title: AssistantMessage
      description: >-
        One assistant message produced by a single ``Runtime.run_turn`` call.


        A turn always returns at least one ``AssistantMessage`` (even an empty

        string for a silent turn). Plan 5 introduces ``max_per_msg_len``
        chunking

        for SMS, at which point ``run_turn`` will return *N* messages for one

        turn (one per chunk). For Plan 3, the list always has length 1.


        ``turn_id`` is populated when the runtime persisted the row inline

        (``PersistStrategy.PER_TURN``); for ``FLUSH_AT_END`` it stays ``None``

        until ``end_session`` flushes the buffer at which point the channel

        runtime no longer cares — voice has already streamed the audio, the

        DB row is now durable but its id is internal to the buffer flush.
    SessionStatus:
      type: string
      enum:
        - idle
        - running_turn
        - end_requested
        - end_processing
        - ended
        - error
      title: SessionStatus
      description: |-
        In-memory lifecycle status of a ``Runtime`` instance.

        Distinct from ``ConversationSession.status`` (DB column). The DB status
        is the durable end-state of a session row; this enum is the per-instance
        live signal that channel runtimes consult after each ``run_turn`` to
        decide whether to call ``end_session``.
    CallTransferIntent:
      properties:
        destination:
          type: string
          title: Destination
        mode:
          type: string
          enum:
            - cold
            - warm
          title: Mode
          default: cold
        label:
          anyOf:
            - type: string
            - type: 'null'
          title: Label
        connecting_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Connecting Text
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
        warm_destinations:
          items:
            type: string
          type: array
          title: Warm Destinations
        max_retries:
          type: integer
          maximum: 5
          minimum: 0
          title: Max Retries
          default: 1
        retry_text:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Retry Text
        on_failure:
          anyOf:
            - type: string
            - type: 'null'
          title: On Failure
        warm:
          anyOf:
            - $ref: '#/components/schemas/WarmTransferConfig'
            - type: 'null'
        warm_overrides:
          anyOf:
            - $ref: '#/components/schemas/WarmTransferTargetOverride'
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - destination
      title: CallTransferIntent
      description: >-
        The resolved, ready-to-execute transfer the voice host renders after a
        turn.


        Both authoring surfaces converge on this: the assistant
        ``transfer_call`` platform

        tool (label → destination resolved from config) and the workflow
        ``HandoffNode``

        voice transfer (deterministic single target, or LLM-picked among many)
        both produce a

        ``CallTransferIntent``; the voice worker reads it via
        ``VoiceRuntime.pending_transfer``

        and issues the SIP REFER. ``connecting_text`` is the optional "one
        moment, connecting

        you…" line spoken before the transfer.
    DtmfInputSpec:
      properties:
        expects_input:
          type: boolean
          title: Expects Input
          default: true
        max_digits:
          anyOf:
            - type: integer
              maximum: 64
              minimum: 1
            - type: 'null'
          title: Max Digits
        termination_digit:
          anyOf:
            - type: string
              maxLength: 1
            - type: 'null'
          title: Termination Digit
        inter_digit_timeout_ms:
          anyOf:
            - type: integer
              maximum: 60000
              minimum: 250
            - type: 'null'
          title: Inter Digit Timeout Ms
        prefix:
          anyOf:
            - type: string
              maxLength: 32
            - type: 'null'
          title: Prefix
      additionalProperties: false
      type: object
      title: DtmfInputSpec
      description: >-
        Per-node keypad-collection tuning (authoring config + runtime
        directive).


        All fields optional: an unset field means "leave the assistant-level
        default

        in place" (the voice config's ``dtmf_*`` values). ``expects_input`` is
        the

        intent flag — a node that explicitly expects keypad entry — used so the
        host

        can apply the retune even when no numeric override differs from the
        default.

        ``prefix`` overrides the turn-text label (collection mechanics +
        framing).
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    WarmTransferConfig:
      properties:
        message_mode:
          type: string
          enum:
            - ai_summary
            - static
            - prompt
          title: Message Mode
          default: ai_summary
        briefing_template:
          anyOf:
            - type: string
              maxLength: 4000
            - type: 'null'
          title: Briefing Template
        max_dial_seconds:
          type: integer
          maximum: 120
          minimum: 5
          title: Max Dial Seconds
          default: 30
        max_briefing_seconds:
          type: integer
          maximum: 600
          minimum: 15
          title: Max Briefing Seconds
          default: 60
        bridge_confirm_seconds:
          type: integer
          maximum: 60
          minimum: 5
          title: Bridge Confirm Seconds
          default: 20
        max_hold_seconds:
          type: integer
          maximum: 300
          minimum: 15
          title: Max Hold Seconds
          default: 110
        hold_announcement_text:
          type: string
          maxLength: 500
          title: Hold Announcement Text
          default: One moment — I'll place you on a brief hold while I connect you.
        reassurance_interval_seconds:
          type: integer
          maximum: 60
          minimum: 0
          title: Reassurance Interval Seconds
          default: 20
        reassurance_text:
          type: string
          maxLength: 500
          title: Reassurance Text
          default: Thanks for your patience — I'm still working on connecting you.
        detect_supervisor_voicemail:
          type: boolean
          title: Detect Supervisor Voicemail
          default: false
        detect_supervisor_silence:
          type: boolean
          title: Detect Supervisor Silence
          default: false
        silence_reminder_text:
          type: string
          maxLength: 500
          title: Silence Reminder Text
          default: Hello — are you available to take this call?
        silence_timeout_seconds:
          type: integer
          maximum: 60
          minimum: 5
          title: Silence Timeout Seconds
          default: 15
        retry_announcement_text:
          type: string
          maxLength: 500
          title: Retry Announcement Text
          default: I couldn't reach them that way — let me try connecting you directly.
        failure_text:
          type: string
          maxLength: 500
          title: Failure Text
          default: >-
            I'm sorry, I wasn't able to connect you right now. I can keep
            helping you here.
      additionalProperties: false
      type: object
      title: WarmTransferConfig
      description: >-
        Tuning for *warm* call transfer on the assistant ``transfer_call``
        platform tool.


        Lives under ``platform_tools["transfer_call"]["warm"]`` alongside
        ``targets``. Warm is

        selected by authoring a target ``mode="warm"`` (its ``destination`` is
        the supervisor) —

        this block only carries the timeouts / message-mode knobs. Durations are
        bounded

        so a bad config can never strand a caller on hold indefinitely.
    WarmTransferTargetOverride:
      properties:
        briefing_template:
          anyOf:
            - type: string
              maxLength: 4000
            - type: 'null'
          title: Briefing Template
        message_mode:
          anyOf:
            - type: string
              enum:
                - ai_summary
                - static
                - prompt
            - type: 'null'
          title: Message Mode
      additionalProperties: false
      type: object
      title: WarmTransferTargetOverride
      description: >-
        Per-destination override of the destination-specific subset of
        WarmTransferConfig.


        Lives on a ``TransferTargetConfig`` (assistant ``transfer_call`` tool
        target OR workflow

        ``HandoffNode.channels.voice`` target). ``None`` fields inherit the
        tool/node-level

        ``WarmTransferConfig`` baseline. Only the genuinely destination-specific
        fields are

        overridable here — the customer-experience + Twilio-mechanics timeouts
        (max_hold,

        reassurance, bridge_confirm, dial/briefing windows) stay tool/node-wide.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````