{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dealboard/json-schema/dealboard-me-schema.json",
  "title": "Me",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dealboard-openapi.json#/components/schemas/Me",
  "type": "object",
  "required": [
    "user",
    "workspace",
    "apiKey",
    "auth"
  ],
  "properties": {
    "user": {
      "type": "object",
      "required": [
        "id",
        "email",
        "name"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "workspace": {
      "type": "object",
      "required": [
        "id",
        "name",
        "plan"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "plan": {
          "type": "string",
          "enum": [
            "free",
            "standard"
          ]
        }
      }
    },
    "apiKey": {
      "type": [
        "object",
        "null"
      ],
      "description": "The API key in use, or null when authenticated via OAuth.",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "auth": {
      "type": "object",
      "description": "How the caller authenticated and what it may do.",
      "required": [
        "kind",
        "scopes",
        "client"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "api_key",
            "oauth"
          ]
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "deals:read",
              "deals:write",
              "leads:read",
              "leads:write",
              "pipeline:read"
            ]
          },
          "description": "Granted scopes. API keys hold the full set (role is the gate); OAuth tokens hold exactly what the user consented to.\n\n- `deals:read` — List, search, and read deals plus their notes and activity.\n- `deals:write` — Create deals, update fields, move stages, and add notes.\n- `leads:read` — Read inbound leads and their enrichment payloads.\n- `leads:write` — Triage leads, promote them to deals, and write enrichment back.\n- `pipeline:read` — Read pipeline summaries, weighted pipeline, report cards, and export PNGs."
        },
        "client": {
          "type": [
            "object",
            "null"
          ],
          "description": "The OAuth client, when kind = oauth.",
          "properties": {
            "id": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}