{
  "openapi": "3.1.0",
  "info": {
    "title": "EXPANS Time Tracker — Reporting API",
    "version": "1.0.0",
    "description": "Server-to-server read-only reporting API. A bearer key covers explicitly granted projects for one client or all current and future projects in one workspace. Client projects include work categories and task titles with links removed; internal projects return time without that detail. No employee identities, payroll, financial budgets, active timers or mutation operations. Fetch every snapshot page before replacing a report. Periods cover at most 366 inclusive local days; snapshots expire after 30 minutes or when access ends."
  },
  "servers": [
    {
      "url": "https://track.expans.ua/integrations/client-portal/v1",
      "description": "HTTPS endpoint. Requests require a valid integration key and enabled service access."
    }
  ],
  "security": [
    {
      "ClientPortalBearer": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "portalHealth",
        "security": [
          {
            "ClientPortalBearer": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Authenticated safe projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query, period or cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, rotated or revoked bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Project denied or grants changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown route/snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Read-only API",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Snapshot expired; discard partial load and restart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Narrow the period; snapshot too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or storage quota; respect Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          },
          "503": {
            "description": "Disabled, database busy or temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          }
        }
      }
    },
    "/projects": {
      "get": {
        "operationId": "allowedProjects",
        "security": [
          {
            "ClientPortalBearer": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated safe projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectsPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query, period or cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, rotated or revoked bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Project denied or grants changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown route/snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Read-only API",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Snapshot expired; discard partial load and restart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Narrow the period; snapshot too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or storage quota; respect Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          },
          "503": {
            "description": "Disabled, database busy or temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          }
        }
      }
    },
    "/projects/{project_id}/entries": {
      "get": {
        "operationId": "projectSnapshot",
        "security": [
          {
            "ClientPortalBearer": []
          }
        ],
        "parameters": [
          {
            "name": "project_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,17}$"
            }
          },
          {
            "name": "period_start",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "period_end",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 64,
              "example": "Europe/Kyiv"
            }
          },
          {
            "name": "snapshot_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated safe projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntriesPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query, period or cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, rotated or revoked bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Project denied or grants changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown route/snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Read-only API",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Snapshot expired; discard partial load and restart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Narrow the period; snapshot too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or storage quota; respect Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          },
          "503": {
            "description": "Disabled, database busy or temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Seconds before retry"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ClientPortalBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A separate integration key scoped to permitted client projects or a whole workspace; not an account password, session cookie or extension token."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Health": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schema_version",
          "ready",
          "scope"
        ],
        "properties": {
          "schema_version": {
            "const": 1
          },
          "ready": {
            "const": true
          },
          "scope": {
            "const": "client_projection.read"
          }
        }
      },
      "Project": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "project_id",
          "name"
        ],
        "properties": {
          "project_id": {
            "type": "string",
            "pattern": "^[1-9][0-9]*$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          }
        }
      },
      "Entry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "entry_id",
          "project_id",
          "revision",
          "started_at",
          "ended_at",
          "seconds",
          "category",
          "client_title",
          "work_id",
          "deleted"
        ],
        "properties": {
          "entry_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "project_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "revision": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "ended_at": {
            "type": "string",
            "format": "date-time"
          },
          "seconds": {
            "type": "integer",
            "minimum": 0,
            "description": "Full original UTC duration, floored to integer seconds. Consumer clips to period."
          },
          "category": {
            "type": "string",
            "maxLength": 160,
            "description": "Work direction name for an authorized client project, with links removed. Empty for internal projects or missing data."
          },
          "client_title": {
            "type": "string",
            "maxLength": 500,
            "description": "Task name for an authorized client project, with links removed. Empty for internal projects or missing data."
          },
          "work_id": {
            "type": "string",
            "maxLength": 160,
            "description": "Opaque task grouping ID scoped to the project and client. Empty when the task title is absent."
          },
          "deleted": {
            "const": false
          }
        }
      },
      "ProjectsPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schema_version",
          "scope",
          "projects",
          "next_cursor",
          "complete"
        ],
        "properties": {
          "schema_version": {
            "const": 1
          },
          "scope": {
            "const": "client_projection.read"
          },
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Project"
            },
            "maxItems": 1000
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000,
            "description": "Opaque signed continuation, null on final page."
          },
          "complete": {
            "type": "boolean"
          }
        }
      },
      "EntriesPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schema_version",
          "snapshot_id",
          "project_id",
          "period_start",
          "period_end",
          "timezone",
          "generated_at",
          "records",
          "next_cursor",
          "complete"
        ],
        "properties": {
          "schema_version": {
            "const": 1
          },
          "snapshot_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "project_id": {
            "type": "string"
          },
          "period_start": {
            "type": "string",
            "format": "date"
          },
          "period_end": {
            "type": "string",
            "format": "date"
          },
          "timezone": {
            "type": "string",
            "maxLength": 64
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Entry"
            },
            "maxItems": 1000
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000,
            "description": "Opaque signed continuation, null on final page."
          },
          "complete": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
