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

# Session Events Process

> Sends an event to an active session to process

## Overview

This endpoint sends an event to an active session to process.

## Request

<ParamField body="session_id" type="string" required>
  The ID of the active session the event should be routed to.
</ParamField>

<ParamField body="event" type="object" required>
  The event to route to the session. Must contain a `type` field.
</ParamField>

## Response

<ResponseField name="type" type="string">
  Response type. "error" indicates a processing error occurred.
</ResponseField>

<ResponseField name="event_data" type="object">
  Event processing result or error details.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl -X POST https://api.u1.archetypeai.app/v0.5/lens/sessions/events/process \
    -H "Authorization: Bearer $ATAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "session_id": "lsn-250313c2177253cbaa7a73542edd90",
      "event": {
        "type": "image",
        "data": "base64_encoded_image_data"
      }
    }'
  ```

  ```python Python theme={"system"}
  import requests
  import os

  api_key = os.environ.get("ATAI_API_KEY")

  response = requests.post(
      "https://api.u1.archetypeai.app/v0.5/lens/sessions/events/process",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "session_id": "lsn-250313c2177253cbaa7a73542edd90",
          "event": {
              "type": "image",
              "data": "base64_encoded_image_data"
          }
      }
  )

  result = response.json()

  if result.get("type") == "error":
      print(f"Error: {result['event_data']['error_messages']}")
  elif not result:
      print("Empty response - check session_id and event parameters")
  else:
      print(f"Success: {result}")
  ```

  ```javascript JavaScript theme={"system"}
  const response = await fetch('https://api.u1.archetypeai.app/v0.5/lens/sessions/events/process', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.ATAI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      session_id: 'lsn-250313c2177253cbaa7a73542edd90',
      event: {
        type: 'image',
        data: 'base64_encoded_image_data'
      }
    })
  });

  const result = await response.json();

  if (result.type === 'error') {
    console.error('Error:', result.event_data.error_messages);
  } else if (Object.keys(result).length === 0) {
    console.log('Empty response - check session_id and event parameters');
  } else {
    console.log('Success:', result);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={"system"}
  {
    "type": "success",
    "event_data": {
      "response": "Processing result..."
    }
  }
  ```

  ```json 200 - Error: Unknown event type theme={"system"}
  {
    "type": "error",
    "event_data": {
      "is_valid": false,
      "error_messages": [
        "Unknown event type: test"
      ]
    }
  }
  ```

  ```json 200 - Error: Empty event payload theme={"system"}
  {
    "type": "error",
    "event_data": {
      "is_valid": false,
      "error_messages": [
        "Event payload is empty!"
      ]
    }
  }
  ```

  ```json 400 - Missing session_id theme={"system"}
  {
    "detail": "error"
  }
  ```

  ```json 401 - Unauthorized theme={"system"}
  {
    "errors": [
      {
        "code": "unauthorized_request",
        "message": "Unauthorized or invalid access.",
        "suggestion": "Provide valid authentication credentials and ensure they have the required permissions.",
        "error_uid": "err-xxxxxxxx"
      }
    ]
  }
  ```

  ```json 500 - Invalid event format (non-object) theme={"system"}
  Internal Server Error
  ```
</ResponseExample>
