{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/preuve-ai/json-schema/preuve-ai-agency-context-schema.json",
  "title": "AgencyContext",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/preuve-ai-openapi.json#/components/schemas/AgencyContext",
  "type": "object",
  "properties": {
    "agency": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "description": "The calling account's role in the workspace."
        }
      }
    },
    "quota": {
      "$ref": "#/$defs/AgencyQuota"
    },
    "canRunScan": {
      "type": "boolean",
      "description": "Eligibility, not live availability. True only when the role may run scans, the workspace is approved, billing setup is done, and quota remains. It does not read the service kill switch, the LLM pause or the rate limiters, so a start can still answer 503 or 429 while this is true. None of those refusals spends a project credit. This is the deep project slot answer only; see canRunStarterScan for a client Starter Scan.\n"
    },
    "canRunStarterScan": {
      "type": "boolean",
      "description": "Whether a client Starter Scan (scanType \"starter\", no project slot) can start for this key. Eligibility, like canRunScan. True only for the workspace owner who holds the AppSumo Tier 4 or 5 licence, or for the owner of a workspace nobody has funded while its one free scan is unused. It does not read the deep quota or payment setup, and it does not count the Starter fair use, so a start can still answer 429 FAIR_USE_LIMIT.\n"
    },
    "reports": {
      "type": "array",
      "description": "One page of the workspace's client reports, newest first, including ones created in the Agency dashboard. Same shape and paging as /api/agent/agency/reports.\n",
      "items": {
        "$ref": "#/$defs/AgencyReportListItem"
      }
    },
    "nextOffset": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Offset of the next page of reports, or null on the last page.\n"
    }
  },
  "$defs": {
    "AgencyQuota": {
      "type": "object",
      "description": "Shared project quota for the workspace, same pool as the dashboard.",
      "properties": {
        "plan": {
          "type": "string"
        },
        "isActiveSubscription": {
          "type": "boolean"
        },
        "trialLimit": {
          "type": "integer"
        },
        "trialUsed": {
          "type": "integer"
        },
        "trialExpired": {
          "type": "boolean"
        },
        "delinquent": {
          "type": "boolean"
        },
        "monthlyLimit": {
          "type": "integer"
        },
        "monthlyUsed": {
          "type": "integer"
        },
        "monthlyRemaining": {
          "type": "integer"
        },
        "topupRemaining": {
          "type": "integer"
        },
        "totalRemaining": {
          "type": "integer"
        },
        "requiresPaymentSetup": {
          "type": "boolean"
        },
        "canScan": {
          "type": "boolean"
        },
        "nextResetAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "AgencyReportListItem": {
      "type": "object",
      "description": "One client report in the workspace, without its payload.",
      "properties": {
        "reportId": {
          "type": "string"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": "string"
        },
        "scanType": {
          "type": "string",
          "enum": [
            "starter",
            "deep"
          ]
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "reportUrl": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}