> ## 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.

# Complete Session

> Mark a session completed.

Sets `tutor_sessions.status='completed'` and writes one tutor-owed
`session_ledger` row per participant from that participant's per-hour rate
snapshot, atomically via a transactional RPC. Idempotent — completing an
already-completed session is a no-op replay, never a double-ledger. No charge is
initiated here. Requires the `sessions:write` scope. 404 if the session isn't in
your org.



## OpenAPI

````yaml /openapi.json put /v1/sessions/{session_id}/complete
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/sessions/{session_id}/complete:
    put:
      tags:
        - Sessions
      summary: Complete Session
      description: >-
        Mark a session completed.


        Sets `tutor_sessions.status='completed'` and writes one tutor-owed

        `session_ledger` row per participant from that participant's per-hour
        rate

        snapshot, atomically via a transactional RPC. Idempotent — completing an

        already-completed session is a no-op replay, never a double-ledger. No
        charge is

        initiated here. Requires the `sessions:write` scope. 404 if the session
        isn't in

        your org.
      operationId: complete_session_v1_sessions__session_id__complete_put
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
        - 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/SessionComplete'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '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'
        '404':
          description: >-
            Not found — the record doesn't exist or belongs to another
            organisation.
          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:
    SessionComplete:
      properties:
        attendance:
          anyOf:
            - type: string
            - type: 'null'
          title: Attendance
          description: 'Optional attendance marker: attended, no_show, or excused'
        completed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Completed At
          description: Optional ISO 8601 completion time; defaults to now
      additionalProperties: false
      type: object
      title: SessionComplete
      description: >-
        PUT /v1/sessions/{id}/complete → tutor_sessions.status + session_ledger.


        Marks a scheduled session completed and writes one tutor-owed
        `session_ledger`

        row per participant from that participant's per-hour rate snapshot.
        Idempotent:

        completing an already-completed session is a no-op replay, never a
        double-ledger.

        Both fields are persisted: `attendance` sets each participant's
        attendance +

        settlement_state (and `excused` books 0 owed), mirroring the in-app

        mark_session_attendance; `completed_at` is stored on
        tutor_sessions.completed_at.
    Session:
      properties:
        id:
          type: string
          title: Id
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        tutor_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Tutor Id
        student_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Student Id
        starts_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Starts At
        ends_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Ends At
        duration_minutes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Duration Minutes
        tutor_pay_rate_cents:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tutor Pay Rate Cents
        student_rate_cents:
          anyOf:
            - type: integer
            - type: 'null'
          title: Student Rate Cents
        amount_owed_cents:
          anyOf:
            - type: integer
            - type: 'null'
          title: Amount Owed Cents
        mode:
          anyOf:
            - type: string
            - type: 'null'
          title: Mode
        subject_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Subject Id
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
        completed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Completed At
      type: object
      required:
        - id
      title: Session
    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.