> ## Documentation Index
> Fetch the complete documentation index at: https://docs.classquill.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Invite

> Mint a join link or code for a chosen scope, org-scoped to the API key's org.

Scopes: `organization` (recruit a tutor/admin by email, or get a reusable org
join link), `tutor_student` (1-on-1), `classroom`, `group`, `parent`. Supply
`email` to invite a specific person (creates an invite row; EquateIt emails them
where the platform already does); omit `email` for a reusable shareable
link/code. Cross-org targets return 404. Honours `Idempotency-Key`.



## OpenAPI

````yaml /openapi.json post /v1/invites
openapi: 3.1.0
info:
  title: ClassQuill Public API
  description: >-
    REST API for ClassQuill tutoring organisations. Pipe your sessions,
    invoices, payments, tutor earnings, students, and more into your own tools.
    Most endpoints are reads; a focused set of writes (each gated by a *:write
    scope) create or update data, including creating student/tutor/parent
    accounts.


    Authenticate every request with an org API key:

        Authorization: Token token=ei_live_...

    Mint keys in the ClassQuill app under Settings → Developers.
  version: 1.0.0
servers: []
security:
  - ApiKeyAuth: []
tags:
  - name: General
  - name: Sessions
  - name: Tutors
  - name: Students & Parents
  - name: Billing
  - name: Curriculum
  - name: Coursework
  - name: Operations
  - name: Pricing
  - name: Bookings
  - name: Blog
  - name: Reports
paths:
  /v1/invites:
    post:
      tags:
        - General
      summary: Create Invite
      description: >-
        Mint a join link or code for a chosen scope, org-scoped to the API key's
        org.


        Scopes: `organization` (recruit a tutor/admin by email, or get a
        reusable org

        join link), `tutor_student` (1-on-1), `classroom`, `group`, `parent`.
        Supply

        `email` to invite a specific person (creates an invite row; EquateIt
        emails them

        where the platform already does); omit `email` for a reusable shareable

        link/code. Cross-org targets return 404. Honours `Idempotency-Key`.
      operationId: create_invite_v1_invites_post
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Idempotency-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InviteCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invite'
        '401':
          description: Missing, malformed, revoked, or expired credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: The credential lacks the scope this endpoint requires.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '422':
          description: Validation error — `error.details.errors` lists the fields.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: >-
            Rate limit exceeded — honour Retry-After and the RateLimit-*
            headers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
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
      title: InviteCreate
      description: >-
        POST /v1/invites → mint a join link or code for a chosen scope.


        Delivery is decided by `email` + `scope` (there is no `send_email`
        flag): supply

        `email` to invite a specific person — this creates an invite row and
        ClassQuill

        queues them an email where the platform already does (`organization`
        always, via

        a DB trigger; `tutor_student` when an email is given). Omit `email` to
        get a

        reusable shareable link/code. Per-scope required/irrelevant fields are
        validated

        server-side (422). `organization_id`, tokens, and timestamps are always

        server-set; the invite RPCs are never called (they are
        auth.uid()-gated).


        `emailed: true` in the response means the invite email was QUEUED, not
        that it

        was delivered — queueing happens synchronously in this request, but the
        actual

        send is async (a 1-minute-cadence cron drains the queue via Resend).
        Treat

        `join_url` as the reliable fallback: surface it to the caller/inviter
        rather

        than assuming the email will arrive.
    Invite:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        scope:
          type: string
          title: Scope
        role:
          anyOf:
            - type: string
            - type: 'null'
          title: Role
        target_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Target Id
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
        token:
          anyOf:
            - type: string
            - type: 'null'
          title: Token
        join_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Join Url
        expires_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Expires At
        subject_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Subject Id
        emailed:
          type: boolean
          title: Emailed
          default: false
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
      type: object
      required:
        - scope
      title: Invite
      description: >-
        A minted invite. `token` carries the invite token
        (organization/tutor_student)

        or the code (parent / org-join-code scopes). `join_url` is null for
        `parent` (the

        code is entered manually).


        `emailed` is true when ClassQuill queued an email for this invite
        (organization,

        or tutor_student with an email) — it does NOT confirm delivery. The
        actual send

        is async: a background job drains the queue and calls Resend, which can
        still

        fail, bounce, or land in spam after this response returns. Callers
        should

        surface `join_url` as a fallback rather than relying on the email
        arriving.
    ApiError:
      description: Canonical error envelope for every /v1 error response (4xx/5xx).
      properties:
        error:
          $ref: '#/components/schemas/ApiErrorBody'
      required:
        - error
      title: ApiError
      type: object
    ApiErrorBody:
      description: The `error` object every /v1 error response carries.
      properties:
        code:
          description: >-
            Stable machine-readable error code: bad_request, unauthorized,
            forbidden, not_found, conflict, validation_error, rate_limited, or
            internal_error.
          examples:
            - not_found
          title: Code
          type: string
        message:
          description: Human-readable explanation, safe to surface to end users.
          examples:
            - Session not found
          title: Message
          type: string
        status:
          description: The HTTP status code, repeated in the body.
          examples:
            - 404
          title: Status
          type: integer
        details:
          additionalProperties: true
          description: >-
            Error-specific context. 422 carries the field errors under `errors`;
            429 carries `retry_after_seconds`.
          title: Details
          type: object
      required:
        - code
        - message
        - status
      title: ApiErrorBody
      type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Org API key as `Token token=ei_live_...`

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.