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

# Send Support / Control Command

> The operator control rail for a session. Send a plain `message` (delivered to the customer while a human has taken over), a control `command`, or both.

Recognized commands:
- `takeover` — a human operator takes over the session; the agent stops auto-replying and `mode` becomes `support`.
- `tell` — inject operator guidance **and** fire an agent turn; the agent's `reply` is returned. Provide the text in `message`.
- `whisper` — append private operator guidance for the next agent turn; the customer never sees it.
- `end` — hand the session back to the agent (`mode` returns to `ai`).
- `close` — close the session permanently.

A request with only `message` and no `command` is a plain operator message, valid while the session is in `support` mode (after `takeover`).

Optional idempotency applies to every operation: plain operator messages, `tell`, `whisper`, `takeover`, `end`, and `close`. Supply an `idempotency_key` in the body, or an `Idempotency-Key` header when the body key is absent, null, or blank. A nonblank body key takes precedence and is preserved exactly, including surrounding whitespace. Without a key, requests retain their existing behavior and are not deduplicated.

Keys are scoped account-wide in a support namespace, independently of inbound-message keys. The operation fingerprint includes the session, command, exact message text, and effective operator identity. Message whitespace is significant; omitted and null messages are equivalent, as are omitted and null commands. For JWT authentication, the server uses the authenticated operator email and ignores body `operator_email`; for gateway requests, it trims surrounding whitespace from `operator_email` and treats a blank email as absent. Reuse the same key only for the same operation. Authentication and session ownership are checked on every request, including replays.

A completed operation, including a deterministic refusal, returns its saved result and HTTP status without repeating its effects. Completion records the operation's final server result, including any deferred delivery attempt result; the existing meaning of delivery success is unchanged. Pending retries return `202` with `data.state: "in_progress"` and `data.retry_after_ms: 1000`, without executing again. This state can persist if a process dies before recording its final outcome and does not prove the execution is still running. Retries never take over after a timeout; investigate prolonged pending states before resubmitting. A `busy` result means nothing ran and is retryable with the same key and operation.

A different operation using the same key returns `409` with `idempotency_key_reused`. An operation whose outcome cannot be established returns `409` with `support_operation_outcome_unknown`: investigate before resubmission. Such operations are never automatically re-executed or expired to allow execution. Idempotency does not promise exactly-once external delivery or a retention period beyond the stored receipt. Support keys are not automatically echoed in chat delivery callbacks.

## Retrying a support operation

Send an optional `idempotency_key` (at most 128 characters) with any support operation: a plain operator message, `tell`, `whisper`, `takeover`, `end`, or `close`. Use `Idempotency-Key` as a header fallback when the body key is absent, `null`, or blank. A nonblank body key takes precedence and is preserved exactly, including surrounding whitespace. Without an effective key, requests follow the existing behavior and are not deduplicated.

```json theme={null}
{
  "command": "close",
  "idempotency_key": "support-close-4718a326-1"
}
```

A key identifies one operation across your account's support namespace. Inbound-message keys use a separate namespace. Retry with the same session, command, exact message text, and effective operator identity. Message whitespace is significant; omitted and `null` messages are equivalent, as are omitted and `null` commands. For JWT-authenticated requests, the server uses the authenticated operator's email and ignores any body `operator_email`. Gateway requests use `operator_email` after trimming surrounding whitespace; a blank email is treated as absent. Authentication and session ownership are checked again before any replay.

| Response | What to do |
| - | - |
| Saved completed result and status | Use the original result, including any deterministic refusal. The server does not repeat the operation's effects. |
| `202`, `success: true`, `data.state: "in_progress"`, `data.retry_after_ms: 1000` | Wait 1 second, then retry with the same key and operation. Retries never start a second execution or take over after a timeout. If this state persists, investigate the original operation. |
| `200`, `success: true`, `data.state: "busy"`, with a retry delay | Nothing ran; retry with the same key and operation. |
| `409`, `error: "idempotency_key_reused"` | The key was used for a different operation. Use a new key only for a new operation. |
| `409`, `error: "support_operation_outcome_unknown"` | Investigate the original operation before resubmitting. Do not automatically retry with a new key. |
| `503`, `success: false`, with a machine-readable `error` | The durable key reservation could not be confirmed, or the runtime pool was unavailable before execution. The operation does not execute. Retry the same key and operation once the service recovers. |

An already reserved key remains bound to its operation. Retries never automatically take over a pending operation. `in_progress` can persist if a process dies before recording its final outcome; it does not prove that the execution is still running. Investigate a prolonged pending state before resubmitting.

Completion records the operation's final server result, including any deferred delivery attempt result. The existing meaning of delivery success stays the same. Unknown outcomes are never automatically re-executed or expired to allow execution. This contract does not promise exactly-once external delivery or a retention period beyond the stored receipt.

Support keys are not automatically echoed in [chat delivery callbacks](https://docs.osvi.ai/api-reference/endpoint/chat/delivery_webhook.md). The callback's `idempotency_key` field correlates inbound turns.


## OpenAPI

````yaml POST /v1/chat/session/{id}/support
openapi: 3.1.0
info:
  title: OSVI AI API
  description: REST API for the OSVI AI voice and chat platform
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.osvi.ai
security:
  - ApiToken: []
paths:
  /v1/chat/session/{id}/support:
    post:
      summary: Send support / control command
      description: >-
        The operator control rail for a session. Send a plain `message`
        (delivered to the customer while a human has taken over), a control
        `command`, or both.


        Recognized commands:

        - `takeover` — a human operator takes over the session; the agent stops
        auto-replying and `mode` becomes `support`.

        - `tell` — inject operator guidance **and** fire an agent turn; the
        agent's `reply` is returned. Provide the text in `message`.

        - `whisper` — append private operator guidance for the next agent turn;
        the customer never sees it.

        - `end` — hand the session back to the agent (`mode` returns to `ai`).

        - `close` — close the session permanently.


        A request with only `message` and no `command` is a plain operator
        message, valid while the session is in `support` mode (after
        `takeover`).


        Optional idempotency applies to every operation: plain operator
        messages, `tell`, `whisper`, `takeover`, `end`, and `close`. Supply an
        `idempotency_key` in the body, or an `Idempotency-Key` header when the
        body key is absent, null, or blank. A nonblank body key takes precedence
        and is preserved exactly, including surrounding whitespace. Without a
        key, requests retain their existing behavior and are not deduplicated.


        Keys are scoped account-wide in a support namespace, independently of
        inbound-message keys. The operation fingerprint includes the session,
        command, exact message text, and effective operator identity. Message
        whitespace is significant; omitted and null messages are equivalent, as
        are omitted and null commands. For JWT authentication, the server uses
        the authenticated operator email and ignores body `operator_email`; for
        gateway requests, it trims surrounding whitespace from `operator_email`
        and treats a blank email as absent. Reuse the same key only for the same
        operation. Authentication and session ownership are checked on every
        request, including replays.


        A completed operation, including a deterministic refusal, returns its
        saved result and HTTP status without repeating its effects. Completion
        records the operation's final server result, including any deferred
        delivery attempt result; the existing meaning of delivery success is
        unchanged. Pending retries return `202` with `data.state: "in_progress"`
        and `data.retry_after_ms: 1000`, without executing again. This state can
        persist if a process dies before recording its final outcome and does
        not prove the execution is still running. Retries never take over after
        a timeout; investigate prolonged pending states before resubmitting. A
        `busy` result means nothing ran and is retryable with the same key and
        operation.


        A different operation using the same key returns `409` with
        `idempotency_key_reused`. An operation whose outcome cannot be
        established returns `409` with `support_operation_outcome_unknown`:
        investigate before resubmission. Such operations are never automatically
        re-executed or expired to allow execution. Idempotency does not promise
        exactly-once external delivery or a retention period beyond the stored
        receipt. Support keys are not automatically echoed in chat delivery
        callbacks.
      parameters:
        - name: id
          in: path
          required: true
          description: The session UUID (from Create Session or Get Active Session).
          schema:
            type: string
            example: 4718a326-417b-4dda-90d0-21fd65a11cb8
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Optional support-operation key, used only when the body
            idempotency_key is absent, null, or blank. A nonblank body key wins
            and is preserved exactly, including surrounding whitespace. Scoped
            account-wide within the support namespace, separately from
            inbound-message keys.
          schema:
            type: string
            maxLength: 128
            example: support-close-4718a326-1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                command:
                  type: string
                  enum:
                    - takeover
                    - tell
                    - whisper
                    - end
                    - close
                  description: >-
                    Control command to apply. Omit to send a plain operator
                    message (requires the session to be in `support` mode).
                  example: close
                  nullable: true
                message:
                  type: string
                  description: >-
                    Message text. Required for a plain operator message and for
                    the `tell` command; optional context for `takeover`.
                  example: A human agent is joining the conversation.
                  nullable: true
                idempotency_key:
                  type: string
                  nullable: true
                  maxLength: 128
                  description: >-
                    Optional key for this exact support operation. A nonblank
                    body key is preserved exactly, including surrounding
                    whitespace, and takes precedence over Idempotency-Key;
                    absent, null, or blank falls back to the header. Reuse the
                    same key with the same session, command, exact message, and
                    effective operator identity when retrying. Without an
                    effective key, no deduplication occurs.
                  example: support-close-4718a326-1
                operator_email:
                  type: string
                  nullable: true
                  description: >-
                    Optional operator email for gateway requests. Surrounding
                    whitespace is trimmed and a blank email is treated as
                    absent. For JWT-authenticated requests, the server always
                    uses the authenticated user email and ignores this body
                    field. The effective identity is part of the idempotency
                    fingerprint.
                  example: agent@yourco.com
            examples:
              plain_message:
                summary: Plain operator message
                value:
                  message: A human agent is joining the conversation.
              close:
                summary: Close the session
                value:
                  command: close
                  idempotency_key: support-close-4718a326-1
              takeover:
                summary: Human takeover
                value:
                  command: takeover
              tell:
                summary: Tell (guide the agent and reply)
                value:
                  command: tell
                  message: Thanks, I can help with that.
      responses:
        '200':
          description: >-
            Operation completed, or an existing command outcome such as busy. A
            completed keyed operation replays its saved result and status
            without repeating effects; completion records the final server
            result, including any deferred delivery attempt result. The response
            data includes state, session_id, and command; additional fields
            depend on the command (e.g. reply for tell, active_human for
            takeover). A busy outcome means nothing ran; retry with the same key
            and operation. Existing delivery-success semantics are unchanged.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      state:
                        type: string
                        description: >-
                          Outcome of the command — `ok` on success, or a status
                          such as `no_change`, `busy`, `dormant`, `rejected`,
                          `disabled`, `invalid`, or `timeout`.
                        example: ok
                      session_id:
                        type: string
                        example: 4718a326-417b-4dda-90d0-21fd65a11cb8
                      command:
                        type: string
                        nullable: true
                        description: >-
                          Echo of the command issued. `null` for a plain
                          operator message.
                        example: close
                      reply:
                        type: string
                        nullable: true
                        description: Agent reply — present for the `tell` command.
                        example: Of course, let me pull that up for you.
                      active_human:
                        type: string
                        nullable: true
                        description: >-
                          Email of the operator now holding the session —
                          present for `takeover`.
                        example: agent@yourco.com
                      retry_after_ms:
                        type: integer
                        description: >-
                          Suggested retry delay in milliseconds for a busy
                          result where nothing ran. Retry with the same key and
                          operation.
                        example: 1000
        '202':
          description: >-
            The keyed operation has no recorded final outcome. Wait
            retry_after_ms, then retry the same key and operation to obtain its
            saved completion result. This state can persist if a process dies
            before recording its final outcome; it does not prove the execution
            is still running. Retries never execute again or take over after a
            timeout. Investigate prolonged pending states before resubmitting.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    required:
                      - state
                      - session_id
                      - command
                      - retry_after_ms
                      - idempotency_key
                    properties:
                      state:
                        type: string
                        enum:
                          - in_progress
                        example: in_progress
                      session_id:
                        type: string
                        example: 4718a326-417b-4dda-90d0-21fd65a11cb8
                      command:
                        type: string
                        nullable: true
                        description: Command issued; null for a plain operator message.
                        example: close
                      retry_after_ms:
                        type: integer
                        enum:
                          - 1000
                        example: 1000
                      idempotency_key:
                        type: string
                        maxLength: 128
                        description: >-
                          Echo of the effective support-operation key. This does
                          not imply the key is echoed in delivery callbacks.
                        example: support-close-4718a326-1
              example:
                success: true
                data:
                  state: in_progress
                  session_id: 4718a326-417b-4dda-90d0-21fd65a11cb8
                  command: close
                  retry_after_ms: 1000
                  idempotency_key: support-close-4718a326-1
        '401':
          description: Invalid or missing API token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatV1Error'
        '403':
          description: >-
            The requested command is disabled for this agent
            (`command_disabled`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatV1Error'
        '404':
          description: No session matches the given `id` (`session_not_found`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatV1Error'
        '409':
          description: >-
            Support idempotency conflict. idempotency_key_reused means this
            account-wide support key was used for a different session, command,
            exact message, or effective operator identity.
            support_operation_outcome_unknown means the original outcome cannot
            be established; investigate before resubmission. An unknown outcome
            is never automatically re-executed or expired to allow execution.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    enum:
                      - idempotency_key_reused
                      - support_operation_outcome_unknown
                    description: Machine-readable support idempotency conflict code.
                    example: idempotency_key_reused
                  data:
                    type: object
                    description: >-
                      Additional operation details from the chat engine, when
                      available.
                    additionalProperties: true
                    nullable: true
              examples:
                key_reused:
                  summary: Key used for a different operation
                  value:
                    success: false
                    error: idempotency_key_reused
                outcome_unknown:
                  summary: Original outcome needs investigation
                  value:
                    success: false
                    error: support_operation_outcome_unknown
        '422':
          description: >-
            The chat engine rejected the command (e.g. wrong mode for a plain
            message, or empty `tell` text). Keyed requests use success: false
            with a machine-readable error and optional nullable data containing
            engine details. Requests without a key retain the legacy error and
            upstream_body envelope.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ChatV1TurnError'
                  - $ref: '#/components/schemas/ChatV1EngineError'
        '502':
          description: >-
            The chat engine could not be reached or returned an error. Keyed
            requests use success: false with a machine-readable error and
            optional nullable data containing engine details. Requests without a
            key retain the legacy error and upstream_body envelope.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ChatV1TurnError'
                  - $ref: '#/components/schemas/ChatV1EngineError'
        '503':
          description: >-
            For keyed requests, the durable key reservation could not be
            confirmed, or the runtime pool was unavailable before execution. The
            operation does not execute. Retry the same key and operation once
            the service recovers. An already reserved key remains bound to its
            operation; retries never automatically take over a pending
            operation.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    description: Machine-readable error code from the chat engine.
                  data:
                    type: object
                    description: >-
                      Additional operation details from the chat engine, when
                      available.
                    additionalProperties: true
                    nullable: true
components:
  schemas:
    ChatV1Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Machine-readable error code or message.
          example: agent_not_found
    ChatV1TurnError:
      type: object
      description: >-
        A turn-level conflict or refusal from the chat engine, passed through
        with the status code the engine gave it.
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Machine-readable error code.
          example: idempotency_key_reused
        data:
          type: object
          nullable: true
          description: Extra context when available — typically `turn_id` and `session_id`.
          example:
            state: error
            turn_id: turn_9f3d2a1b
            session_id: 4718a326-417b-4dda-90d0-21fd65a11cb8
    ChatV1EngineError:
      type: object
      description: >-
        Returned when the upstream chat engine rejects or fails a proxied
        request.
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Python engine returned 422 for POST /v1/chat/session/{id}/support
        upstream_body:
          type: object
          nullable: true
          description: Parsed error body returned by the chat engine, when available.
          example:
            state: rejected
            reason: tell_not_allowed_during_takeover
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: API-Token
      description: >-
        16-character API token associated with your OSVI account. Find it in
        your dashboard under Settings → API.

````

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