{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/derive-to/json-schema/derive-to-share-result-schema.json",
  "title": "ShareResult",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/derive-to-sharing-api-openapi.yml#/components/schemas/ShareResult",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "member"
          ],
          "description": "The person already had an account — shared directly."
        },
        "member": {
          "$ref": "#/$defs/ArtifactMember"
        }
      },
      "required": [
        "kind",
        "member"
      ]
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "invite"
          ],
          "description": "No account with that email — a pending invite was created and emailed."
        },
        "invite": {
          "$ref": "#/$defs/ArtifactInvite"
        },
        "accept_url": {
          "type": "string",
          "description": "The link the invitee follows to accept."
        }
      },
      "required": [
        "kind",
        "invite",
        "accept_url"
      ]
    }
  ],
  "$defs": {
    "ArtifactInvite": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "description": "The invitee's email (share-capable callers only)."
        },
        "role": {
          "type": "string",
          "enum": [
            "viewer",
            "commenter",
            "editor",
            "owner"
          ],
          "description": "The role accepting will grant."
        },
        "created_at": {
          "type": "string"
        },
        "expires_at": {
          "type": "string",
          "description": "When the invite expires (7-day TTL)."
        }
      },
      "required": [
        "id",
        "email",
        "role",
        "created_at",
        "expires_at"
      ]
    },
    "ArtifactMember": {
      "type": "object",
      "properties": {
        "user_id": {
          "type": "string"
        },
        "handle": {
          "type": [
            "string",
            "null"
          ],
          "description": "Public @handle; null when the user has none."
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display name; null when unset."
        },
        "profession": {
          "type": [
            "string",
            "null"
          ],
          "description": "Joined only on workspace-member payloads; absent on artifact/collection lists."
        },
        "role": {
          "type": "string",
          "enum": [
            "viewer",
            "commenter",
            "editor",
            "owner"
          ],
          "description": "Permission tier, ascending: viewer < commenter < editor < owner."
        }
      },
      "required": [
        "user_id",
        "handle",
        "name",
        "role"
      ]
    }
  }
}