{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/publishwith-ai/json-schema/publishwith-ai-share-request-schema.json",
  "title": "ShareRequest",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/publishwith-ai-openapi.yml#/components/schemas/ShareRequest",
  "type": "object",
  "required": [
    "principal"
  ],
  "properties": {
    "principal": {
      "$ref": "#/$defs/Principal"
    },
    "access": {
      "type": "string",
      "enum": [
        "view",
        "edit",
        "own"
      ],
      "default": "view",
      "description": "Access level to grant. Owners/editors (edit/own) must be tenant users: an external_email is capped at view and edit/own are rejected."
    },
    "delivery": {
      "type": "string",
      "enum": [
        "auto",
        "canonical",
        "link"
      ],
      "default": "auto",
      "description": "auto resolves by lane (internal→canonical, external→link); canonical forces the in-app URL; link forces a tokenized share link."
    },
    "ttl_days": {
      "type": "integer",
      "description": "Expiry in days for an external (link) grant. Default 90. Ignored for internal grants."
    }
  },
  "$defs": {
    "Principal": {
      "type": "object",
      "required": [
        "type",
        "value"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "tenant_user",
            "tenant_group",
            "external_email",
            "audience",
            "auto"
          ],
          "description": "Principal kind. tenant_user/tenant_group are internal (canonical URL); external_email gets a tokenized share link; audience fans out external links to a saved contact group. auto lets the server pick the lane: an email inside the workspace resolves to tenant_user, outside it to external_email, and a person name is resolved against the directory. auto never resolves to a group."
        },
        "value": {
          "type": "string",
          "description": "Identifier: an email (tenant_user/external_email/auto), a group name (tenant_group), an audience group id (audience), or a person name (auto)."
        }
      }
    }
  }
}