DashboardSupportWelcome

👤 USER DOCS

Getting Started

Daily Operations

Shift Workspace & TasksPre-Shift SetupLine-Up CardsShift ReportsForms

Staff & Locations

Staff SchedulingManaging Locations

Oversight

Manager ReportsAnalyticsPre-Shift & Compliance

Incidents & Feedback

Incident ReportingAnonymous FeedbackMessages & Announcements

AI & Settings

AI ChatgearApp Settings

Administration

Dashboard & OnboardingAdmin

⚙️ DEVELOPER DOCS

Getting Started

Getting StartedDevelopmentDeployment Guide

Architecture

Architecture OverviewData FlowArchitecture Decision Records

Core Domain

Core DomainDatabase ReferenceLocations DomainAuth & RBACScheduling DomainReports DomainIncidents DomainNotifications DomainAudit Log & OptimizationDesign Audit Findings

Frontend

Frontend ArchitectureFormsLoading SkeletonsComponentsPWA & NotificationsimageScreenshots

API Reference

API Reference

Endpoints

POS Sales APIOptimization Data APISchedule Shifts APIEmployee Export APIReports APIIncidents APIAI Chat APIPush Notifications APIWebhooks APICron API

Contributing

ContributingcodeCode Examples

Security

Security & Compliance
Danvas IconDanvas
Danvas IconDanvas

Optimization Data API

Labor optimization metrics and goals for schedule planning

Returns weekly optimization data including sales, labor costs, and goal progress. Used for labor variance checking and schedule optimization.

Endpoints

GET /api/analytics/optimization
GET /api/analytics/goals

Query Parameters

ParameterTypeRequiredDescription
teamIdstring✅Team/organization identifier
weekOfstring✅ISO date of Saturday starting the week
locationIdstring❌Optional location filter

Optimization Response Schema

POS Sales API

Real-time sales data from Toast POS

Schedule Shifts API

Imported schedule data from external systems

On this page

EndpointsQuery ParametersOptimization Response SchemaGoals Response SchemaExample RequestExample ResponseGoals Example ResponseCache TTLClient UsageError ResponsesRelated Files
{
  weekLabel: string;
  summary: {
    totalSales: number;        // finite, nonnegative
    totalLaborCost: number;    // finite, nonnegative
    laborPct: number;          // finite
    targetLaborPct?: number;   // finite
    splh: number;              // finite
    targetSplh?: number;       // finite
  };
  salesByCategory?: Array<{   // defaults to [] if not provided
    day: string;
    block: string;
    food: number;    































Goals Response Schema

{
  goals: Array<{
    dayOfWeek: number;  // integer 0-6 (0 = Saturday)
    salesGoal: number;  // finite, nonnegative
    laborPctTarget: number; // finite, nonnegative
    splhTarget: number

Example Request

curl -X GET "https://analytics.example.com/api/analytics/optimization?teamId=team123&weekOf=2026-05-16&locationId=loc456" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

{
  "weekLabel": "May 11-17, 2026",
  "summary": {
    "totalSales": 45230.00,
    "totalLaborCost": 12500.00,
    "laborPct": 27.6,
    "splh": 142.50
  },
  "salesByCategory": [
    {
      "day": "Monday",
      "block": 




































Goals Example Response

{
  "goals": [
    {
      "dayOfWeek": 0,
      "salesGoal": 5000.00,
      "laborPctTarget": 28.0,
      "splhTarget": 135.00
    }
  ]
}

Cache TTL

  • Redis cache: 15 minutes
  • Reconfiguration: On webhook events or scheduled sync

Client Usage

import { getOptimizationData, getGoalsFromApi } from '@repo/analytics/labor-client';

// Get weekly optimization data
const optimization = await getOptimizationData({
  teamId: 'team123',
  weekOf: '2026-05-16',
  locationId: 'loc456'
});





Error Responses

StatusDescription
401Missing or invalid API key
400Invalid query parameters
503Circuit breaker open

Related Files

FilePurpose
packages/analytics/labor-client.tsClient implementation with Zod schemas
packages/analytics/labor-variance.tsLabor variance checking logic
// finite, nonnegative
beverage: number; // finite, nonnegative
other: number; // finite, nonnegative
total: number; // finite, nonnegative
}>;
laborByCategory?: Array<{ // defaults to [] if not provided
day: string;
fohHours: number; // finite, nonnegative
bohHours: number; // finite, nonnegative
naHours: number; // finite, nonnegative
totalHours: number; // finite, nonnegative
cost: number; // finite, nonnegative
pctOfSales: number; // finite
}>;
dailySummary?: Array<{ // defaults to [] if not provided
day: string;
sales: number; // finite, nonnegative
laborCost: number; // finite, nonnegative
laborPct: number; // finite
splh: number; // finite
servedGuests?: number; // integer, nonnegative
goalsMet?: boolean;
}>;
weeklySummary?: { // optional
totalSales: number; // finite, nonnegative
totalLaborCost: number; // finite, nonnegative
avgLaborPct: number; // finite
avgSplh: number; // finite
goalsMetPercent?: number;
topDay?: string;
worstDay?: string;
};
}
;
// finite, nonnegative
}>;
}
"Dinner"
,
"food": 2500.00,
"beverage": 1200.00,
"other": 300.00,
"total": 4000.00
}
],
"laborByCategory": [
{
"day": "Monday",
"fohHours": 32.5,
"bohHours": 28.0,
"naHours": 4.0,
"totalHours": 64.5,
"cost": 1800.00,
"pctOfSales": 26.5
}
],
"dailySummary": [
{
"day": "Monday",
"sales": 6500.00,
"laborCost": 1800.00,
"laborPct": 27.7,
"splh": 140.00,
"goalsMet": true
}
],
"weeklySummary": {
"totalSales": 45230.00,
"totalLaborCost": 12500.00,
"avgLaborPct": 27.6,
"avgSplh": 142.50,
"goalsMetPercent": 71.4,
"topDay": "Saturday",
"worstDay": "Tuesday"
}
}
// Get optimization goals
const goals = await getGoalsFromApi({
teamId: 'team123',
locationId: 'loc456'
});