{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/classquill-com/json-schema/classquill-com-invite-create-schema.json",
  "title": "InviteCreate",
  "description": "POST /v1/invites → mint a join link or code for a chosen scope.\n\nDelivery is decided by `email` + `scope` (there is no `send_email` flag): supply\n`email` to invite a specific person — this creates an invite row and ClassQuill\nqueues them an email where the platform already does (`organization` always, via\na DB trigger; `tutor_student` when an email is given). Omit `email` to get a\nreusable shareable link/code. Per-scope required/irrelevant fields are validated\nserver-side (422). `organization_id`, tokens, and timestamps are always\nserver-set; the invite RPCs are never called (they are auth.uid()-gated).\n\n`emailed: true` in the response means the invite email was QUEUED, not that it\nwas delivered — queueing happens synchronously in this request, but the actual\nsend is async (a 1-minute-cadence cron drains the queue via Resend). Treat\n`join_url` as the reliable fallback: surface it to the caller/inviter rather\nthan assuming the email will arrive.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/classquill-com-openapi.json#/components/schemas/InviteCreate",
  "properties": {
    "scope": {
      "type": "string",
      "enum": [
        "organization",
        "classroom",
        "group",
        "tutor_student",
        "parent"
      ],
      "title": "Scope"
    },
    "role": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Role",
      "description": "organization only: 'tutor' (default) | 'admin' | 'student'."
    },
    "email": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Email",
      "description": "Required for the organization email path; optional elsewhere."
    },
    "tutor_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Tutor Id",
      "description": "Required for scope=tutor_student."
    },
    "classroom_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Classroom Id",
      "description": "Required for scope=classroom."
    },
    "group_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Group Id",
      "description": "Required for scope=group."
    },
    "student_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Student Id",
      "description": "Required for scope=parent (the child)."
    },
    "subject_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Subject Id",
      "description": "Optional, scope=tutor_student only — echoed back + audited."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "scope"
  ]
}