{
    "openapi": "3.1.0",
    "info": {
        "title": "Stundentakt tools API",
        "version": "1",
        "summary": "What a learning tool embedded in a Stundentakt medium calls with its person's access token.",
        "description": "A learning tool is an external web page that Stundentakt frames as a block of a medium. It signs its person in with OAuth 2 (authorization code with PKCE, S256 only, public client without secret), then lists the person's assignments with it or opens a pasted link, reads its task and the whole medium, saves drafts, hands in a result, keeps free data (records), reports learning events in the shape of an xAPI statement and reads what the person's subscription unlocks. A pupil is only ever her pseudonym; a guest gets no token. Every refusal is `{message, reason}`; decide by `reason`. The contract in prose (German): https://stundentakt.net/docs/developers/reference.md.",
        "license": {
            "name": "Proprietary",
            "identifier": "LicenseRef-Proprietary"
        }
    },
    "externalDocs": {
        "description": "Tools API contract (German)",
        "url": "https://stundentakt.net/docs/developers/reference.md"
    },
    "servers": [
        {
            "url": "https://stundentakt.net/api/v1/tools"
        }
    ],
    "paths": {
        "/openapi.json": {
            "get": {
                "operationId": "getOpenApi",
                "summary": "This description as OpenAPI 3.1. Public; may be cached for five minutes.",
                "security": [],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "description": "An OpenAPI 3.1 document."
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/documents/{document}": {
            "get": {
                "operationId": "getDocument",
                "summary": "Mode `author`: the medium's name, this tool's blocks (with `hidden` where the person may change them) and the whole medium.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/document"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "document",
                                        "blocks",
                                        "content"
                                    ],
                                    "properties": {
                                        "document": {
                                            "type": "object",
                                            "required": [
                                                "ulid",
                                                "name",
                                                "type"
                                            ],
                                            "properties": {
                                                "ulid": {
                                                    "$ref": "#/components/schemas/Ulid"
                                                },
                                                "name": {
                                                    "type": "string"
                                                },
                                                "type": {
                                                    "type": "string"
                                                }
                                            }
                                        },
                                        "blocks": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/ToolBlock"
                                            }
                                        },
                                        "content": {
                                            "$ref": "#/components/schemas/Content"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}": {
            "get": {
                "operationId": "getAssignment",
                "summary": "Modes `learn` and `review`: the assignment, its window, who is asking, this tool's blocks, the whole medium and the person's progress.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "assignment",
                                        "document",
                                        "window",
                                        "me",
                                        "blocks",
                                        "content",
                                        "progress"
                                    ],
                                    "properties": {
                                        "assignment": {
                                            "type": "object",
                                            "properties": {
                                                "ulid": {
                                                    "$ref": "#/components/schemas/Ulid"
                                                },
                                                "mode": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ]
                                                },
                                                "visible_from": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "format": "date-time"
                                                },
                                                "visible_until": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "format": "date-time"
                                                },
                                                "open_from": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "format": "date-time"
                                                },
                                                "closes_at": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "format": "date-time"
                                                }
                                            }
                                        },
                                        "document": {
                                            "type": "object",
                                            "properties": {
                                                "ulid": {
                                                    "$ref": "#/components/schemas/Ulid"
                                                },
                                                "name": {
                                                    "type": "string"
                                                }
                                            }
                                        },
                                        "window": {
                                            "type": "object",
                                            "properties": {
                                                "phase": {
                                                    "type": "string"
                                                },
                                                "takes_answers": {
                                                    "type": "boolean"
                                                }
                                            }
                                        },
                                        "me": {
                                            "type": "object",
                                            "properties": {
                                                "role": {
                                                    "type": "string",
                                                    "enum": [
                                                        "teacher",
                                                        "student",
                                                        "guest"
                                                    ]
                                                },
                                                "alias": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "description": "A pupil's pseudonym, never a real name."
                                                }
                                            }
                                        },
                                        "blocks": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/ToolBlock"
                                            }
                                        },
                                        "content": {
                                            "$ref": "#/components/schemas/Content"
                                        },
                                        "progress": {
                                            "$ref": "#/components/schemas/Progress"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/blocks/{block}": {
            "put": {
                "operationId": "updateBlock",
                "summary": "Mode `author`: write title, task and hidden part. What the body leaves out stays; with `updated_at` it saves only if the task is unchanged since (else 409 `conflict` with the current `block`).",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "title": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 200
                                    },
                                    "task": {
                                        "type": [
                                            "object",
                                            "array",
                                            "null"
                                        ],
                                        "description": "The task, at most 64 KB."
                                    },
                                    "hidden": {
                                        "type": [
                                            "object",
                                            "array",
                                            "null"
                                        ],
                                        "description": "Only for the author and the tool in her hand, at most 64 KB."
                                    },
                                    "display": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "inline",
                                            "full",
                                            null
                                        ],
                                        "description": "In the page (`inline`) or in a tab of its own (`full`); `null` follows the tool's entry."
                                    },
                                    "complete": {
                                        "type": "boolean",
                                        "description": "`false` stores a draft no class sees."
                                    },
                                    "updated_at": {
                                        "type": "string",
                                        "format": "date-time",
                                        "description": "Precondition, compared to the second."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "complete",
                                        "incomplete",
                                        "block"
                                    ],
                                    "properties": {
                                        "complete": {
                                            "type": "boolean"
                                        },
                                        "incomplete": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "type": "string"
                                            },
                                            "description": "Why the block cannot be answered yet, by path."
                                        },
                                        "block": {
                                            "$ref": "#/components/schemas/ToolBlock"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}/blocks/{block}/draft": {
            "get": {
                "operationId": "getDraft",
                "summary": "The person's own draft and own handed-in answer. Handing in deletes the draft, so a draft beside an answer is newer.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "draft",
                                        "response"
                                    ],
                                    "properties": {
                                        "draft": {
                                            "oneOf": [
                                                {
                                                    "type": "null"
                                                },
                                                {
                                                    "type": "object",
                                                    "properties": {
                                                        "state": {
                                                            "type": [
                                                                "object",
                                                                "array",
                                                                "null"
                                                            ],
                                                            "description": "The tool's own working state."
                                                        },
                                                        "updated_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time"
                                                        }
                                                    }
                                                }
                                            ]
                                        },
                                        "response": {
                                            "oneOf": [
                                                {
                                                    "type": "null"
                                                },
                                                {
                                                    "$ref": "#/components/schemas/Answer"
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "put": {
                "operationId": "saveDraft",
                "summary": "Save the person's working state.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "state"
                                ],
                                "properties": {
                                    "state": {
                                        "type": [
                                            "object",
                                            "array",
                                            "null"
                                        ],
                                        "description": "At most 64 KB."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "saved": {
                                            "type": "boolean"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}/blocks/{block}/response": {
            "post": {
                "operationId": "submitResponse",
                "summary": "Hand in the result. A new answer replaces the earlier one; `score` is the tool's word, nobody checks it.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "done",
                                    "state"
                                ],
                                "properties": {
                                    "done": {
                                        "type": "boolean"
                                    },
                                    "score": {
                                        "type": [
                                            "number",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "description": "At most `max_score`; needs `max_score`."
                                    },
                                    "max_score": {
                                        "type": [
                                            "number",
                                            "null"
                                        ],
                                        "exclusiveMinimum": 0
                                    },
                                    "state": {
                                        "type": [
                                            "object",
                                            "array",
                                            "null"
                                        ],
                                        "description": "At most 64 KB."
                                    },
                                    "attachments": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "maxItems": 20,
                                        "items": {
                                            "$ref": "#/components/schemas/Ulid"
                                        },
                                        "description": "ULIDs from the upload route."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean",
                                            "const": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}/blocks/{block}/response/{response}": {
            "get": {
                "operationId": "getResponse",
                "summary": "Mode `review`: read one answer of the class. An answer that is gone is 404 `withdrawn`.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/response"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Answer"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "ulid": {
                                                    "$ref": "#/components/schemas/Ulid"
                                                },
                                                "alias": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ],
                                                    "description": "The pupil's pseudonym."
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}/blocks/{block}/attachments": {
            "post": {
                "operationId": "uploadAttachment",
                "summary": "Upload a file to hand in with the result; its ULID goes into `attachments` of the answer.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "type",
                                    "attachment"
                                ],
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "const": "file"
                                    },
                                    "attachment": {
                                        "type": "string",
                                        "contentMediaType": "application/octet-stream"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ulid": {
                                            "$ref": "#/components/schemas/Ulid"
                                        },
                                        "url": {
                                            "type": "string",
                                            "format": "uri"
                                        },
                                        "filename": {
                                            "type": "string"
                                        },
                                        "type": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/assignments/{assignment}/events": {
            "post": {
                "operationId": "recordEvents",
                "summary": "Report learning events in a lesson. Person and tool are the token's; a call is stored whole or not at all.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/assignment"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/Events"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Recorded"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/events": {
            "post": {
                "operationId": "recordFreeEvents",
                "summary": "Report learning events outside a lesson: no `block`, as `object` only an own `record`.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/Events"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Recorded"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/blocks/{block}/note": {
            "get": {
                "operationId": "getNote",
                "summary": "The person's own note under the block.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Note"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "put": {
                "operationId": "saveNote",
                "summary": "Save the note; empty or null deletes it.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/block"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "note"
                                ],
                                "properties": {
                                    "note": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 10000
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Note"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/me": {
            "get": {
                "operationId": "getMe",
                "summary": "Who is signed in and what her subscription unlocks.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Me"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/me/assignments": {
            "get": {
                "operationId": "listMyAssignments",
                "summary": "The person's assignments whose medium holds a block of this tool, and those of a course whose lessons link to such a medium: her classes (as a teacher those she teaches) and the links of shared media she has answered on. By deadline (none last), then the newest. Nothing of another tool; a class only by its name.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                        }
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "items",
                                        "page",
                                        "per_page",
                                        "total"
                                    ],
                                    "properties": {
                                        "items": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/ToolAssignment"
                                            }
                                        },
                                        "page": {
                                            "type": "integer",
                                            "minimum": 1
                                        },
                                        "per_page": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "maximum": 100
                                        },
                                        "total": {
                                            "type": "integer",
                                            "minimum": 0
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/links/resolve": {
            "get": {
                "operationId": "resolveLink",
                "summary": "Open a Stundentakt address a person pasted (`/d/…`, `/m/…`, a stage, a live round, a short link or a code alone; absolute on this origin or its short domain, or relative) as the assignment she works on there. Anything she cannot reach, or without a block of this tool, is 404 `not_found`; whether the medium exists is never told.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "name": "url",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "maxLength": 2048
                        }
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ToolAssignment"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/logout": {
            "post": {
                "operationId": "logout",
                "summary": "Revoke the person's access and refresh tokens in every tool.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "revoked": {
                                            "type": "integer",
                                            "minimum": 0
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/collections/{collection}/records": {
            "get": {
                "operationId": "listRecords",
                "summary": "The person's own records of a collection; with `scope=shared` those of others she may read.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/collection"
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "-updated",
                                "updated",
                                "-created",
                                "created"
                            ],
                            "default": "-updated"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                        }
                    },
                    {
                        "name": "scope",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "shared"
                            ]
                        }
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "items",
                                        "page",
                                        "per_page",
                                        "total"
                                    ],
                                    "properties": {
                                        "items": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Record"
                                            }
                                        },
                                        "page": {
                                            "type": "integer",
                                            "minimum": 1
                                        },
                                        "per_page": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "maximum": 100
                                        },
                                        "total": {
                                            "type": "integer",
                                            "minimum": 0
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "post": {
                "operationId": "createRecord",
                "summary": "Create a record.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/collection"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "data"
                                ],
                                "properties": {
                                    "data": {
                                        "type": [
                                            "object",
                                            "array"
                                        ],
                                        "description": "At most 64 KB of UTF-8 JSON; Stundentakt never reads it."
                                    },
                                    "schema": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 1,
                                        "description": "The tool's own format number."
                                    },
                                    "visibility": {
                                        "type": "string",
                                        "enum": [
                                            "private",
                                            "group",
                                            "team",
                                            "public"
                                        ],
                                        "default": "private"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Record"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/collections/{collection}/records/{record}": {
            "get": {
                "operationId": "getRecord",
                "summary": "Read an own or shared record. One the person may not read is 404, never 403.",
                "security": [
                    {
                        "oauth2": [
                            "tools:read"
                        ]
                    },
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/collection"
                    },
                    {
                        "$ref": "#/components/parameters/record"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Record"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "patch": {
                "operationId": "updateRecord",
                "summary": "Change an own record. `updated_at` as last read is required; a change since is 409 `conflict` with the current `record`.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/collection"
                    },
                    {
                        "$ref": "#/components/parameters/record"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "updated_at"
                                ],
                                "properties": {
                                    "data": {
                                        "type": [
                                            "object",
                                            "array"
                                        ],
                                        "description": "At most 64 KB of UTF-8 JSON; Stundentakt never reads it."
                                    },
                                    "schema": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 1,
                                        "description": "The tool's own format number."
                                    },
                                    "visibility": {
                                        "type": "string",
                                        "enum": [
                                            "private",
                                            "group",
                                            "team",
                                            "public"
                                        ],
                                        "default": "private"
                                    },
                                    "updated_at": {
                                        "type": "string",
                                        "format": "date-time",
                                        "description": "Compared to the microsecond."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Record"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "delete": {
                "operationId": "deleteRecord",
                "summary": "Delete an own record.",
                "security": [
                    {
                        "oauth2": [
                            "tools:write"
                        ]
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/collection"
                    },
                    {
                        "$ref": "#/components/parameters/record"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted."
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/records/{record}": {
            "get": {
                "operationId": "getPublicRecord",
                "summary": "Read a public record without a token. Anything else is 404.",
                "security": [],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/record"
                    },
                    {
                        "$ref": "#/components/parameters/AcceptLanguage"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Record"
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "oauth2": {
                "type": "oauth2",
                "description": "Authorization code with PKCE (RFC 7636, `code_challenge_method=S256` only) for a public client without secret: the `client_id` is the one shown at the tool's entry. `prompt=none` asks silently and returns `error=login_required` when nobody is signed in. Access tokens last 15 minutes, refresh tokens rotate. Send `Authorization: Bearer <access_token>`.",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://stundentakt.net/oauth/authorize",
                        "tokenUrl": "https://stundentakt.net/oauth/token",
                        "refreshUrl": "https://stundentakt.net/oauth/token",
                        "scopes": {
                            "tools:read": "Read only: mode `review`.",
                            "tools:write": "Read and write: modes `learn` and `author`."
                        }
                    }
                }
            }
        },
        "parameters": {
            "document": {
                "name": "document",
                "in": "path",
                "required": true,
                "description": "The medium, as the launch URL names it.",
                "schema": {
                    "$ref": "#/components/schemas/Ulid"
                }
            },
            "assignment": {
                "name": "assignment",
                "in": "path",
                "required": true,
                "description": "The assignment, as the launch URL names it.",
                "schema": {
                    "$ref": "#/components/schemas/Ulid"
                }
            },
            "block": {
                "name": "block",
                "in": "path",
                "required": true,
                "description": "A block of this tool.",
                "schema": {
                    "$ref": "#/components/schemas/Ulid"
                }
            },
            "response": {
                "name": "response",
                "in": "path",
                "required": true,
                "description": "An answer of the class, as the launch URL of a review names it.",
                "schema": {
                    "$ref": "#/components/schemas/Ulid"
                }
            },
            "record": {
                "name": "record",
                "in": "path",
                "required": true,
                "description": "A record.",
                "schema": {
                    "$ref": "#/components/schemas/Ulid"
                }
            },
            "collection": {
                "name": "collection",
                "in": "path",
                "required": true,
                "description": "A name the tool chooses for a kind of data.",
                "schema": {
                    "type": "string",
                    "pattern": "^[a-z0-9_-]{1,64}$"
                }
            },
            "AcceptLanguage": {
                "name": "Accept-Language",
                "in": "header",
                "required": false,
                "description": "The `lang` of the launch URL; it sets the language of `message` and `plan_name`.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "de",
                        "en"
                    ]
                }
            }
        },
        "schemas": {
            "Ulid": {
                "type": "string",
                "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$",
                "description": "A ULID; the API never shows an internal number."
            },
            "Error": {
                "type": "object",
                "required": [
                    "message",
                    "reason"
                ],
                "properties": {
                    "reason": {
                        "type": "string",
                        "enum": [
                            "token_expired",
                            "token_revoked",
                            "token_invalid",
                            "wrong_scope",
                            "wrong_origin",
                            "tool_unavailable",
                            "forbidden",
                            "guest_not_supported",
                            "not_found",
                            "withdrawn",
                            "conflict",
                            "invalid",
                            "too_large",
                            "quota_exceeded",
                            "no_storage",
                            "not_open",
                            "too_many_requests",
                            "maintenance"
                        ],
                        "description": "Decide by this code:\n- `token_expired` (401): The access token has expired. Refresh it.\n- `token_revoked` (401): The access token was revoked. Sign in again.\n- `token_invalid` (401): The access token is missing or not one of a learning tool.\n- `wrong_scope` (403): This token may only read.\n- `wrong_origin` (403): The request does not come from the tool’s own address.\n- `tool_unavailable` (403): The learning tool is blocked or no longer exists.\n- `forbidden` (403): You may not do this here.\n- `guest_not_supported` (403): A guest is not signed in for a learning tool.\n- `not_found` (404): Not found.\n- `withdrawn` (404): This answer was taken back or removed.\n- `conflict` (409): It has changed since it was read.\n- `invalid` (422): The request does not fit.\n- `too_large` (413): A state, task, hidden part or record may not be larger than 64 KB.\n- `quota_exceeded` (413): The storage for records is full.\n- `no_storage` (403): Without a class there is no storage for records.\n- `not_open` (422): The class does not take an answer now.\n- `too_many_requests` (429): Too many requests. Wait a moment.\n- `maintenance` (503): Stundentakt is down for maintenance. Try again later."
                    },
                    "message": {
                        "type": "string",
                        "description": "For a log, in the language of the request; never decide by it."
                    },
                    "detail": {
                        "type": "string",
                        "enum": [
                            "not_yet",
                            "closed",
                            "wrong_mode"
                        ],
                        "description": "With `not_open`: why the class takes no answer now."
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "description": "With `invalid`, `too_large` and `not_open`: the fields."
                    },
                    "block": {
                        "$ref": "#/components/schemas/ToolBlock",
                        "description": "With `conflict` on a block: its current state."
                    },
                    "record": {
                        "$ref": "#/components/schemas/Record",
                        "description": "With `conflict` on a record: its current state."
                    }
                }
            },
            "ToolBlock": {
                "type": "object",
                "required": [
                    "ulid",
                    "type",
                    "payload",
                    "updated_at"
                ],
                "properties": {
                    "ulid": {
                        "$ref": "#/components/schemas/Ulid"
                    },
                    "type": {
                        "type": "string",
                        "const": "tool"
                    },
                    "payload": {
                        "type": "object",
                        "properties": {
                            "tool": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "title": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "task": {
                                "type": [
                                    "object",
                                    "array",
                                    "null"
                                ],
                                "description": "The task the author wrote with the tool."
                            },
                            "display": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "inline",
                                    "full",
                                    null
                                ],
                                "description": "In the page (`inline`) or in a tab of its own (`full`); `null` follows the tool's entry."
                            }
                        }
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "hidden": {
                        "type": [
                            "object",
                            "array",
                            "null"
                        ],
                        "description": "Only for a person who may change the block."
                    }
                }
            },
            "Content": {
                "type": "array",
                "description": "The whole medium in page order, each child right after its parent.",
                "items": {
                    "type": "object",
                    "required": [
                        "ulid",
                        "type",
                        "position",
                        "parent",
                        "own"
                    ],
                    "properties": {
                        "ulid": {
                            "$ref": "#/components/schemas/Ulid"
                        },
                        "type": {
                            "type": "string"
                        },
                        "position": {
                            "type": "integer"
                        },
                        "parent": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "$ref": "#/components/schemas/Ulid"
                                }
                            ]
                        },
                        "own": {
                            "type": "boolean",
                            "description": "`true`: a block of this tool in the form of `ToolBlock`."
                        },
                        "payload": {
                            "type": "object",
                            "description": "Own blocks, and others for a person who may change them."
                        },
                        "hidden": {
                            "type": [
                                "object",
                                "array",
                                "null"
                            ],
                            "description": "Own blocks, for a person who may change them."
                        },
                        "updated_at": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "date-time"
                        },
                        "text": {
                            "type": "string",
                            "description": "Other blocks: the readable Markdown version."
                        },
                        "images": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "Signed, valid for five minutes, loads without a cookie."
                                    },
                                    "alt": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    }
                                }
                            }
                        },
                        "solution": {
                            "type": "object",
                            "description": "Only where the app shows the solution."
                        },
                        "medium": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "ulid": {
                                            "$ref": "#/components/schemas/Ulid"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "type": {
                                            "type": "string"
                                        },
                                        "assignment": {
                                            "oneOf": [
                                                {
                                                    "type": "null"
                                                },
                                                {
                                                    "$ref": "#/components/schemas/Ulid"
                                                }
                                            ]
                                        },
                                        "progress": {
                                            "$ref": "#/components/schemas/Progress"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "ToolAssignment": {
                "type": "object",
                "required": [
                    "assignment",
                    "role",
                    "document",
                    "group",
                    "mode",
                    "open_from",
                    "closes_at",
                    "open",
                    "progress",
                    "last_activity",
                    "blocks"
                ],
                "properties": {
                    "assignment": {
                        "$ref": "#/components/schemas/Ulid"
                    },
                    "role": {
                        "type": "string",
                        "enum": [
                            "teacher",
                            "student",
                            "guest"
                        ]
                    },
                    "document": {
                        "type": "object",
                        "required": [
                            "ulid",
                            "name",
                            "type"
                        ],
                        "properties": {
                            "ulid": {
                                "$ref": "#/components/schemas/Ulid"
                            },
                            "name": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            }
                        }
                    },
                    "group": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    }
                                }
                            }
                        ],
                        "description": "The class by its name alone; `null` on a link."
                    },
                    "mode": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "open_from": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "closes_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "open": {
                        "type": "boolean",
                        "description": "Whether the class takes answers now."
                    },
                    "progress": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "$ref": "#/components/schemas/Progress"
                            }
                        ],
                        "description": "The person's own; `null` for the teacher of the class. A course sums its own tasks and every medium in `lessons` once."
                    },
                    "last_activity": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "When the person last answered, saved a draft or this tool reported an event here (a course: also in its media); `null` before that and for the teacher of the class."
                    },
                    "blocks": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Ulid"
                        },
                        "description": "This tool's blocks in the medium."
                    },
                    "lessons": {
                        "type": "array",
                        "description": "Courses only: the lessons linking to media with a block of this tool.",
                        "items": {
                            "type": "object",
                            "properties": {
                                "ulid": {
                                    "$ref": "#/components/schemas/Ulid"
                                },
                                "topic": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "media": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "ulid": {
                                                "$ref": "#/components/schemas/Ulid"
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "type": {
                                                "type": "string"
                                            },
                                            "assignment": {
                                                "oneOf": [
                                                    {
                                                        "type": "null"
                                                    },
                                                    {
                                                        "$ref": "#/components/schemas/Ulid"
                                                    }
                                                ]
                                            },
                                            "progress": {
                                                "$ref": "#/components/schemas/Progress"
                                            },
                                            "blocks": {
                                                "type": "array",
                                                "items": {
                                                    "$ref": "#/components/schemas/Ulid"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "Progress": {
                "type": "object",
                "required": [
                    "done",
                    "total",
                    "blocks"
                ],
                "properties": {
                    "done": {
                        "type": "integer",
                        "minimum": 0
                    },
                    "total": {
                        "type": "integer",
                        "minimum": 0
                    },
                    "blocks": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "ulid": {
                                    "$ref": "#/components/schemas/Ulid"
                                },
                                "done": {
                                    "type": "boolean"
                                }
                            }
                        }
                    }
                }
            },
            "Answer": {
                "type": "object",
                "required": [
                    "payload",
                    "submitted_at",
                    "returned"
                ],
                "properties": {
                    "payload": {
                        "type": "object",
                        "properties": {
                            "done": {
                                "type": "boolean"
                            },
                            "score": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "max_score": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "state": {
                                "type": [
                                    "object",
                                    "array",
                                    "null"
                                ],
                                "description": "The state handed in."
                            }
                        }
                    },
                    "submitted_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "returned": {
                        "type": "boolean"
                    }
                }
            },
            "Events": {
                "type": "object",
                "required": [
                    "events"
                ],
                "properties": {
                    "events": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 100,
                        "items": {
                            "$ref": "#/components/schemas/Event"
                        }
                    }
                }
            },
            "Event": {
                "type": "object",
                "description": "Shaped after an xAPI statement (actor, verb, object, result, timestamp) without a learning record store; the actor is always the token's person.",
                "required": [
                    "verb"
                ],
                "properties": {
                    "block": {
                        "$ref": "#/components/schemas/Ulid",
                        "description": "A block of this tool in the assignment; not allowed on `/events`."
                    },
                    "verb": {
                        "type": "string",
                        "maxLength": 40,
                        "description": "Free; recommended: `run`, `error` (with `code`), `step`, `submit`, `reset`."
                    },
                    "code": {
                        "type": "string",
                        "maxLength": 80
                    },
                    "object": {
                        "type": "object",
                        "required": [
                            "type",
                            "id"
                        ],
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "block",
                                    "record"
                                ]
                            },
                            "id": {
                                "$ref": "#/components/schemas/Ulid"
                            }
                        }
                    },
                    "result": {
                        "type": "object",
                        "description": "At most 2 KB of JSON.",
                        "properties": {
                            "success": {
                                "type": "boolean"
                            },
                            "score": {
                                "oneOf": [
                                    {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 1
                                    },
                                    {
                                        "type": "object",
                                        "properties": {
                                            "raw": {
                                                "type": "number"
                                            },
                                            "min": {
                                                "type": "number"
                                            },
                                            "max": {
                                                "type": "number"
                                            },
                                            "scaled": {
                                                "type": "number",
                                                "minimum": 0,
                                                "maximum": 1
                                            }
                                        }
                                    }
                                ]
                            },
                            "duration": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "description": "ISO 8601 duration such as `PT1M30.5S`, up to `P30D`."
                                    },
                                    {
                                        "type": "integer",
                                        "minimum": 0,
                                        "description": "Milliseconds."
                                    }
                                ]
                            }
                        }
                    },
                    "timestamp": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Clamped to the last 24 hours."
                    }
                }
            },
            "Recorded": {
                "type": "object",
                "required": [
                    "recorded"
                ],
                "properties": {
                    "recorded": {
                        "type": "integer",
                        "minimum": 0
                    }
                }
            },
            "Note": {
                "type": "object",
                "required": [
                    "note"
                ],
                "properties": {
                    "note": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "maxLength": 10000
                    }
                }
            },
            "Record": {
                "type": "object",
                "required": [
                    "id",
                    "collection",
                    "data",
                    "schema",
                    "visibility",
                    "created_at",
                    "updated_at",
                    "owner"
                ],
                "properties": {
                    "id": {
                        "$ref": "#/components/schemas/Ulid"
                    },
                    "collection": {
                        "type": "string",
                        "pattern": "^[a-z0-9_-]{1,64}$"
                    },
                    "data": {
                        "type": [
                            "object",
                            "array"
                        ],
                        "description": "At most 64 KB of UTF-8 JSON; Stundentakt never reads it."
                    },
                    "schema": {
                        "type": "integer",
                        "minimum": 1,
                        "default": 1,
                        "description": "The tool's own format number."
                    },
                    "visibility": {
                        "type": "string",
                        "enum": [
                            "private",
                            "group",
                            "team",
                            "public"
                        ],
                        "default": "private"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "UTC with microseconds; send it back unchanged as the precondition."
                    },
                    "owner": {
                        "type": "object",
                        "required": [
                            "kind",
                            "alias",
                            "self"
                        ],
                        "properties": {
                            "kind": {
                                "type": "string",
                                "enum": [
                                    "student",
                                    "teacher"
                                ]
                            },
                            "alias": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "A pupil's pseudonym or a teacher's attribution, never an email address."
                            },
                            "self": {
                                "type": "boolean"
                            }
                        }
                    }
                }
            },
            "Me": {
                "type": "object",
                "required": [
                    "kind",
                    "alias",
                    "profile_url",
                    "entitlements"
                ],
                "properties": {
                    "kind": {
                        "type": "string",
                        "enum": [
                            "user",
                            "member"
                        ]
                    },
                    "alias": {
                        "type": "string",
                        "description": "A pupil's pseudonym or a teacher's attribution; never a pupil's real name, an email address or an id."
                    },
                    "profile_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Where the person manages herself in Stundentakt: a teacher's settings, a pupil's own area. Open it in a new tab."
                    },
                    "entitlements": {
                        "type": "object",
                        "required": [
                            "plan",
                            "plan_name",
                            "features",
                            "ai",
                            "records"
                        ],
                        "properties": {
                            "plan": {
                                "type": "string",
                                "enum": [
                                    "free",
                                    "pro",
                                    "premium"
                                ]
                            },
                            "plan_name": {
                                "type": "string"
                            },
                            "features": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "boolean"
                                },
                                "description": "A missing switch is open."
                            },
                            "ai": {
                                "oneOf": [
                                    {
                                        "type": "null"
                                    },
                                    {
                                        "type": "object",
                                        "properties": {
                                            "monthly_tokens": {
                                                "type": "integer",
                                                "minimum": 0
                                            },
                                            "remaining_tokens": {
                                                "type": "integer",
                                                "minimum": 0
                                            }
                                        }
                                    }
                                ]
                            },
                            "records": {
                                "type": "object",
                                "properties": {
                                    "limit_bytes": {
                                        "type": "integer",
                                        "minimum": 0
                                    },
                                    "own_bytes": {
                                        "type": "integer",
                                        "minimum": 0
                                    },
                                    "record_max_bytes": {
                                        "type": "integer",
                                        "const": 65536
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "responses": {
            "Error": {
                "description": "A refusal. The status follows `reason`; `Retry-After` comes with 429 and 503.",
                "headers": {
                    "Retry-After": {
                        "schema": {
                            "type": "integer",
                            "minimum": 0
                        }
                    }
                },
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        }
    }
}