{
  "info": {
    "name": "Reports API",
    "description": "Reports module: list report types, get report data (charts + table), and export as CSV or PDF. Requires permission: view-reports. All requests use Bearer token.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{auth_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "web_url",
      "value": "https://sys.roms.roqay.dev/api/v1/web",
      "type": "string"
    },
    {
      "key": "auth_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "report_type",
      "value": "tickets",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "List Report Types",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports",
          "host": ["{{web_url}}"],
          "path": ["reports"]
        },
        "description": "Returns the list of available report types with key, name, and description. Use this to build the Reports module page (Tickets Report, Employee Performance Report, Email Tickets Report, Overdue Tickets Report, Project & SLA Status Report)."
      }
    },
    {
      "name": "Get Report Data (Tickets)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/tickets?date_from=2026-01-01&date_to=2026-02-26&company_id=1&project_id=1&status=1&priority=1&type=1&sla_id=1&chart_year=2026&trend_type=response",
          "host": ["{{web_url}}"],
          "path": ["reports", "tickets"],
          "query": [
            { "key": "date_from", "value": "2026-01-01", "description": "Filter from date (Y-m-d)" },
            { "key": "date_to", "value": "2026-02-26", "description": "Filter to date (Y-m-d)" },
            { "key": "company_id", "value": "1", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "1", "description": "Project ID(s), comma-separated" },
            { "key": "status", "value": "1", "description": "Ticket status" },
            { "key": "priority", "value": "1", "description": "Priority" },
            { "key": "type", "value": "1", "description": "Ticket type" },
            { "key": "sla_id", "value": "1", "description": "SLA ID" },
            { "key": "chart_year", "value": "2026", "description": "Tickets Report charts year (if date_from/date_to not provided, applies to whole report)" },
            { "key": "trend_type", "value": "response", "description": "Tickets Report trend type: response or resolution" }
          ]
        },
        "description": "Returns Tickets Report data: kpis, filters_meta, charts_meta (years, trend_types), columns, charts (by_status, by_priority, ticket_volume_monthly, avg_timer_trend) and table. Filters optional."
      }
    },
    {
      "name": "Get Report Data (Employee Performance)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/employee_performance?date_from=2026-01-01&date_to=2026-02-26&project_id=1&employee_id=1",
          "host": ["{{web_url}}"],
          "path": ["reports", "employee_performance"],
          "query": [
            { "key": "date_from", "value": "2026-01-01" },
            { "key": "date_to", "value": "2026-02-26" },
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "1" },
            { "key": "employee_id", "value": "1" }
          ]
        },
        "description": "Returns Employee Performance charts + table per employee. Charts include by_closure_rate, by_current_delayed, tickets_per_employee, avg_response_resolution_hours. Filters: date_from/date_to/company_id/project_id/employee_id."
      }
    },
    {
      "name": "Get Report Data (Email Tickets)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/email_tickets?date_from=2026-01-01&date_to=2026-02-26",
          "host": ["{{web_url}}"],
          "path": ["reports", "email_tickets"],
          "query": [
            { "key": "date_from", "value": "2026-01-01" },
            { "key": "date_to", "value": "2026-02-26" },
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "" }
          ]
        },
        "description": "Email Tickets Report. Charts compare Email vs Portal/Manual in the same filter scope: source_distribution, tickets_per_project, tickets_by_priority, plus by_status for email. Table returns email tickets."
      }
    },
    {
      "name": "Get Report Data (Overdue Tickets)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/overdue_tickets?date_from=2026-01-01&date_to=2026-02-26&project_id=1",
          "host": ["{{web_url}}"],
          "path": ["reports", "overdue_tickets"],
          "query": [
            { "key": "date_from", "value": "2026-01-01" },
            { "key": "date_to", "value": "2026-02-26" },
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "1" }
          ]
        },
        "description": "Overdue Tickets Report. Returns charts: by_days_open, overdue_distribution (0-7/8-14/15-30/30+), overdue_by_priority, overdue_by_status; and table rows with days_open and breached_at."
      }
    },
    {
      "name": "Get Report Data (Project & SLA Status)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/project_sla_status?project_id=1",
          "host": ["{{web_url}}"],
          "path": ["reports", "project_sla_status"],
          "query": [
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "1" },
            { "key": "date_from", "value": "" },
            { "key": "date_to", "value": "" }
          ]
        },
        "description": "Returns projects and SLAs with remaining_days (SLA end date - current date)."
      }
    },
    {
      "name": "Export Report (CSV)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "text/csv",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/export/{{report_type}}?format=csv&date_from=2026-01-01&date_to=2026-02-26",
          "host": ["{{web_url}}"],
          "path": ["reports", "export", "{{report_type}}"],
          "query": [
            { "key": "format", "value": "csv", "description": "csv or pdf" },
            { "key": "date_from", "value": "2026-01-01" },
            { "key": "date_to", "value": "2026-02-26" },
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "" },
            { "key": "status", "value": "" },
            { "key": "priority", "value": "" },
            { "key": "type", "value": "", "description": "Ticket type" },
            { "key": "sla_id", "value": "" },
            { "key": "employee_id", "value": "" }
          ]
        },
        "description": "Downloads report table as CSV. Set report_type variable to: tickets, employee_performance, email_tickets, overdue_tickets, project_sla_status."
      }
    },
    {
      "name": "Export Report (PDF)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/pdf",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{web_url}}/reports/export/{{report_type}}?format=pdf&date_from=2026-01-01&date_to=2026-02-26",
          "host": ["{{web_url}}"],
          "path": ["reports", "export", "{{report_type}}"],
          "query": [
            { "key": "format", "value": "pdf" },
            { "key": "date_from", "value": "2026-01-01" },
            { "key": "date_to", "value": "2026-02-26" },
            { "key": "company_id", "value": "", "description": "Company ID(s), comma-separated" },
            { "key": "project_id", "value": "" }
          ]
        },
        "description": "Streams report table as PDF. Same filters as CSV."
      }
    },
    {
      "name": "Examples (Filters)",
      "item": [
        {
          "name": "Tickets Report - Use chart_year only (applies to whole report)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/tickets?chart_year=2026&trend_type=response",
              "host": ["{{web_url}}"],
              "path": ["reports", "tickets"],
              "query": [
                { "key": "chart_year", "value": "2026", "description": "Applies to whole report when date_from/date_to not provided" },
                { "key": "trend_type", "value": "response", "description": "response or resolution" }
              ]
            },
            "description": "Verify chart_year fallback + charts_meta.years matches actual data scope."
          }
        },
        {
          "name": "Tickets Report - Company + Project + SLA + Type + Priority",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/tickets?date_from=2026-01-01&date_to=2026-12-31&company_id=1&project_id=1&sla_id=1&type=1&priority=1&status=1",
              "host": ["{{web_url}}"],
              "path": ["reports", "tickets"],
              "query": [
                { "key": "date_from", "value": "2026-01-01" },
                { "key": "date_to", "value": "2026-12-31" },
                { "key": "company_id", "value": "1" },
                { "key": "project_id", "value": "1" },
                { "key": "sla_id", "value": "1" },
                { "key": "type", "value": "1" },
                { "key": "priority", "value": "1" },
                { "key": "status", "value": "1" }
              ]
            },
            "description": "Verify all tickets filters affect KPIs, charts and table."
          }
        },
        {
          "name": "Employee Performance - Date + Company + Project + Employee",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/employee_performance?date_from=2026-01-01&date_to=2026-02-26&company_id=1&project_id=1&employee_id=1",
              "host": ["{{web_url}}"],
              "path": ["reports", "employee_performance"],
              "query": [
                { "key": "date_from", "value": "2026-01-01" },
                { "key": "date_to", "value": "2026-02-26" },
                { "key": "company_id", "value": "1" },
                { "key": "project_id", "value": "1" },
                { "key": "employee_id", "value": "1" }
              ]
            },
            "description": "Verify filters affect charts.tickets_per_employee and charts.avg_response_resolution_hours."
          }
        },
        {
          "name": "Email Tickets - Date + Company + Project + Priority",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/email_tickets?date_from=2026-01-01&date_to=2026-12-31&company_id=1&project_id=1&priority=1",
              "host": ["{{web_url}}"],
              "path": ["reports", "email_tickets"],
              "query": [
                { "key": "date_from", "value": "2026-01-01" },
                { "key": "date_to", "value": "2026-12-31" },
                { "key": "company_id", "value": "1" },
                { "key": "project_id", "value": "1" },
                { "key": "priority", "value": "1" }
              ]
            },
            "description": "Charts compare Email vs Portal/Manual within the same filter scope; table returns email only."
          }
        },
        {
          "name": "Overdue Tickets - Date + Company + Project + Priority",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/overdue_tickets?date_from=2026-01-01&date_to=2026-12-31&company_id=1&project_id=1&priority=1",
              "host": ["{{web_url}}"],
              "path": ["reports", "overdue_tickets"],
              "query": [
                { "key": "date_from", "value": "2026-01-01" },
                { "key": "date_to", "value": "2026-12-31" },
                { "key": "company_id", "value": "1" },
                { "key": "project_id", "value": "1" },
                { "key": "priority", "value": "1" }
              ]
            },
            "description": "Verify overdue_distribution / overdue_by_priority / overdue_by_status match filtered scope."
          }
        },
        {
          "name": "Project & SLA Status - Company + Project + Date Range",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json", "type": "text" }],
            "url": {
              "raw": "{{web_url}}/reports/project_sla_status?company_id=1&project_id=1&date_from=2026-01-01&date_to=2026-12-31",
              "host": ["{{web_url}}"],
              "path": ["reports", "project_sla_status"],
              "query": [
                { "key": "company_id", "value": "1" },
                { "key": "project_id", "value": "1" },
                { "key": "date_from", "value": "2026-01-01" },
                { "key": "date_to", "value": "2026-12-31" }
              ]
            },
            "description": "Verify company/project/date filters apply to SLA listing."
          }
        }
      ]
    }
  ]
}
