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

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

[JA] ๐Ÿ” Authentication

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

[JA] ๐Ÿ’ฌ Chat & Conversations

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

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

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

[JA] 2) Cross-origin widget

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

[JA] 3) Authenticated session / admin UI only

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

[JA] ๐Ÿ“Š Analytics & Monitoring

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

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

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

[JA] ๐ŸŽฏ UnityXpressions Pilot

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

[JA] ๐ŸŽ“ Training & Learning

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

[JA] ๐Ÿ”Œ Widget Installation

[JA] Add Bob to any website with a single script tag. After onboarding, your widget embed code is available in the Customer Portal under [JA] 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
[JA] Returns ready-to-paste embed code for your website. Requires customer JWT.

[JA] ๐ŸŽญ Persona Customization

[JA] 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
[JA] List all personas for a tenant.
POST /api/personas/:tenantId
[JA] Create a new persona. Body: { name, description, tone, systemPrompt }
PUT /api/personas/:tenantId/:personaId
[JA] Update an existing persona's tone, instructions, or name.

[JA] ๐Ÿ’ฐ Plans & Pricing

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

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

[JA] ๐Ÿ› ๏ธ Integration Examples

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

[JA] 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();

[JA] 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 })
});

[JA] 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 }
)