{"openapi":"3.0.0","info":{"title":"Templates Microservice API","version":"1.0.0","description":"API for managing medical templates, sections, categories, and tags with multi-language support."},"servers":[{"url":"/","description":"Current server"}],"tags":[{"name":"Templates","description":"Template CRUD operations"},{"name":"Default Templates","description":"System and per-user default template management"},{"name":"Template Sections","description":"Manage sections within templates"},{"name":"Sections","description":"Standalone section operations"},{"name":"Categories","description":"Category management"},{"name":"Tags","description":"Tag management"},{"name":"Favorites","description":"User favorite templates"},{"name":"Analytics","description":"Usage analytics and tracking"},{"name":"Admin Analytics","description":"System-wide analytics for administrators"},{"name":"Languages","description":"Supported languages"},{"name":"User","description":"Current user information"}],"components":{"schemas":{"UUID":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"LanguageCode":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"TemplateResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for the template","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_id":{"type":"string","format":"uuid","description":"UUID of the owner. Can be a user ID or organization ID depending on owner_type.","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"description":"user: owned by an individual user. organization: owned by an organization and shared with all members."},"created_by":{"type":"string","format":"uuid","description":"User who originally created this template (for attribution/audit).","example":"550e8400-e29b-41d4-a716-446655440000"},"updated_by":{"type":"string","nullable":true,"format":"uuid","description":"User who last updated this template","example":"550e8400-e29b-41d4-a716-446655440000"},"status":{"type":"string","enum":["draft","published","archived"],"description":"draft: work in progress. published: active and visible. archived: soft-deleted, hidden from listings."},"visibility":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"emrTemplateId":{"type":"integer","nullable":true,"minimum":0,"exclusiveMinimum":true,"description":"Optional BIGINT linking to an EMR system template"},"created_at":{"type":"string","format":"date-time","description":"Timestamp when the template was created"},"updated_at":{"type":"string","format":"date-time","description":"Timestamp when the template was last modified"},"translations":{"type":"array","items":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"title":{"type":"string"},"description":{"type":"string","nullable":true},"ai_guidance":{"type":"string","nullable":true}},"required":["language_code","title","description","ai_guidance"]},"description":"All available translations for this template. Use ?language= to filter to templates that have a specific language."},"categories":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"name":{"type":"string"},"description":{"type":"string","nullable":true}},"required":["id","name","description"]},"description":"Categories this template belongs to (e.g., 'Cardiology', 'General Medicine')"},"tags":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"name":{"type":"string"},"color":{"type":"string","nullable":true,"description":"Hex color code for UI display (e.g., '#ef4444')"}},"required":["id","name","color"]},"description":"Tags for filtering/organizing templates (e.g., 'urgent', 'follow-up')"},"is_favorited":{"type":"boolean","description":"Whether the current user has favorited this template"},"sections":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Template-section junction ID","example":"550e8400-e29b-41d4-a716-446655440000"},"section_id":{"type":"string","format":"uuid","description":"The section's own ID","example":"550e8400-e29b-41d4-a716-446655440000"},"display_order":{"type":"number","description":"Position in the template (0-indexed)"},"output_format":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"description":"Output format for sections. free_text: open-ended text input. bullet_points: list of items. structured_fields: predefined fields with specific types."},"status":{"type":"string","enum":["draft","active","archived"],"description":"draft: work in progress. active: available for use in templates. archived: no longer available."},"specialty":{"type":"string","nullable":true,"description":"Medical specialty"},"created_by":{"type":"string","format":"uuid","description":"User who created the section","example":"550e8400-e29b-41d4-a716-446655440000"},"translations":{"type":"array","items":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"name":{"type":"string","description":"Localized section name"},"description":{"type":"string","nullable":true,"description":"Localized description"},"ai_guidance":{"type":"string","nullable":true,"description":"Instructions for AI when processing this section"}},"required":["language_code","name","description","ai_guidance"]},"description":"Section translations"},"fields":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"field_type":{"type":"string","description":"Type of input (text, number, date, time, duration, number_scale)"},"unit_of_measure":{"type":"string","nullable":true,"description":"Unit for numeric fields (e.g., 'mmHg', 'kg')"},"display_order":{"type":"number","description":"Position in the section (0-indexed)"},"is_required":{"type":"boolean","description":"Whether this field must be filled"},"min_value":{"type":"number","nullable":true,"description":"Minimum allowed value for numeric fields"},"max_value":{"type":"number","nullable":true,"description":"Maximum allowed value for numeric fields"},"translations":{"type":"array","items":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"name":{"type":"string","description":"Localized field label"},"description":{"type":"string","nullable":true,"description":"Help text or additional context"}},"required":["language_code","name","description"]}}},"required":["id","field_type","unit_of_measure","display_order","is_required","min_value","max_value","translations"]},"description":"Field definitions for structured_fields output format"}},"required":["id","section_id","display_order","output_format","status","specialty","created_by","translations","fields"]},"description":"Sections attached to this template with their translations and fields. Included in single template GET responses."}},"required":["id","owner_id","owner_type","created_by","updated_by","status","visibility","created_at","updated_at","translations","categories","tags","is_favorited"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","owner_id":"660e8400-e29b-41d4-a716-446655440001","owner_type":"user","created_by":"660e8400-e29b-41d4-a716-446655440001","updated_by":null,"status":"published","visibility":"public","created_at":"2024-01-15T10:30:00Z","updated_at":"2024-01-20T14:45:00Z","translations":[{"language_code":"en","title":"General Medical Consultation","description":"A comprehensive template for general medical consultations","ai_guidance":"Focus on patient history and symptoms"},{"language_code":"de","title":"Allgemeine medizinische Beratung","description":"Eine umfassende Vorlage für allgemeine medizinische Beratungen","ai_guidance":"Konzentrieren Sie sich auf die Patientengeschichte und Symptome"}],"categories":[{"id":"880e8400-e29b-41d4-a716-446655440003","name":"General Medicine","description":"General medical templates"}],"tags":[{"id":"990e8400-e29b-41d4-a716-446655440004","name":"consultation","color":"#3b82f6"}],"is_favorited":false,"sections":[{"id":"aa0e8400-e29b-41d4-a716-446655440005","section_id":"bb0e8400-e29b-41d4-a716-446655440006","display_order":0,"output_format":"free_text","status":"active","specialty":null,"created_by":"660e8400-e29b-41d4-a716-446655440001","translations":[{"language_code":"en","name":"Anamnesis","description":"Patient history section","ai_guidance":"Extract chief complaint, history of present illness, and relevant past medical history"}],"fields":[]}]}},"CategoryResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","description","created_at"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","name":"Cardiology","description":"Templates related to cardiac care and heart conditions","created_at":"2024-01-15T10:30:00Z"}},"TagResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"name":{"type":"string"},"color":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","color","created_at"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","name":"urgent","color":"#ef4444","created_at":"2024-01-15T10:30:00Z"}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"},"details":{"type":"object","additionalProperties":{"nullable":true}}},"required":["error"],"example":{"error":"Resource not found","code":"NOT_FOUND","details":{"resource":"template","id":"550e8400-e29b-41d4-a716-446655440000"}}},"SectionResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for the section","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_id":{"type":"string","format":"uuid","description":"UUID of the owner. Can be a user ID or organization ID depending on owner_type.","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"description":"user: owned by individual. organization: owned by org."},"created_by":{"type":"string","format":"uuid","description":"User who originally created this section (for attribution/audit).","example":"550e8400-e29b-41d4-a716-446655440000"},"output_format":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"description":"How content should be structured. structured_fields requires field definitions."},"visibility":{"type":"string","enum":["private","organization","public"],"description":"Who can see and use this section"},"status":{"type":"string","enum":["draft","active","archived"],"description":"draft: in progress. active: available for use. archived: hidden."},"specialty":{"type":"string","nullable":true,"description":"Medical specialty this section is designed for (e.g., 'Cardiology', 'Pediatrics')"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"translations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"language_code":{"type":"string","description":"ISO language code"},"name":{"type":"string","description":"Localized section name"},"description":{"type":"string","nullable":true,"description":"Localized description"},"ai_guidance":{"type":"string","nullable":true,"description":"Instructions for AI when processing this section"}},"required":["id","language_code","name","description","ai_guidance"]},"description":"Localized content. At least one translation required."},"fields":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"field_type":{"type":"string","description":"Type of input (text, number, date, time, duration, number_scale)"},"unit_of_measure":{"type":"string","nullable":true,"description":"Unit for numeric fields (e.g., 'mmHg', 'kg', 'bpm')"},"display_order":{"type":"number","description":"Position in the section (0-indexed)"},"is_required":{"type":"boolean","description":"Whether this field must be filled"},"min_value":{"type":"number","nullable":true,"description":"Minimum allowed value for numeric fields"},"max_value":{"type":"number","nullable":true,"description":"Maximum allowed value for numeric fields"},"translations":{"type":"array","items":{"type":"object","properties":{"language_code":{"type":"string"},"name":{"type":"string","description":"Localized field label"},"description":{"type":"string","nullable":true,"description":"Help text or additional context"}},"required":["language_code","name","description"]}}},"required":["id","field_type","unit_of_measure","display_order","is_required","min_value","max_value","translations"]},"description":"Field definitions for structured_fields output format"}},"required":["id","owner_id","owner_type","created_by","output_format","visibility","status","specialty","created_at","updated_at","translations"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","owner_id":"660e8400-e29b-41d4-a716-446655440001","owner_type":"user","created_by":"660e8400-e29b-41d4-a716-446655440001","output_format":"structured_fields","visibility":"public","status":"active","specialty":"Cardiology","created_at":"2024-01-15T10:30:00Z","updated_at":"2024-01-20T14:45:00Z","translations":[{"id":"770e8400-e29b-41d4-a716-446655440002","language_code":"en","name":"Vital Signs","description":"Patient vital signs section","ai_guidance":null}],"fields":[{"id":"880e8400-e29b-41d4-a716-446655440003","field_type":"number","unit_of_measure":"mmHg","display_order":1,"is_required":true,"min_value":60,"max_value":200,"translations":[{"language_code":"en","name":"Blood Pressure","description":null}]}]}},"AnalyticsOverview":{"type":"object","properties":{"total_templates":{"type":"number"},"total_sections":{"type":"number"},"total_views":{"type":"number"},"total_copies":{"type":"number"},"templates_by_status":{"type":"object","additionalProperties":{"type":"number"}},"recent_activity":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"views":{"type":"number"},"copies":{"type":"number"}},"required":["date","views","copies"]}}},"required":["total_templates","total_sections","total_views","total_copies","templates_by_status","recent_activity"],"example":{"total_templates":25,"total_sections":87,"total_views":1250,"total_copies":340,"templates_by_status":{"draft":5,"published":18,"archived":2},"recent_activity":[{"date":"2024-01-20","views":45,"copies":12},{"date":"2024-01-19","views":38,"copies":8}]}},"TemplateAnalytics":{"type":"object","properties":{"template_id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"total_views":{"type":"number"},"total_copies":{"type":"number"},"total_exports":{"type":"number"},"total_downloads":{"type":"number"},"daily_stats":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"views":{"type":"number"},"copies":{"type":"number"},"exports":{"type":"number"},"downloads":{"type":"number"}},"required":["date","views","copies","exports","downloads"]}}},"required":["template_id","total_views","total_copies","total_exports","total_downloads","daily_stats"],"example":{"template_id":"550e8400-e29b-41d4-a716-446655440000","total_views":523,"total_copies":89,"total_exports":34,"total_downloads":12,"daily_stats":[{"date":"2024-01-20","views":25,"copies":5,"exports":2,"downloads":1}]}},"PopularTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"title":{"type":"string"},"total_usage":{"type":"number"},"view_count":{"type":"number"},"copy_count":{"type":"number"}},"required":["id","title","total_usage","view_count","copy_count"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","title":"General Medical Consultation","total_usage":612,"view_count":523,"copy_count":89}},"Language":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string"},"native_name":{"type":"string"}},"required":["code","name","native_name"],"example":{"code":"en","name":"English","native_name":"English"}},"UserInfo":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"organization_id":{"type":"string","nullable":true,"format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"roles":{"type":"array","items":{"type":"string"}}},"required":["user_id","organization_id","roles"],"example":{"user_id":"550e8400-e29b-41d4-a716-446655440000","organization_id":"660e8400-e29b-41d4-a716-446655440001","roles":["admin","template_creator"]}},"SuccessMessage":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"],"example":{"message":"Operation completed successfully"}},"FavoriteResponse":{"type":"object","properties":{"message":{"type":"string"},"is_favorite":{"type":"boolean"}},"required":["message","is_favorite"],"example":{"message":"Template added to favorites","is_favorite":true}},"PaginatedTemplates":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TemplateResponse"}},"pagination":{"type":"object","properties":{"page":{"type":"number"},"limit":{"type":"number"},"total":{"type":"number"},"total_pages":{"type":"number"}},"required":["page","limit","total","total_pages"]}},"required":["data","pagination"]},"PaginatedSections":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SectionResponse"}},"pagination":{"type":"object","properties":{"page":{"type":"number"},"limit":{"type":"number"},"total":{"type":"number"},"total_pages":{"type":"number"}},"required":["page","limit","total","total_pages"]}},"required":["data","pagination"]},"PaginatedCategories":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CategoryResponse"}},"pagination":{"type":"object","properties":{"page":{"type":"number"},"limit":{"type":"number"},"total":{"type":"number"},"total_pages":{"type":"number"}},"required":["page","limit","total","total_pages"]}},"required":["data","pagination"]},"PaginatedTags":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TagResponse"}},"pagination":{"type":"object","properties":{"page":{"type":"number"},"limit":{"type":"number"},"total":{"type":"number"},"total_pages":{"type":"number"}},"required":["page","limit","total","total_pages"]}},"required":["data","pagination"]},"PaginatedPopular":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PopularTemplate"}},"pagination":{"type":"object","properties":{"page":{"type":"number"},"limit":{"type":"number"},"total":{"type":"number"},"total_pages":{"type":"number"}},"required":["page","limit","total","total_pages"]}},"required":["data","pagination"]},"DefaultTemplateResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"template_id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"user_id":{"type":"string","nullable":true},"source":{"type":"string","enum":["system","user"],"description":"system: global default set by admin. user: personal override set by the user."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"template":{"allOf":[{"$ref":"#/components/schemas/TemplateResponse"},{"description":"Full template object (included when requested)"}]}},"required":["id","language_code","template_id","user_id","source","created_at","updated_at"],"example":{"id":"550e8400-e29b-41d4-a716-446655440000","language_code":"en","template_id":"660e8400-e29b-41d4-a716-446655440001","user_id":null,"source":"system","created_at":"2024-01-15T10:30:00Z","updated_at":"2024-01-15T10:30:00Z"}},"DefaultTemplateDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/DefaultTemplateResponse"}},"required":["data"]},"DefaultTemplateArrayResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/DefaultTemplateResponse"}}},"required":["data"]},"TemplateDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TemplateResponse"}},"required":["data"]},"SectionDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SectionResponse"}},"required":["data"]},"CategoryDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CategoryResponse"}},"required":["data"]},"TagDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TagResponse"}},"required":["data"]},"LanguagesArrayResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Language"}}},"required":["data"]},"TemplateSectionsResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"section":{"$ref":"#/components/schemas/SectionResponse"},"display_order":{"type":"number"},"is_required":{"type":"boolean"},"custom_ai_guidance":{"type":"string","nullable":true},"emrSectionId":{"type":"string","nullable":true,"format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["id","section","display_order","is_required","custom_ai_guidance"]}}},"required":["data"]},"SectionsArrayResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SectionResponse"}}},"required":["data"]},"AnalyticsOverviewDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AnalyticsOverview"}},"required":["data"]},"TemplateAnalyticsDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TemplateAnalytics"}},"required":["data"]},"UserInfoDataResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UserInfo"}},"required":["data"]},"AdminAnalyticsUserActivity":{"type":"object","properties":{"active_users":{"type":"number","description":"Unique users with activity in period"},"templates_created":{"type":"number"},"templates_published":{"type":"number"},"sections_created":{"type":"number"},"duplications":{"type":"number"},"total_sessions":{"type":"number"},"avg_session_duration_seconds":{"type":"number"}},"required":["active_users","templates_created","templates_published","sections_created","duplications","total_sessions","avg_session_duration_seconds"]},"AdminAnalyticsPainPoints":{"type":"object","properties":{"abandoned_sessions":{"type":"number","description":"Sessions marked as abandoned"},"errors_by_type":{"type":"object","additionalProperties":{"type":"number"},"description":"Error counts grouped by error code"},"total_errors":{"type":"number"},"long_sessions_over_30min":{"type":"number","description":"Sessions over 30 minutes - potential struggle indicator"},"stale_draft_templates":{"type":"number","description":"Draft templates with no updates in 7+ days"}},"required":["abandoned_sessions","errors_by_type","total_errors","long_sessions_over_30min","stale_draft_templates"]},"AdminAnalyticsFeatureUsage":{"type":"object","properties":{"section_formats":{"type":"object","additionalProperties":{"type":"number"},"description":"Section counts by output_format"},"templates_with_translations":{"type":"number"},"multi_language_templates":{"type":"number","description":"Templates with 2+ languages"},"visibility_distribution":{"type":"object","additionalProperties":{"type":"number"},"description":"Template counts by visibility"},"owner_type_distribution":{"type":"object","additionalProperties":{"type":"number"},"description":"Template counts by owner_type"}},"required":["section_formats","templates_with_translations","multi_language_templates","visibility_distribution","owner_type_distribution"]},"AdminAnalyticsContentQuality":{"type":"object","properties":{"avg_sections_per_template":{"type":"number"},"sections_reused_in_multiple_templates":{"type":"number"},"templates_duplicated_by_users":{"type":"number"},"templates_favorited":{"type":"number"}},"required":["avg_sections_per_template","sections_reused_in_multiple_templates","templates_duplicated_by_users","templates_favorited"]},"AdminAnalyticsDashboard":{"type":"object","properties":{"period":{"type":"object","properties":{"start_date":{"type":"string","format":"date"},"end_date":{"type":"string","format":"date"}},"required":["start_date","end_date"]},"user_activity":{"$ref":"#/components/schemas/AdminAnalyticsUserActivity"},"pain_points":{"$ref":"#/components/schemas/AdminAnalyticsPainPoints"},"feature_usage":{"$ref":"#/components/schemas/AdminAnalyticsFeatureUsage"},"content_quality":{"$ref":"#/components/schemas/AdminAnalyticsContentQuality"}},"required":["period"]},"AdminDailyMetrics":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"date":{"type":"string","format":"date"},"total_events":{"type":"number"},"unique_users":{"type":"number"},"templates_created":{"type":"number"},"templates_published":{"type":"number"},"sections_created":{"type":"number"},"avg_session_duration_seconds":{"type":"number","nullable":true},"error_count":{"type":"number"},"metrics_json":{"type":"object","nullable":true,"additionalProperties":{"nullable":true},"description":"Additional metrics stored as JSON"},"created_at":{"type":"string","format":"date-time"}},"required":["id","date","total_events","unique_users","templates_created","templates_published","sections_created","avg_session_duration_seconds","error_count","metrics_json","created_at"]},"AdminDailyMetricsResponse":{"type":"object","properties":{"period":{"type":"object","properties":{"start_date":{"type":"string","format":"date"},"end_date":{"type":"string","format":"date"}},"required":["start_date","end_date"]},"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminDailyMetrics"}}},"required":["period","data"]},"InlineCategory":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"example":"Cardiology"},"description":{"type":"string","maxLength":500}},"required":["name"]},"InlineTag":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":50,"example":"urgent"},"color":{"type":"string","maxLength":20,"example":"#ff0000"}},"required":["name"]},"SectionTranslationInput":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"name":{"type":"string","minLength":1,"maxLength":50,"example":"Patient History"},"description":{"type":"string","maxLength":500},"ai_guidance":{"type":"string","maxLength":5000}},"required":["language_code","name"]},"FieldTranslationInput":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"name":{"type":"string","minLength":1,"maxLength":100,"example":"Blood Pressure"},"description":{"type":"string","maxLength":500}},"required":["language_code","name"]},"InlineField":{"type":"object","properties":{"field_type":{"type":"string","enum":["text","number","date","time","duration","number_scale"],"description":"Field type for structured fields. Determines input validation and UI rendering."},"unit_of_measure":{"type":"string","maxLength":20,"example":"mmHg"},"display_order":{"type":"integer","minimum":0},"is_required":{"type":"boolean","default":false},"min_value":{"type":"number"},"max_value":{"type":"number"},"translations":{"type":"array","items":{"$ref":"#/components/schemas/FieldTranslationInput"},"minItems":1}},"required":["field_type","translations"]},"InlineSection":{"type":"object","properties":{"output_format":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"default":"free_text","description":"Output format for sections. free_text: open-ended text input. bullet_points: list of items. structured_fields: predefined fields with specific types."},"visibility":{"type":"string","enum":["private","organization","public"],"default":"private","description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"specialty":{"type":"string","maxLength":100},"translations":{"type":"array","items":{"$ref":"#/components/schemas/SectionTranslationInput"},"minItems":1},"fields":{"type":"array","items":{"$ref":"#/components/schemas/InlineField"},"description":"Fields for structured_fields output format"},"display_order":{"type":"integer","minimum":0,"description":"Position in template. Auto-assigned if not provided."},"emrSectionId":{"type":"string","format":"uuid","description":"Optional UUID linking to an EMR system section","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["translations"],"description":"Create a new section inline when creating/updating a template","example":{"output_format":"free_text","translations":[{"language_code":"en","name":"Patient History","ai_guidance":"Collect comprehensive patient history including symptoms, duration, and severity"}]}},"TemplateTranslationInput":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"title":{"type":"string","minLength":1,"maxLength":200,"example":"Medical Consultation Template"},"description":{"type":"string","maxLength":1000,"example":"A template for general medical consultations"},"ai_guidance":{"type":"string","maxLength":5000}},"required":["language_code","title"]},"CreateTemplateRequest":{"type":"object","properties":{"owner_id":{"type":"string","format":"uuid","description":"Owner ID (user or org). Defaults to current user if not provided.","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"default":"user","description":"Type of owner: 'user' or 'organization'"},"status":{"type":"string","enum":["draft","published","archived"],"default":"draft","description":"draft: work in progress. published: active and visible. archived: soft-deleted, hidden from listings."},"visibility":{"type":"string","enum":["private","organization","public"],"default":"private","description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"emrTemplateId":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Optional BIGINT linking to an EMR system template"},"category_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"description":"Existing category IDs to link"},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"description":"Existing tag IDs to link"},"section_ids":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Existing section ID to attach","example":"550e8400-e29b-41d4-a716-446655440000"},"display_order":{"type":"integer","minimum":0,"description":"Position in template"},"emrSectionId":{"type":"string","format":"uuid","description":"Optional UUID linking to an EMR system section","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["id"]},"description":"Existing section IDs to attach with optional display order"},"categories":{"type":"array","items":{"$ref":"#/components/schemas/InlineCategory"},"description":"Create new categories inline"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/InlineTag"},"description":"Create new tags inline"},"sections":{"type":"array","items":{"$ref":"#/components/schemas/InlineSection"},"description":"Create new sections inline. Sections are owned by the template creator."},"translations":{"type":"array","items":{"$ref":"#/components/schemas/TemplateTranslationInput"},"minItems":1},"session_duration_seconds":{"type":"integer","minimum":0,"description":"Time spent creating this template (tracked by frontend)"}},"required":["translations"]},"UpdateTemplateRequest":{"type":"object","properties":{"owner_id":{"type":"string","format":"uuid","description":"Transfer ownership to another user or org","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"description":"Change owner type (requires owner_id)"},"status":{"type":"string","enum":["draft","published","archived"],"description":"draft: work in progress. published: active and visible. archived: soft-deleted, hidden from listings."},"visibility":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"emrTemplateId":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Optional BIGINT linking to an EMR system template"},"category_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"}},"section_ids":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Existing section ID to attach","example":"550e8400-e29b-41d4-a716-446655440000"},"display_order":{"type":"integer","minimum":0,"description":"Position in template"},"emrSectionId":{"type":"string","format":"uuid","description":"Optional UUID linking to an EMR system section","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["id"]},"description":"Replace all sections with these existing section IDs"},"categories":{"type":"array","items":{"$ref":"#/components/schemas/InlineCategory"}},"tags":{"type":"array","items":{"$ref":"#/components/schemas/InlineTag"}},"sections":{"type":"array","items":{"$ref":"#/components/schemas/InlineSection"},"description":"Create new sections inline and attach to template"},"translations":{"type":"array","items":{"$ref":"#/components/schemas/TemplateTranslationInput"}},"session_duration_seconds":{"type":"integer","minimum":0,"description":"Time spent editing this template (tracked by frontend)"}}},"ShareTemplateRequest":{"type":"object","properties":{"visibility":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."}},"required":["visibility"]},"AddSectionToTemplateRequest":{"type":"object","properties":{"section_id":{"type":"string","format":"uuid","description":"Section ID to add to template","example":"550e8400-e29b-41d4-a716-446655440000"},"display_order":{"type":"integer","minimum":0,"description":"Position in template. Auto-assigned if not provided."},"emrSectionId":{"type":"string","format":"uuid","description":"Optional UUID linking to an EMR system section","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["section_id"]},"ReorderSectionsRequest":{"type":"object","properties":{"section_order":{"type":"array","items":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"description":"Ordered array of section IDs"}},"required":["section_order"]},"UpdateTemplateSectionRequest":{"type":"object","properties":{"display_order":{"type":"integer","description":"Display order in template"}}},"FieldInput":{"type":"object","properties":{"field_type":{"type":"string","enum":["text","number","date","time","duration","number_scale"],"description":"Field type for structured fields. Determines input validation and UI rendering."},"unit_of_measure":{"type":"string","maxLength":20,"example":"mmHg"},"display_order":{"type":"integer","minimum":0},"is_required":{"type":"boolean","default":false},"min_value":{"type":"number"},"max_value":{"type":"number"},"translations":{"type":"array","items":{"$ref":"#/components/schemas/FieldTranslationInput"},"minItems":1}},"required":["field_type","translations"]},"CreateSectionRequest":{"type":"object","properties":{"owner_id":{"type":"string","format":"uuid","description":"Owner ID (user or org). Defaults to current user if not provided.","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"default":"user","description":"Type of owner: 'user' or 'organization'"},"output_format":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"description":"Output format for sections. free_text: open-ended text input. bullet_points: list of items. structured_fields: predefined fields with specific types."},"visibility":{"type":"string","enum":["private","organization","public"],"default":"private","description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"specialty":{"type":"string","maxLength":100},"translations":{"type":"array","items":{"$ref":"#/components/schemas/SectionTranslationInput"},"minItems":1},"fields":{"type":"array","items":{"$ref":"#/components/schemas/FieldInput"}}},"required":["output_format","translations"]},"UpdateFieldInput":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"If provided, update existing field; otherwise create new","example":"550e8400-e29b-41d4-a716-446655440000"},"field_type":{"type":"string","enum":["text","number","date","time","duration","number_scale"],"description":"Field type for structured fields. Determines input validation and UI rendering."},"unit_of_measure":{"type":"string","maxLength":20},"display_order":{"type":"integer","minimum":0},"is_required":{"type":"boolean","default":false},"min_value":{"type":"number"},"max_value":{"type":"number"},"translations":{"type":"array","items":{"$ref":"#/components/schemas/FieldTranslationInput"},"minItems":1}},"required":["field_type","translations"]},"UpdateSectionRequest":{"type":"object","properties":{"output_format":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"description":"Output format for sections. free_text: open-ended text input. bullet_points: list of items. structured_fields: predefined fields with specific types."},"visibility":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"status":{"type":"string","enum":["draft","active","archived"],"description":"draft: work in progress. active: available for use in templates. archived: no longer available."},"specialty":{"type":"string","maxLength":100},"owner_id":{"type":"string","format":"uuid","description":"Transfer ownership to another user or organization","example":"550e8400-e29b-41d4-a716-446655440000"},"owner_type":{"type":"string","enum":["user","organization"],"description":"Change owner type (use with owner_id)"},"translations":{"type":"array","items":{"$ref":"#/components/schemas/SectionTranslationInput"}},"fields":{"type":"array","items":{"$ref":"#/components/schemas/UpdateFieldInput"},"description":"Update or create fields. Include id to update existing, omit to create new."}}},"CreateCategoryRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500}},"required":["name"]},"UpdateCategoryRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500}}},"CreateTagRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":50},"color":{"type":"string","maxLength":20}},"required":["name"]},"UpdateTagRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":50},"color":{"type":"string","maxLength":20}}},"TrackUsageRequest":{"type":"object","properties":{"action":{"type":"string","enum":["view","copy","export","download"],"description":"view: template was viewed. copy: template was duplicated. export: content was exported. download: file was downloaded."},"metadata":{"type":"object","additionalProperties":{"nullable":true}}},"required":["action"]},"SetDefaultTemplateRequest":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"description":"Language code (e.g., 'en', 'nl')","example":"en"},"template_id":{"type":"string","format":"uuid","description":"Template ID to set as default","example":"550e8400-e29b-41d4-a716-446655440000"},"user_id":{"type":"string","nullable":true,"description":"User ID for user-level override. Null or omitted for system default."}},"required":["language_code","template_id"]},"DeleteDefaultTemplateRequest":{"type":"object","properties":{"language_code":{"type":"string","minLength":2,"maxLength":5,"description":"Language code to remove default for","example":"en"},"user_id":{"type":"string","nullable":true,"description":"User ID for user-level override. Null or omitted for system default."}},"required":["language_code"]}},"parameters":{}},"paths":{"/api/v1/templates":{"get":{"tags":["Templates"],"summary":"List templates","description":"Get a paginated list of templates with optional filtering","parameters":[{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to access organization-owned templates or templates with organization visibility.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"description":"Language code for translations (e.g., 'en', 'nl')","example":"en"},"required":false,"name":"language","in":"query"},{"schema":{"type":"string","format":"uuid","description":"Filter by category ID","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"category_id","in":"query"},{"schema":{"type":"string","description":"Comma-separated tag IDs to filter by"},"required":false,"name":"tag_ids","in":"query"},{"schema":{"type":"string","enum":["draft","published","archived"],"description":"draft: work in progress. published: active and visible. archived: soft-deleted, hidden from listings."},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"required":false,"name":"visibility","in":"query"},{"schema":{"type":"string","description":"Search in template title and description"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","format":"uuid","description":"Filter by creator user ID","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"created_by","in":"query"},{"schema":{"type":"string","enum":["all","only","exclude"],"default":"all","description":"all: return all templates. only: return only favorited templates. exclude: return only non-favorited templates."},"required":false,"name":"favorite_filter","in":"query"},{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["created_at","updated_at","title"],"default":"created_at"},"required":false,"name":"sort_by","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sort_order","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"description":"Language code to use for alphabetical sorting when sort_by=title. Falls back to the first available translation if not provided.","example":"en"},"required":false,"name":"sort_language","in":"query"}],"responses":{"200":{"description":"List of templates with pagination","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedTemplates"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Templates"],"summary":"Create template","description":"Create a new template with translations. Supports inline creation of categories, tags, and sections. Use section_ids to attach existing sections, or sections to create new sections inline (owned by the creator).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTemplateRequest"}}}},"responses":{"201":{"description":"Template created successfully with attached sections","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateDataResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}":{"get":{"tags":["Templates"],"summary":"Get template by ID","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to access organization-owned templates.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"required":false,"name":"language","in":"query"}],"responses":{"200":{"description":"Template details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Templates"],"summary":"Update template","description":"Update template fields, translations, categories, tags, and sections. Use section_ids to replace sections with existing ones, or sections to create new sections inline.","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to edit organization-owned templates.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTemplateRequest"}}}},"responses":{"200":{"description":"Template updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Templates"],"summary":"Delete template","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to delete organization-owned templates.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"responses":{"200":{"description":"Template deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/duplicate":{"post":{"tags":["Templates"],"summary":"Duplicate template","description":"Create a copy of a template with all translations (as draft, private)","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to duplicate organization-owned templates.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"responses":{"201":{"description":"Template duplicated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/share":{"post":{"tags":["Templates"],"summary":"Update template visibility","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareTemplateRequest"}}}},"responses":{"200":{"description":"Visibility updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied (admin only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/sections":{"get":{"tags":["Template Sections"],"summary":"List template sections","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"required":false,"name":"language","in":"query"}],"responses":{"200":{"description":"List of sections in template","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionsArrayResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Template Sections"],"summary":"Add section to template","description":"Add existing section by ID or create new inline section","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddSectionToTemplateRequest"}}}},"responses":{"201":{"description":"Section added to template","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["Template Sections"],"summary":"Reorder template sections","description":"Reorder all sections in one call by providing ordered section IDs","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReorderSectionsRequest"}}}},"responses":{"200":{"description":"Sections reordered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/sections/{sectionId}":{"patch":{"tags":["Template Sections"],"summary":"Update section display order in template","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"sectionId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTemplateSectionRequest"}}}},"responses":{"200":{"description":"Section updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Template Sections"],"summary":"Remove section from template","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"sectionId","in":"path"}],"responses":{"200":{"description":"Section removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/favorite":{"post":{"tags":["Favorites"],"summary":"Add template to favorites","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Added to favorites","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FavoriteResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Favorites"],"summary":"Remove template from favorites","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Removed from favorites","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FavoriteResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/sections":{"get":{"tags":["Sections"],"summary":"List sections","parameters":[{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to access organization-owned sections or sections with organization visibility.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"required":false,"name":"language","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["private","organization","public"],"description":"private: only owner/admins can access. organization: all org members can access. public: anyone can view/copy."},"required":false,"name":"visibility","in":"query"},{"schema":{"type":"string","enum":["draft","active","archived"],"description":"draft: work in progress. active: available for use in templates. archived: no longer available."},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"specialty","in":"query"},{"schema":{"type":"string","enum":["free_text","bullet_points","structured_fields"],"description":"Output format for sections. free_text: open-ended text input. bullet_points: list of items. structured_fields: predefined fields with specific types."},"required":false,"name":"output_format","in":"query"},{"schema":{"type":"string","format":"uuid","description":"Filter by owner (user or organization)","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"owner_id","in":"query"},{"schema":{"type":"string","enum":["user","organization"],"description":"Filter by owner type"},"required":false,"name":"owner_type","in":"query"},{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["created_at","updated_at","name"],"default":"created_at","description":"Field to sort by. 'name' sorts alphabetically by section name from translations."},"required":false,"name":"sort_by","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sort_order","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"description":"Language code to use for alphabetical sorting when sort_by=name. Falls back to the first available translation if not provided.","example":"en"},"required":false,"name":"sort_language","in":"query"}],"responses":{"200":{"description":"List of sections","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedSections"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Sections"],"summary":"Create section","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSectionRequest"}}}},"responses":{"201":{"description":"Section created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/sections/{id}":{"get":{"tags":["Sections"],"summary":"Get section by ID","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to access organization-owned sections.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"},{"schema":{"type":"string","minLength":2,"maxLength":5,"example":"en"},"required":false,"name":"language","in":"query"}],"responses":{"200":{"description":"Section details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Section not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Sections"],"summary":"Update section","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to edit organization-owned sections.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateSectionRequest"}}}},"responses":{"200":{"description":"Section updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Section not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Sections"],"summary":"Delete section","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to delete organization-owned sections.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"responses":{"200":{"description":"Section deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Section not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/sections/{id}/duplicate":{"post":{"tags":["Sections"],"summary":"Duplicate section","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","description":"User's organization ID. Required to duplicate organization-owned sections.","example":"550e8400-e29b-41d4-a716-446655440000"},"required":false,"name":"organization_id","in":"query"}],"responses":{"201":{"description":"Section duplicated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SectionDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Section not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/categories":{"get":{"tags":["Categories"],"summary":"List categories","parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"List of categories","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedCategories"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Categories"],"summary":"Create category","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCategoryRequest"}}}},"responses":{"201":{"description":"Category created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategoryDataResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/categories/{id}":{"get":{"tags":["Categories"],"summary":"Get category by ID","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Category details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategoryDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Categories"],"summary":"Update category","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCategoryRequest"}}}},"responses":{"200":{"description":"Category updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategoryDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Categories"],"summary":"Delete category","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Category deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/tags":{"get":{"tags":["Tags"],"summary":"List tags","parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"List of tags","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedTags"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Tags"],"summary":"Create tag","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTagRequest"}}}},"responses":{"201":{"description":"Tag created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagDataResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/tags/{id}":{"get":{"tags":["Tags"],"summary":"Get tag by ID","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Tag details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Tags"],"summary":"Update tag","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTagRequest"}}}},"responses":{"200":{"description":"Tag updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Tags"],"summary":"Delete tag","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Tag deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/analytics/overview":{"get":{"tags":["Analytics"],"summary":"Get user analytics overview","parameters":[{"schema":{"type":"integer","nullable":true,"default":30,"description":"Number of days for stats"},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"Analytics overview","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyticsOverviewDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/analytics/popular":{"get":{"tags":["Analytics"],"summary":"Get popular templates","parameters":[{"schema":{"type":"integer","nullable":true,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","nullable":true,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"integer","nullable":true,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"Popular templates list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedPopular"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/analytics":{"get":{"tags":["Analytics"],"summary":"Get template analytics","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","nullable":true,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"Template analytics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateAnalyticsDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/{id}/track":{"post":{"tags":["Analytics"],"summary":"Track template usage","parameters":[{"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackUsageRequest"}}}},"responses":{"200":{"description":"Usage tracked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessage"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/admin/analytics":{"get":{"tags":["Admin Analytics"],"summary":"Get system-wide analytics dashboard","description":"Returns comprehensive analytics including user activity, pain points, feature usage, and content quality metrics. Use the metrics parameter to select which categories to include.","parameters":[{"schema":{"type":"string","format":"date","description":"Start date (YYYY-MM-DD). Defaults to 30 days ago."},"required":false,"name":"start_date","in":"query"},{"schema":{"type":"string","format":"date","description":"End date (YYYY-MM-DD). Defaults to today."},"required":false,"name":"end_date","in":"query"},{"schema":{"type":"string","description":"Comma-separated list of metric categories to include. Options: user_activity, pain_points, feature_usage, content_quality. Defaults to all.","example":"user_activity,pain_points"},"required":false,"name":"metrics","in":"query"}],"responses":{"200":{"description":"Analytics dashboard data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminAnalyticsDashboard"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/defaults":{"get":{"tags":["Default Templates"],"summary":"Resolve default template for a language","description":"Resolves the default template for a given language with fallback: user override -> system default. The `source` field in the response indicates which level the result came from.","parameters":[{"schema":{"type":"string","minLength":2,"maxLength":5,"description":"Language code to resolve default for (e.g., 'en')","example":"en"},"required":true,"name":"language","in":"query"},{"schema":{"type":"string","description":"If provided, tries user default first, falls back to system"},"required":false,"name":"user_id","in":"query"}],"responses":{"200":{"description":"Default template resolved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultTemplateDataResponse"}}}},"400":{"description":"Missing language parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"No default template found for this language","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["Default Templates"],"summary":"Set or update a default template","description":"Upsert a default template for a language. Set user_id to null or omit for system default, or provide a user_id for a user-level override.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetDefaultTemplateRequest"}}}},"responses":{"200":{"description":"Default template set","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultTemplateDataResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template or language not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Default Templates"],"summary":"Remove a default template","description":"Remove a default template for a language. Deleting a user override means the user falls back to the system default.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteDefaultTemplateRequest"}}}},"responses":{"204":{"description":"Default template removed"},"400":{"description":"Missing language_code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/templates/defaults/all":{"get":{"tags":["Default Templates"],"summary":"List all default templates","description":"List all system defaults (user_id omitted) or all of a specific user's overrides (user_id provided). Each entry includes the full template object.","parameters":[{"schema":{"type":"string","description":"If provided, returns user overrides. Omit for system defaults."},"required":false,"name":"user_id","in":"query"}],"responses":{"200":{"description":"List of default templates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultTemplateArrayResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/languages":{"get":{"tags":["Languages"],"summary":"List supported languages","responses":{"200":{"description":"List of supported languages","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LanguagesArrayResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/me":{"get":{"tags":["User"],"summary":"Get current user info","description":"Returns user information extracted from gateway headers","responses":{"200":{"description":"Current user information from gateway headers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserInfoDataResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}