{"openapi":"3.1.0","info":{"title":"UnderscoreStat API v1","description":"Внешние интеграции. Отдельные права ключа указаны у каждой операции.","version":"0.7.028"},"paths":{"/version":{"get":{"tags":["Сервис"],"summary":"Version Info","operationId":"version_info_version_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Version Info Version Get"}}}}}}},"/capabilities":{"get":{"tags":["Сервис"],"summary":"Capabilities View","operationId":"capabilities_view_capabilities_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"additionalProperties":true,"type":"object"},"type":"object","title":"Response Capabilities View Capabilities Get"}}}}},"security":[{"ApiKey":[]}]}},"/connections":{"get":{"tags":["connections"],"summary":"List Connections","description":"Требуется право `connections:read`.","operationId":"list_connections_connections_get","security":[{"ApiKey":[]}],"parameters":[{"name":"project_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Project Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ConnectionView"},"title":"Response List Connections Connections Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"connections:read"},"post":{"tags":["connections"],"summary":"Create Connection","description":"Требуется право `connections:write`.","operationId":"create_connection_connections_post","security":[{"ApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"connections:write"}},"/connections/{connection_id}":{"put":{"tags":["connections"],"summary":"Update Connection","description":"Требуется право `connections:write`.","operationId":"update_connection_connections__connection_id__put","security":[{"ApiKey":[]}],"parameters":[{"name":"connection_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Connection Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"connections:write"},"delete":{"tags":["connections"],"summary":"Delete Connection","description":"Требуется право `connections:write`.","operationId":"delete_connection_connections__connection_id__delete","security":[{"ApiKey":[]}],"parameters":[{"name":"connection_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Connection Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"connections:write"}},"/connections/{connection_id}/check":{"post":{"tags":["connections"],"summary":"Check Connection","description":"Требуется право `connections:write`.","operationId":"check_connection_connections__connection_id__check_post","security":[{"ApiKey":[]}],"parameters":[{"name":"connection_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Connection Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionCheckView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"connections:write"}},"/reports":{"get":{"tags":["reports"],"summary":"List Reports","description":"Требуется право `reports:read`.","operationId":"list_reports_reports_get","security":[{"ApiKey":[]}],"parameters":[{"name":"project_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Project Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ReportView"},"title":"Response List Reports Reports Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:read"},"post":{"tags":["reports"],"summary":"Create Report","description":"Требуется право `reports:write`.","operationId":"create_report_reports_post","security":[{"ApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:write"}},"/reports/{report_id}":{"put":{"tags":["reports"],"summary":"Update Report","description":"Требуется право `reports:write`.","operationId":"update_report_reports__report_id__put","security":[{"ApiKey":[]}],"parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Report Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:write"},"delete":{"tags":["reports"],"summary":"Delete Report","description":"Требуется право `reports:write`.","operationId":"delete_report_reports__report_id__delete","security":[{"ApiKey":[]}],"parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Report Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:write"},"get":{"tags":["reports"],"summary":"Get Report","operationId":"get_report_reports__report_id__get","security":[{"ApiKey":[]}],"parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Report Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:read"}},"/reports/{report_id}/schedule":{"put":{"tags":["reports"],"summary":"Update Schedule","description":"Требуется право `reports:write`.","operationId":"update_schedule_reports__report_id__schedule_put","security":[{"ApiKey":[]}],"parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Report Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScheduleWrite"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"reports:write"}},"/runs":{"get":{"tags":["runs"],"summary":"List Runs","description":"Требуется право `runs:read`.","operationId":"list_runs_runs_get","security":[{"ApiKey":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":100,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"report_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Report Id"}},{"name":"run_status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Status"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RunView"},"title":"Response List Runs Runs Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"runs:read"}},"/runs/{run_id}/export":{"post":{"tags":["runs"],"summary":"Replay Export","description":"Требуется право `runs:write`.","operationId":"replay_export_runs__run_id__export_post","security":[{"ApiKey":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Run Id"}}],"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"runs:write"}},"/analytics/datasets":{"get":{"tags":["analytics"],"summary":"List Analytics Datasets","description":"Требуется право `analytics:read`.","operationId":"list_analytics_datasets_analytics_datasets_get","security":[{"ApiKey":[]}],"parameters":[{"name":"project_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Project Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"analytics:read"}},"/runs/{run_id}":{"get":{"tags":["runs"],"summary":"Get Run","operationId":"get_run_runs__run_id__get","security":[{"ApiKey":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"runs:read"}},"/reports/{report_id}/runs":{"post":{"tags":["runs"],"summary":"Start Run","description":"Idempotency-Key — UUID. Повтор с тем же ключом и телом возвращает тот же запуск; изменение тела возвращает 409.","operationId":"start_run_reports__report_id__runs_post","security":[{"ApiKey":[]}],"parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Report Id"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","format":"uuid","title":"Idempotency-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunCreate"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"runs:write"}},"/analytics/datasets/{dataset_id}/rows":{"get":{"tags":["analytics"],"summary":"Dataset Rows","description":"Текущие сохранённые данные за период. Денежные и дробные значения — строки без потери точности. Состав полей зависит от источника.","operationId":"dataset_rows_analytics_datasets__dataset_id__rows_get","security":[{"ApiKey":[]}],"parameters":[{"name":"dataset_id","in":"path","required":true,"schema":{"type":"string","title":"Dataset Id"}},{"name":"date_from","in":"query","required":true,"schema":{"type":"string","format":"date","title":"Date From"}},{"name":"date_to","in":"query","required":true,"schema":{"type":"string","format":"date","title":"Date To"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":1000,"minimum":1,"default":100,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"x-required-scope":"analytics:read"}}},"components":{"schemas":{"ConnectionCheckView":{"properties":{"status":{"type":"string","enum":["healthy","unhealthy"],"title":"Status"},"checked_at":{"type":"string","format":"date-time","title":"Checked At"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"details":{"additionalProperties":true,"type":"object","title":"Details"}},"type":"object","required":["status","checked_at"],"title":"ConnectionCheckView"},"ConnectionCreate":{"properties":{"source":{"type":"string","enum":["direct","yandex_finance","metrika","vk","google","media_metrika","promopages","amocrm","bitrix24","avito","avito_ads","sber_ads","calltouch","clickhouse"],"title":"Source"},"project_id":{"type":"string","format":"uuid","title":"Project Id","default":"00000000-0000-4000-8000-000000000001"},"name":{"type":"string","maxLength":120,"minLength":1,"title":"Name"},"public_config":{"additionalProperties":true,"type":"object","title":"Public Config"},"secret":{"additionalProperties":true,"type":"object","title":"Secret"}},"additionalProperties":false,"type":"object","required":["source","name","secret"],"title":"ConnectionCreate"},"ConnectionUpdate":{"properties":{"name":{"type":"string","maxLength":120,"minLength":1,"title":"Name"},"public_config":{"additionalProperties":true,"type":"object","title":"Public Config"},"secret":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Secret"}},"additionalProperties":false,"type":"object","required":["name"],"title":"ConnectionUpdate","description":"Editable connection fields; credentials are optional to preserve the existing secret."},"ConnectionView":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"project_id":{"type":"string","format":"uuid","title":"Project Id"},"source":{"type":"string","title":"Source"},"name":{"type":"string","title":"Name"},"public_config":{"additionalProperties":true,"type":"object","title":"Public Config"},"health_status":{"type":"string","title":"Health Status"},"health_checked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Health Checked At"},"health_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Health Error"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","project_id","source","name","public_config","health_status","health_checked_at","health_error","created_at","updated_at"],"title":"ConnectionView"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ReportCreate":{"properties":{"project_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Project Id"},"tags":{"items":{"type":"string"},"type":"array","maxItems":12,"title":"Tags"},"name":{"type":"string","maxLength":160,"minLength":1,"title":"Name"},"source":{"type":"string","enum":["direct","yandex_finance","metrika","vk","avito_ads","media_metrika","promopages","amocrm","bitrix24","avito","calltouch","clickhouse","sber_ads"],"title":"Source"},"connection_id":{"type":"string","format":"uuid","title":"Connection Id"},"account_id":{"type":"string","maxLength":160,"minLength":1,"title":"Account Id"},"source_config":{"additionalProperties":true,"type":"object","title":"Source Config"},"destination":{"additionalProperties":true,"type":"object","title":"Destination"},"period_policy":{"additionalProperties":true,"type":"object","title":"Period Policy"},"auto_retry":{"type":"boolean","title":"Auto Retry","default":true},"schedule_change":{"anyOf":[{"$ref":"#/components/schemas/ReportScheduleChange"},{"type":"null"}]},"request_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Request Id"}},"additionalProperties":false,"type":"object","required":["name","source","connection_id","account_id","destination","period_policy"],"title":"ReportCreate"},"ReportScheduleChange":{"properties":{"enabled":{"type":"boolean","title":"Enabled"},"schedule":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Schedule"}},"additionalProperties":false,"type":"object","required":["enabled"],"title":"ReportScheduleChange"},"ReportUpdate":{"properties":{"project_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Project Id"},"tags":{"items":{"type":"string"},"type":"array","maxItems":12,"title":"Tags"},"name":{"type":"string","maxLength":160,"minLength":1,"title":"Name"},"source":{"type":"string","enum":["direct","yandex_finance","metrika","vk","avito_ads","media_metrika","promopages","amocrm","bitrix24","avito","calltouch","clickhouse","sber_ads"],"title":"Source"},"connection_id":{"type":"string","format":"uuid","title":"Connection Id"},"account_id":{"type":"string","maxLength":160,"minLength":1,"title":"Account Id"},"source_config":{"additionalProperties":true,"type":"object","title":"Source Config"},"destination":{"additionalProperties":true,"type":"object","title":"Destination"},"period_policy":{"additionalProperties":true,"type":"object","title":"Period Policy"},"auto_retry":{"type":"boolean","title":"Auto Retry","default":true},"schedule_change":{"anyOf":[{"$ref":"#/components/schemas/ReportScheduleChange"},{"type":"null"}]},"version":{"type":"integer","minimum":1.0,"title":"Version"}},"additionalProperties":false,"type":"object","required":["name","source","connection_id","account_id","destination","period_policy","version"],"title":"ReportUpdate"},"ReportView":{"properties":{"tags":{"items":{"type":"string"},"type":"array","title":"Tags"},"id":{"type":"string","format":"uuid","title":"Id"},"project_id":{"type":"string","format":"uuid","title":"Project Id"},"name":{"type":"string","title":"Name"},"version":{"type":"integer","title":"Version"},"source":{"type":"string","title":"Source"},"connection_id":{"type":"string","format":"uuid","title":"Connection Id"},"account_id":{"type":"string","title":"Account Id"},"source_config":{"additionalProperties":true,"type":"object","title":"Source Config"},"destination":{"additionalProperties":true,"type":"object","title":"Destination"},"period_policy":{"additionalProperties":true,"type":"object","title":"Period Policy"},"schedule":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Schedule"},"auto_retry":{"type":"boolean","title":"Auto Retry"},"schedule_enabled":{"type":"boolean","title":"Schedule Enabled"},"next_slot_utc":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Next Slot Utc"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","project_id","name","version","source","connection_id","account_id","source_config","destination","period_policy","schedule","auto_retry","schedule_enabled","next_slot_utc","created_at","updated_at"],"title":"ReportView"},"RunCreate":{"properties":{"date_from":{"type":"string","format":"date","title":"Date From"},"date_to":{"type":"string","format":"date","title":"Date To"}},"additionalProperties":false,"type":"object","required":["date_from","date_to"],"title":"RunCreate"},"RunView":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"analytics_batch_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Analytics Batch Id"},"report_id":{"type":"string","format":"uuid","title":"Report Id"},"config_version":{"type":"integer","title":"Config Version"},"date_from":{"type":"string","format":"date","title":"Date From"},"date_to":{"type":"string","format":"date","title":"Date To"},"trigger":{"type":"string","title":"Trigger"},"slot_utc":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Slot Utc"},"status":{"type":"string","title":"Status"},"attempts":{"type":"integer","title":"Attempts"},"available_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Available At"},"history_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"History Id"},"source_rows":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Source Rows"},"destination_rows":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Destination Rows"},"warnings":{"items":{"type":"string"},"type":"array","title":"Warnings"},"error_stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Stage"},"error_message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Message"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"started_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Started At"},"finished_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Finished At"}},"type":"object","required":["id","analytics_batch_id","report_id","config_version","date_from","date_to","trigger","slot_utc","status","attempts","available_at","history_id","source_rows","destination_rows","warnings","error_stage","error_message","created_at","started_at","finished_at"],"title":"RunView"},"ScheduleWrite":{"properties":{"version":{"type":"integer","minimum":1.0,"title":"Version"},"enabled":{"type":"boolean","title":"Enabled"},"schedule":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Schedule"}},"additionalProperties":false,"type":"object","required":["version","enabled"],"title":"ScheduleWrite"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"ApiKey":{"type":"http","description":"Ключ из Настройки → API. Authorization: Bearer usk_…","scheme":"bearer"}}},"servers":[{"url":"/api/v1"}]}