# Create a new worker Creates a new worker record with automatic ID generation and optional photo upload. Key features: - Worker ID is auto-generated as INITIALS + MMDD (from hire date) - Requires JWT token authentication in the Authorization header - Company context is inferred from the authenticated user - Validates position, employment_type, and status against template options - Ensures worker_id uniqueness per company (idempotent on duplicate) - Supports photo upload via base64 data URL (JPEG, PNG, WebP up to 12MB) - Photos are uploaded to cloud storage and URL is returned in response Endpoint: POST /api/control/workers Version: 2.0.0 Security: bearerAuth ## Request fields (application/json): - `auth0Id` (string, required) User identifier (internal use, derived from JWT token) Example: "user_123456789" - `first_name` (string, required) Worker first name Example: "John" - `last_name` (string, required) Worker last name Example: "Smith" - `phone` (string) Worker phone number Example: "+1234567890" - `email` (string) Worker email address Example: "john.smith@example.com" - `position` (string, required) Worker position (must match template options) Example: "field_worker" - `employment_type` (string, required) Employment type (must match template options) Example: "full_time" - `hire_date` (string, required) Hire date in YYYY-MM-DD format (used to generate worker_id) Example: "2025-03-15" - `termination_date` (string,null) Termination date in YYYY-MM-DD format (optional) - `status` (string) Worker status (defaults to 'active') Example: "active" - `hourly_rate` (number) Hourly rate (must be >= 0) Example: 18.5 - `emergency_contact_name` (string) Emergency contact name Example: "Jane Smith" - `emergency_contact_phone` (string) Emergency contact phone number Example: "+1234567891" - `skills` (array) Array of worker skills (filtered by template options) Example: ["irrigation","pruning"] - `notes` (string) Additional notes about the worker Example: "Experienced in avocado cultivation" - `photo` (string) Worker photo in base64 data URL format (optional). Supported formats: JPEG, PNG, WebP. Maximum size: 12MB. Format: data:image/jpeg;base64,/9j/4AAQ... or data:image/png;base64,iVBORw0KG... Example: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD..." ## Response 200 fields (application/json): - `status` (string) Example: "exists" - `message` (string) Example: "worker already exists" - `data` (object) - `data.workerId` (string) Example: "6507f1e3c9d8e2a4b1f9c3d5" - `data.worker_id` (string) Example: "JS0315" ## Response 201 fields (application/json): - `status` (string) Example: "success" - `data` (object) - `data.workerId` (string) Worker unique identifier Example: "6507f1e3c9d8e2a4b1f9c3d5" - `data.worker_id` (string) Business worker ID Example: "JS0315" - `data.photoUrl` (string,null) URL of the uploaded photo (if photo was provided) Example: "https://storage.example.com/photos/worker-photo.jpg" ## Response 400 fields (application/json): - `status` (string) Example: "error" - `message` (string) Example: "Error message description" - `error` (string) Example: "Detailed error information" ## Response 401 fields (application/json): - `status` (string) Example: "error" - `message` (string) Example: "Error message description" - `error` (string) Example: "Detailed error information" ## Response 404 fields (application/json): - `status` (string) Example: "error" - `message` (string) Example: "Error message description" - `error` (string) Example: "Detailed error information" ## Response 413 fields (application/json): - `status` (string) Example: "error" - `message` (string) Example: "Error message description" - `error` (string) Example: "Detailed error information" ## Response 500 fields (application/json): - `status` (string) Example: "error" - `message` (string) Example: "Error message description" - `error` (string) Example: "Detailed error information"