[PL] Bob [PL] Office 168/52 developer documentation

[PL] API reference, webhooks, and the embeddable widget for Bobโ€”your governed AI front office.

[PL] ๐Ÿ” Authentication

POST /api/auth/login
[PL] Authenticate admin users and obtain access token
{
  "email": "admin@office16852.com",
  "password": "your_password"
}
POST /api/customers/auth/login
[PL] Authenticate customer users (multi-tenant)
{
  "email": "customer@business.com",
  "password": "customer_password"
}

[PL] ๐Ÿ’ฌ Chat & Conversations

[PL] Three paths: [PL] (1) [PL] Public same-origin anonymous โ†’ POST /api/chat [PL] (e.g. marketing site widget; no login). (2) [PL] Cross-origin embed โ†’ POST /api/widget/chat [PL] with X-Widget-Key [PL] and allowed Origin[PL] . (3) [PL] Authenticated app / Mission Control โ†’ POST /api/chat/session [PL] and POST /api/chat/message [PL] (requires chat.manage [PL] and session/CSRF for cookie auth) โ€” [PL] not [PL] for anonymous fetch [PL] from public pages.

[PL] 1) Public anonymous (same-origin)

POST /api/chat
[PL] Unified pipeline for visitors on your own domain without signing in. Body includes message, session_id[PL] , optional business_id.

[PL] 2) Cross-origin widget

POST /api/widget/chat
[PL] Embeds on customer sites. Headers: X-Widget-Key, Content-Type: application/json. Origin [PL] must be allowed for the key. See docs/REQUEST_FLOWS.md [PL] in the repository for CORS details.

[PL] 3) Authenticated session / admin UI only

POST /api/chat/session
[PL] Create session when logged into Mission Control or dashboard (RBAC + CSRF for cookies).
POST /api/chat/message
[PL] Send a message from [PL] authenticated [PL] admin/chat UI (chat.manage[PL] ). Returns 401 [PL] if called anonymously from a public page โ€” use POST /api/chat [PL] for that case instead.
{
  "session_id": "session_123",
  "message": "Hello, I need help with my order"
}
GET /api/chat/history/:session_id
[PL] Retrieve chat conversation history (authenticated)

[PL] ๐Ÿ“Š Analytics & Monitoring

GET /api/analytics/overview
[PL] Get system analytics overview
GET /api/health
[PL] Check system health status
GET /api/metrics/business
[PL] Get business-specific metrics

[PL] ๐Ÿข Multi-Tenant Customer Management

GET /api/customers/dashboard/:businessId
[PL] Get customer dashboard data for specific business
GET /api/customers/analytics/:businessId
[PL] Get business analytics for specific customer
GET /api/customers/integration/:businessId/status
[PL] Check integration status for business

[PL] ๐ŸŽฏ UnityXpressions Pilot

GET /api/unityxpressions/dashboard
[PL] UnityXpressions pilot dashboard data
GET /api/pilot/metrics/realtime
[PL] Real-time pilot performance metrics
GET /api/pilot/feedback/recent
[PL] Recent customer feedback from pilot

[PL] ๐ŸŽ“ Training & Learning

POST /api/training/unityxpressions/analyze
[PL] Analyze UnityXpressions business for training
POST /api/training/unityxpressions/quick-setup
[PL] Quick setup training for UnityXpressions
GET /api/learning/health
[PL] Learning engine health status

[PL] ๐Ÿ”Œ Widget Installation

[PL] Add Bob to any website with a single script tag. After onboarding, your widget embed code is available in the Customer Portal under [PL] Widget Setup.

<!-- Paste before </body> -->
<script
  src="https://your-domain.com/widget/loader.js"
  data-widget-key="YOUR_WIDGET_KEY"
  data-position="bottom-right"
  async>
</script>
GET /api/customer-portal/widget-code
[PL] Returns ready-to-paste embed code for your website. Requires customer JWT.

[PL] ๐ŸŽญ Persona Customization

[PL] Personas control how Bob communicates โ€” tone, name, and system instructions. Every tenant gets a default persona on signup; you can customize it from the Admin Dashboard or the API.

GET /api/personas/:tenantId
[PL] List all personas for a tenant.
POST /api/personas/:tenantId
[PL] Create a new persona. Body: { name, description, tone, systemPrompt }
PUT /api/personas/:tenantId/:personaId
[PL] Update an existing persona's tone, instructions, or name.

[PL] ๐Ÿ’ฐ Plans & Pricing

[PL] Published pricebook is the source of truth. Use the APIs below for live numbers; this table matches pricebook-seed [PL] V1 (adjusts when you publish a new version).

[PL] Feature [PL] Starter [PL] Pro [PL] Enterprise
[PL] List price (USD/mo) [PL] $79 [PL] $249 [PL] $899
[PL] Included AI credits / mo [PL] 15,000 [PL] 75,000 [PL] 250,000
[PL] Team seats [PL] Up to 3 [PL] Up to 10 [PL] Unlimited
[PL] Standard integrations (included) 1 3 10
[PL] Support [PL] Email [PL] Priority [PL] Dedicated
GET /api/pricing/marketing-cards
[PL] Plan cards for marketing and checkout UI (prices, credits, estimates)โ€”derived from the published pricebook. No authentication required.
GET /api/pricing/snapshot
[PL] Public-safe full pricebook snapshot (no provider cost fields). No authentication required.

[PL] ๐Ÿ› ๏ธ Integration Examples

[PL] Use the block that matches your scenario. Do not copy the admin example into anonymous marketing HTML.

[PL] Public same-origin (anonymous)

const response = await fetch('/api/chat', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    session_id: sessionId,
    message: userMessage,
    business_id: 'office16852-platform'
  })
});
const data = await response.json();

[PL] Cross-origin widget

const response = await fetch('https://office16852.com/api/widget/chat', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Widget-Key': 'pk_live_...',
    'Origin': 'https://your-customer-site.com'
  },
  body: JSON.stringify({ session_id: sessionId, message: userMessage })
});

[PL] Authenticated admin only (Bearer)

// JavaScript โ€” requires logged-in admin / Mission Control (Bearer)
const response = await fetch('/api/chat/message', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + token
  },
  body: JSON.stringify({
    session_id: sessionId,
    message: userMessage
  })
});
const data = await response.json();
// Python โ€” authenticated only
import requests
response = requests.post(
    'https://office16852.com/api/chat/message',
    headers={
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {token}'
    },
    json={ 'session_id': session_id, 'message': user_message }
)