Skip to main content
POST
https://api.u1.archetypeai.app/v0.5
/
lens
/
sessions
/
create
curl -X POST https://api.dev.u1.archetypeai.app/v0.5/lens/sessions/create \
  -H "Authorization: Bearer $ATAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "lens_id": "lns-fd669361822b07e2-237ab3ffd79199b0"
  }'
{
  "org_id": "A15E5AFC",
  "api_key": "YOUR_API_KEY",
  "session_id": "lsn-251207a89f948ed4e30d8f80aaba77",
  "lens_id": "lns-test-lens-b2ba0058",
  "lens_name": "Test Lens",
  "session_status": "LensSessionStatus.SESSION_STATUS_REGISTERED",
  "session_endpoint": "wss://api.dev.u1.archetypeai.app/v0.5/lens/sessions/lsn-251207a89f948ed4e30d8f80aaba77",
  "session_ttl_sec": 86400
}

Overview

This endpoint creates and allocates a new lens session that can process sensor data streams. Each session is associated with a specific lens and returns a unique session ID and endpoint for real-time data streaming.

Request

Authorization
string
required
Bearer token for authentication. Format: Bearer $ATAI_API_KEY
lens_id
string
required
The ID of the lens to use for this session. Get available lens IDs from /lens/metadata

Response

session_id
string
Unique identifier for the created session
lens_id
string
The lens ID associated with this session
session_endpoint
string
WebSocket URL for streaming data to/from the session
session_status
string
Initial status of the session (typically “LensSessionStatus.SESSION_STATUS_REGISTERED”)
errors
array
Array of error messages if the request failed (check for this field to detect errors)
curl -X POST https://api.dev.u1.archetypeai.app/v0.5/lens/sessions/create \
  -H "Authorization: Bearer $ATAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "lens_id": "lns-fd669361822b07e2-237ab3ffd79199b0"
  }'
{
  "org_id": "A15E5AFC",
  "api_key": "YOUR_API_KEY",
  "session_id": "lsn-251207a89f948ed4e30d8f80aaba77",
  "lens_id": "lns-test-lens-b2ba0058",
  "lens_name": "Test Lens",
  "session_status": "LensSessionStatus.SESSION_STATUS_REGISTERED",
  "session_endpoint": "wss://api.dev.u1.archetypeai.app/v0.5/lens/sessions/lsn-251207a89f948ed4e30d8f80aaba77",
  "session_ttl_sec": 86400
}

Important Notes

  • Sessions remain active until explicitly destroyed or timeout after no sensor activity
  • Always destroy sessions when done to free up resources
  • Check which sessions are running via /lens/sessions/metadata