{
  "openapi": "3.0.1",
  "info": {
    "title": "AppLixir Public API",
    "description": "Read-only reporting API for AppLixir publishers. Authenticate with your API key via the X-Api-Key header (or Authorization: Bearer <key>).",
    "version": "v1"
  },
  "paths": {
    "/api/v1/api-keys": {
      "get": {
        "tags": [
          "ApiKeys"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.ApiKeyResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.ApiKeyResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.ApiKeyResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ApiKeys"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/api-keys/{id}": {
      "delete": {
        "tags": [
          "ApiKeys"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v1/api-keys/for-user/{userId}": {
      "post": {
        "tags": [
          "ApiKeys"
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.PublicApi.CreateApiKeyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/countries": {
      "get": {
        "tags": [
          "PublicReports"
        ],
        "parameters": [
          {
            "name": "Page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "Search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "SortBy",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "SortDirection",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Filter",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "FilterList",
            "in": "query",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueWithCountryResponse]"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueWithCountryResponse]"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueWithCountryResponse]"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/by-country": {
      "get": {
        "tags": [
          "PublicReports"
        ],
        "parameters": [
          {
            "name": "Page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "Search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "SortBy",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "SortDirection",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Filter",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "FilterList",
            "in": "query",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          {
            "name": "siteIds",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fromDate",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "toDate",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueByCountryResponse]"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueByCountryResponse]"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueByCountryResponse]"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/totals": {
      "get": {
        "tags": [
          "PublicReports"
        ],
        "parameters": [
          {
            "name": "siteIds",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fromDate",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "toDate",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Revenues.RevenueTotalResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Revenues.RevenueTotalResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Applixir.Server.Revenues.RevenueTotalResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sites": {
      "get": {
        "tags": [
          "PublicSites"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.SiteResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.SiteResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Applixir.Server.PublicApi.SiteResponse"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueByCountryResponse]": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Applixir.Server.Revenues.RevenueByCountryResponse"
            },
            "nullable": true
          },
          "meta": {
            "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponseMeta"
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.Helpers.PagedApiResponse`1[Applixir.Server.Revenues.RevenueWithCountryResponse]": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Applixir.Server.Revenues.RevenueWithCountryResponse"
            },
            "nullable": true
          },
          "meta": {
            "$ref": "#/components/schemas/Applixir.Server.Helpers.PagedApiResponseMeta"
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.Helpers.PagedApiResponseMeta": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "totalRows": {
            "type": "integer",
            "format": "int32"
          },
          "totalPages": {
            "type": "integer",
            "format": "int32"
          },
          "sortBy": {
            "type": "string",
            "nullable": true
          },
          "sortDirection": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.PublicApi.ApiKeyResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "keyPrefix": {
            "type": "string",
            "nullable": true
          },
          "siteIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "nullable": true
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "isActive": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.PublicApi.CreateApiKeyRequest": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "nullable": true
          },
          "siteIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.PublicApi.CreateApiKeyResponse": {
        "type": "object",
        "properties": {
          "key": {
            "$ref": "#/components/schemas/Applixir.Server.PublicApi.ApiKeyResponse"
          },
          "apiKey": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.PublicApi.SiteResponse": {
        "type": "object",
        "properties": {
          "siteId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "framework": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "dailyActiveUsers": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "monthlyActiveUsers": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.Revenues.RevenueByCountryResponse": {
        "type": "object",
        "properties": {
          "country": {
            "type": "string",
            "nullable": true
          },
          "revenueAmount": {
            "type": "number",
            "format": "double"
          },
          "cpm": {
            "type": "number",
            "format": "double"
          },
          "adRequests": {
            "type": "integer",
            "format": "int32"
          },
          "impressions": {
            "type": "integer",
            "format": "int32"
          },
          "fillRate": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.Revenues.RevenueTotalResponse": {
        "type": "object",
        "properties": {
          "totalImpressions": {
            "type": "integer",
            "format": "int32"
          },
          "totalRequests": {
            "type": "integer",
            "format": "int32"
          },
          "averageCpm": {
            "type": "number",
            "format": "double"
          },
          "totalRevenue": {
            "type": "number",
            "format": "double"
          },
          "fillRate": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "Applixir.Server.Revenues.RevenueWithCountryResponse": {
        "type": "object",
        "properties": {
          "impressions": {
            "type": "integer",
            "format": "int32"
          },
          "clicks": {
            "type": "integer",
            "format": "int32"
          },
          "adRequests": {
            "type": "integer",
            "format": "int32"
          },
          "cpm": {
            "type": "number",
            "format": "double"
          },
          "revenueAmount": {
            "type": "number",
            "format": "double"
          },
          "fillRate": {
            "type": "number",
            "format": "double"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "gameId": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "adUnitId": {
            "type": "string",
            "nullable": true
          },
          "gameName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "description": "Client API key. Send as: X-Api-Key: axk_live_...",
        "name": "X-Api-Key",
        "in": "header"
      },
      "Bearer": {
        "type": "http",
        "description": "JWT Authorization header using the Bearer scheme.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "apiKey": {
        "type": "apiKey",
        "name": "apiKey",
        "in": "query"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ],
      "apiKey": [ ],
      "ApiKeyHeader": [ ]
    }
  ]
}