{
  "openapi": "3.1.0",
  "info": {
    "title": "Skylar Reporting API",
    "version": "v1",
    "description": "Client-facing reporting API specification generated from reporting Zod contracts."
  },
  "servers": [
    {
      "url": "https://europe-west2-firebase-frontend-v01.cloudfunctions.net/reportingApi",
      "description": "Production"
    }
  ],
  "paths": {
    "/v1/users": {
      "get": {
        "operationId": "reportingApiListUsers",
        "summary": "List reporting API users for the authenticated organisation.",
        "description": "List reporting API users for the authenticated organisation.",
        "tags": ["Reporting API"],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/reportingApiListUsersResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_argument: Request parameters are invalid. failed_precondition: Request cannot be fulfilled in the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized: Authorization header must include a Bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "403": {
            "description": "forbidden: Forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "404": {
            "description": "not_found: Endpoint not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed: Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "500": {
            "description": "internal: Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/v1/users/{userId}/sessions": {
      "get": {
        "operationId": "reportingApiListUserSessions",
        "summary": "List reporting API session history for a user.",
        "description": "List reporting API session history for a user.",
        "tags": ["Reporting API"],
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": 0
            }
          },
          {
            "in": "query",
            "name": "scenario_id",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "query",
            "name": "date_from",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "in": "query",
            "name": "date_to",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/reportingApiListUserSessionsResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_argument: Request parameters are invalid. failed_precondition: Request cannot be fulfilled in the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized: Authorization header must include a Bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "403": {
            "description": "forbidden: Forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "404": {
            "description": "not_found: Endpoint not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed: Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "500": {
            "description": "internal: Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/v1/users/{userId}/assessments": {
      "get": {
        "operationId": "reportingApiListUserAssessments",
        "summary": "List reporting API assessments for a user.",
        "description": "List reporting API assessments for a user.",
        "tags": ["Reporting API"],
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": 0
            }
          },
          {
            "in": "query",
            "name": "date_from",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "in": "query",
            "name": "date_to",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/reportingApiListUserAssessmentsResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_argument: Request parameters are invalid. failed_precondition: Request cannot be fulfilled in the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized: Authorization header must include a Bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "403": {
            "description": "forbidden: Forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "404": {
            "description": "not_found: Endpoint not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed: Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          },
          "500": {
            "description": "internal: Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportingApiError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Send the reporting API key as `Authorization: Bearer <api-key>`."
      }
    },
    "schemas": {
      "ReportingApiError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "method_not_allowed",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "invalid_argument",
                  "failed_precondition",
                  "internal"
                ]
              },
              "message": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": ["code", "message"],
            "additionalProperties": false
          }
        },
        "required": ["error"],
        "additionalProperties": false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      },
      "reportingApiListUsersResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "user_id": {
                  "type": "string"
                },
                "email": {
                  "type": ["string", "null"]
                },
                "display_name": {
                  "type": ["string", "null"]
                },
                "org_role": {
                  "type": ["string", "null"]
                },
                "org_status": {
                  "type": ["string", "null"]
                },
                "team_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": ["user_id", "email", "display_name", "org_role", "org_status", "team_ids"],
              "additionalProperties": false
            }
          }
        },
        "required": ["data"],
        "additionalProperties": false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      },
      "reportingApiListUserSessionsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "session_id": {
                  "type": ["string", "null"]
                },
                "completed_at": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "scenario_id": {
                  "type": ["string", "null"]
                },
                "scenario_name": {
                  "type": ["string", "null"]
                }
              },
              "required": ["session_id", "completed_at", "scenario_id", "scenario_name"],
              "additionalProperties": false
            }
          },
          "pagination": {
            "type": "object",
            "properties": {
              "page": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "page_size": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "has_next_page": {
                "type": "boolean"
              }
            },
            "required": ["page", "page_size", "has_next_page"],
            "additionalProperties": false
          }
        },
        "required": ["data", "pagination"],
        "additionalProperties": false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      },
      "reportingApiListUserAssessmentsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "session_id": {
                  "type": ["string", "null"]
                },
                "completed_at": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "strongest_criteria": {
                  "type": ["string", "null"]
                },
                "criteria": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "score": {
                        "type": "number"
                      },
                      "description": {
                        "type": "string"
                      }
                    },
                    "required": ["name", "score", "description"],
                    "additionalProperties": false
                  }
                },
                "coach_feedback": {
                  "type": "string"
                }
              },
              "required": ["session_id", "completed_at", "strongest_criteria", "criteria"],
              "additionalProperties": false
            }
          },
          "pagination": {
            "type": "object",
            "properties": {
              "page": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "page_size": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "has_next_page": {
                "type": "boolean"
              }
            },
            "required": ["page", "page_size", "has_next_page"],
            "additionalProperties": false
          }
        },
        "required": ["data", "pagination"],
        "additionalProperties": false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      }
    }
  }
}
