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

# Control self-managed session

> Send a control event to an active session.



## OpenAPI

````yaml /openapi.json post /liveai/sessions/{session_id}/control
openapi: 3.1.0
info:
  title: LemonSlice
  description: An API that gives access to a LemonSlice agent via a Daily room.
  license:
    name: MIT
    identifier: MIT
  version: 1.0.0
servers:
  - url: https://lemonslice.com/api
security:
  - apiKeyAuth: []
paths:
  /liveai/sessions/{session_id}/control:
    post:
      summary: Control self-managed session
      description: Send a control event to an active session.
      operationId: controlSession
      parameters:
        - name: session_id
          in: path
          description: The ID of the session to control.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/TerminateEvent'
                  title: Terminate
                  description: >-
                    Immediately shuts down the LemonSlice avatar and removes it
                    from the WebRTC room.
                - $ref: '#/components/schemas/UpdateImageEvent'
                  title: Update Image
                  description: >-
                    Update the avatar's reference image. When possible, send
                    this event while the avatar is not speaking (any audio
                    currently playing will be cut off). The image changes takes
                    <1 second. See our [Real-time Updates
                    guide](/reference/realtime-updates) for more details.
                - $ref: '#/components/schemas/UpdateAgentPromptEvent'
                  title: Update Agent Prompt
                  description: >-
                    A high-level system prompt that subtly influences the
                    avatar's expressions while speaking. This prompt is best
                    used to suggest general demeanor (for example, 'feel
                    excited' or 'look sad') rather than precise or deterministic
                    actions.
                - $ref: '#/components/schemas/UpdateIdlePromptEvent'
                  title: Update Idle Prompt
                  description: >-
                    A high-level system prompt that subtly influences the
                    avatar's expressions during the idle state.
                - $ref: '#/components/schemas/PoseTriggerEvent'
                  title: Action Trigger
                  description: Trigger a specific action sequence on the active avatar.
                - $ref: '#/components/schemas/ResetIdleTimeoutEvent'
                  title: Reset Idle Timeout
                  description: >-
                    Resets the idle timeout timer on the session. Useful to keep
                    the session alive when the user is still engaged but the
                    avatar is not currently speaking.
              discriminator:
                propertyName: event
                mapping:
                  update-image:
                    $ref: '#/components/schemas/UpdateImageEvent'
                  terminate:
                    $ref: '#/components/schemas/TerminateEvent'
                  update-agent-prompt:
                    $ref: '#/components/schemas/UpdateAgentPromptEvent'
                  update-idle-prompt:
                    $ref: '#/components/schemas/UpdateIdlePromptEvent'
                  pose-trigger:
                    $ref: '#/components/schemas/PoseTriggerEvent'
                  reset-idle-timeout:
                    $ref: '#/components/schemas/ResetIdleTimeoutEvent'
            examples:
              terminate:
                summary: Terminate session
                value:
                  event: terminate
              update_image:
                summary: Change the avatar image (URL)
                description: >-
                  Update the avatar's reference image with an image hosted at a
                  public URL.
                value:
                  event: update-image
                  image_url: https://example.com/avatar.jpg
              update_image_base64:
                summary: Change the avatar image (inline base64)
                description: >-
                  Update the avatar's reference image by sending the new image
                  bytes inline as base64. The decoded image must be under 900
                  KB.
                value:
                  event: update-image
                  image_base64: iVBORw0KGgoAAAANSUhEUgAA...
              update_agent_prompt:
                summary: Update the agent prompt (for speaking periods)
                description: Replace the agent prompt used when the avatar is speaking.
                value:
                  event: update-agent-prompt
                  agent_prompt: a person talking
              update_idle_prompt:
                summary: Update the idle prompt (for idle periods)
                description: Replace the idle prompt used when the avatar is idle.
                value:
                  event: update-idle-prompt
                  idle_prompt: a serious person
              pose_trigger:
                summary: Trigger an action
                description: Trigger the requested action.
                value:
                  event: pose-trigger
                  pose_trigger:
                    name: <ACTION_NAME>
              reset_idle_timeout:
                summary: Reset the idle timeout
                description: Reset the idle timeout timer to keep the session alive.
                value:
                  event: reset-idle-timeout
      responses:
        '200':
          description: Control event accepted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
              example:
                success: true
        '400':
          description: Invalid event or missing required fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: image_url or image_base64 required for update-image event
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Session not found
        '413':
          description: >-
            Inline image too large. The decoded `image_base64` payload must be
            under 900 KB; host larger images and pass `image_url` instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: >-
                  image_base64 decodes to 1048576 bytes; inline images must be
                  under 921600 bytes. Host larger images and pass image_url
                  instead.
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
      security: []
components:
  schemas:
    TerminateEvent:
      type: object
      required:
        - event
      properties:
        event:
          type: string
          const: terminate
          default: terminate
          description: terminate
    UpdateImageEvent:
      type: object
      required:
        - event
      properties:
        event:
          type: string
          const: update-image
          default: update-image
          description: update-image
        image_url:
          type: string
          format: uri
          description: >-
            URL of the new avatar image. Must be publicly accessible. Provide
            exactly one of `image_url` or `image_base64`.
          example: https://example.com/avatar.jpg
        image_base64:
          type: string
          description: >-
            Base64-encoded bytes of the new avatar image. A data URL prefix
            (e.g. `data:image/png;base64,`) is also accepted. The decoded image
            must be under 900 KB — host larger images and pass `image_url`
            instead. Provide exactly one of `image_url` or `image_base64`.
          example: iVBORw0KGgoAAAANSUhEUgAA...
    UpdateAgentPromptEvent:
      type: object
      required:
        - event
        - agent_prompt
      properties:
        event:
          type: string
          const: update-agent-prompt
          default: update-agent-prompt
          description: update-agent-prompt
        agent_prompt:
          type: string
          description: >-
            A high-level system prompt that subtly influences the avatar's
            expressions while speaking.
          example: a person talking
    UpdateIdlePromptEvent:
      type: object
      required:
        - event
        - idle_prompt
      properties:
        event:
          type: string
          const: update-idle-prompt
          default: update-idle-prompt
          description: update-idle-prompt
        idle_prompt:
          type: string
          description: >-
            A high-level system prompt that subtly influences the avatar's
            expressions during the idle state.
          example: a serious person
    PoseTriggerEvent:
      type: object
      required:
        - event
        - pose_trigger
      properties:
        event:
          type: string
          const: pose-trigger
          default: pose-trigger
          description: pose-trigger
        pose_trigger:
          type: object
          required:
            - name
          properties:
            name:
              type: string
              description: Name of action to trigger.
              example: wave
    ResetIdleTimeoutEvent:
      type: object
      required:
        - event
      properties:
        event:
          type: string
          const: reset-idle-timeout
          default: reset-idle-timeout
          description: reset-idle-timeout
    Error:
      type: object
      properties:
        detail:
          type: string
    ServerError:
      type: object
      properties:
        detail:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your LemonSlice API token.

````