> ## 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 base image with a new image. This resets
                    the model, so any audio currently playing will be cut off —
                    best called when the avatar is silent. The image swap takes
                    up to 5 seconds.
                - $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: Swap the avatar image
                description: Replace the avatar's base image.
                value:
                  event: update-image
                  image_url: https://example.com/avatar.jpg
              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 required for update-image event
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Session not found
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
              example:
                detail: Internal server error
      security: []
components:
  schemas:
    TerminateEvent:
      type: object
      required:
        - event
      properties:
        event:
          type: string
          const: terminate
          default: terminate
          description: terminate
    UpdateImageEvent:
      type: object
      required:
        - event
        - image_url
      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.
          example: https://example.com/avatar.jpg
    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
          example: Agent not found
    ServerError:
      type: object
      properties:
        detail:
          type: string
          example: Internal server error
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your LemonSlice API token.

````