{
  "openapi": "3.1.0",
  "info": {
    "title": "NPmonstret öppna fråge-API",
    "version": "2",
    "summary": "Övningsfrågor i NP-format, CC BY-NC 4.0. Ingen nyckel, ingen inloggning.",
    "description": "Läs-API för den här månadens urval av övningsfrågor i NP-format från NPmonstret. Frågorna är övningsfrågor, inte nationella prov. `list_questions` ger inget facit; `GET /api/v1/questions/{id}` ger facit och förklaring. Alla svar har samma kuvert med licens och attribution. Ange alltid attributionen med länk till npmonstret.se. Samma verktyg finns som MCP-server på https://npmonstret.se/api/mcp (Streamable HTTP, POST, JSON-svar). Dokumentation på svenska: https://npmonstret.se/utvecklare/api.",
    "license": {
      "name": "CC BY-NC 4.0",
      "url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv"
    },
    "contact": {
      "name": "NPmonstret",
      "email": "hej@npmonstret.se",
      "url": "https://npmonstret.se/utvecklare/api"
    }
  },
  "externalDocs": {
    "description": "Dokumentation (svenska)",
    "url": "https://npmonstret.se/utvecklare/api"
  },
  "servers": [
    {
      "url": "https://npmonstret.se"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "Frågor",
      "description": "Kurser och övningsfrågor i den här månadens urval."
    }
  ],
  "paths": {
    "/api/v1/courses": {
      "description": "Tillåtna metoder: GET, OPTIONS (HEAD svarar som GET). POST, PUT, PATCH, DELETE ger 405 utan body, med Allow: GET, OPTIONS och Cache-Control: no-store.",
      "get": {
        "operationId": "list_courses",
        "summary": "Lista kurser",
        "description": "Kurser som har frågor i den här månadens urval, sorterade på course_slug. Inga parametrar tillåts.",
        "tags": [
          "Frågor"
        ],
        "responses": {
          "200": {
            "description": "ready med kurslistan, eller empty med data [] och message «Inga frågor publicerade den här månaden.».",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlOk"
              },
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EnvelopeBase"
                    },
                    {
                      "type": "object",
                      "required": [
                        "state",
                        "data"
                      ],
                      "properties": {
                        "state": {
                          "type": "string",
                          "enum": [
                            "ready",
                            "empty"
                          ]
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Course"
                          }
                        },
                        "message": {
                          "type": "string",
                          "description": "Finns bara när state är empty.",
                          "enum": [
                            "Inga frågor publicerade den här månaden.",
                            "Inga frågor publicerade för kursen den här månaden."
                          ]
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "state": "ready",
                  "data": [
                    {
                      "course_slug": "matematik-ak9",
                      "subject": "matematik",
                      "release_id": "2026-11",
                      "count": 5,
                      "course_url": "https://npmonstret.se/nationella-prov/matematik-ak9?utm_source=npmonstret-api&utm_medium=http&utm_campaign=urval-2026-11&utm_content=kurslista"
                    }
                  ],
                  "license": "CC BY-NC 4.0",
                  "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                  "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "source_url": "https://npmonstret.se/",
                  "release_id": "2026-11",
                  "api_version": "2",
                  "request_id": "00000000-0000-4000-8000-000000000000"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_param`: Okänd parameter, upprepad parameter, tomt värde, värde längre än 64 tecken, fel format på course eller id, eller level som inte är E, C eller A.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalid_param": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "invalid_param",
                        "message": "Okänd eller ogiltig parameter."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_param`: Parametrarna student, class, user, email och answer är aldrig tillåtna (oavsett stora eller små bokstäver).",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "forbidden_param": {
                    "value": {
                      "state": "unauthorized",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "forbidden_param",
                        "message": "Parametern är inte tillåten i det öppna API:t."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Off"
          },
          "429": {
            "description": "`rate_limited`: För många anrop. Vänta det antal sekunder som Retry-After anger.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rate_limited": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "rate_limited",
                        "message": "För många anrop. Vänta och försök igen."
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "`warming_up`: API:t startar eller svarar inte just nu. Försök igen efter Retry-After (5 sekunder). `disabled`: API:t är inte tillgängligt just nu (driftfel). Försök igen senare.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "warming_up": {
                    "value": {
                      "state": "loading",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "warming_up",
                        "message": "API:t startar. Försök igen om några sekunder."
                      }
                    }
                  },
                  "disabled": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "disabled",
                        "message": "API:t är inte tillgängligt just nu."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "list_courses_options",
        "summary": "CORS-förfrågan",
        "tags": [
          "Frågor"
        ],
        "responses": {
          "204": {
            "description": "Svar på CORS-förfrågan. Ingen body.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              },
              "Access-Control-Allow-Methods": {
                "schema": {
                  "type": "string",
                  "const": "GET, OPTIONS"
                }
              },
              "Access-Control-Allow-Headers": {
                "schema": {
                  "type": "string",
                  "const": "content-type, accept, mcp-protocol-version"
                }
              },
              "Access-Control-Max-Age": {
                "schema": {
                  "type": "string",
                  "const": "86400"
                }
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            }
          }
        }
      }
    },
    "/api/v1/questions": {
      "description": "Tillåtna metoder: GET, OPTIONS (HEAD svarar som GET). POST, PUT, PATCH, DELETE ger 405 utan body, med Allow: GET, OPTIONS och Cache-Control: no-store.",
      "get": {
        "operationId": "list_questions",
        "summary": "Lista frågor för en kurs (utan facit)",
        "description": "Högst 5 frågor för en kurs, sorterade på nivå (E, C, A) och sedan id. Svaret saknar facit och förklaring. Alternativen står i den ordning som gäller för facit i get_question.",
        "tags": [
          "Frågor"
        ],
        "parameters": [
          {
            "name": "course",
            "in": "query",
            "required": true,
            "description": "Kurs-slug, t.ex. matematik-ak9. Se /api/v1/courses för kurser med frågor.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
              "minLength": 1,
              "maxLength": 64
            },
            "example": "matematik-ak9"
          },
          {
            "name": "level",
            "in": "query",
            "required": false,
            "description": "Valfri nivå.",
            "schema": {
              "type": "string",
              "enum": [
                "E",
                "C",
                "A"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ready med frågorna, eller empty med data [] och message «Inga frågor publicerade för kursen den här månaden.» när kursen finns men saknar frågor (för vald nivå) den här månaden.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlOk"
              },
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EnvelopeBase"
                    },
                    {
                      "type": "object",
                      "required": [
                        "state",
                        "data"
                      ],
                      "properties": {
                        "state": {
                          "type": "string",
                          "enum": [
                            "ready",
                            "empty"
                          ]
                        },
                        "data": {
                          "type": "array",
                          "maxItems": 5,
                          "items": {
                            "$ref": "#/components/schemas/Question"
                          }
                        },
                        "message": {
                          "type": "string",
                          "description": "Finns bara när state är empty.",
                          "enum": [
                            "Inga frågor publicerade den här månaden.",
                            "Inga frågor publicerade för kursen den här månaden."
                          ]
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "state": "ready",
                  "data": [
                    {
                      "id": "00000000-0000-4000-8000-000000000001",
                      "version": "0123456789ab",
                      "level": "E",
                      "topic": "Exempelområde",
                      "question": "Exempel på frågetext.",
                      "options": [
                        "Alternativ 1",
                        "Alternativ 2",
                        "Alternativ 3",
                        "Alternativ 4"
                      ],
                      "course_url": "https://npmonstret.se/nationella-prov/matematik-ak9?utm_source=npmonstret-api&utm_medium=http&utm_campaign=urval-2026-11&utm_content=00000000"
                    }
                  ],
                  "license": "CC BY-NC 4.0",
                  "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                  "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "source_url": "https://npmonstret.se/",
                  "release_id": "2026-11",
                  "api_version": "2",
                  "request_id": "00000000-0000-4000-8000-000000000000"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_param`: Okänd parameter, upprepad parameter, tomt värde, värde längre än 64 tecken, fel format på course eller id, eller level som inte är E, C eller A.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalid_param": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "invalid_param",
                        "message": "Okänd eller ogiltig parameter."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_param`: Parametrarna student, class, user, email och answer är aldrig tillåtna (oavsett stora eller små bokstäver).",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "forbidden_param": {
                    "value": {
                      "state": "unauthorized",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "forbidden_param",
                        "message": "Parametern är inte tillåten i det öppna API:t."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`unknown_course`: Kursen finns inte. Är API:t avstängt blir svaret i stället en tom 404 utan body (Cache-Control: no-store).",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unknown_course": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "unknown_course",
                        "message": "Kursen finns inte."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: För många anrop. Vänta det antal sekunder som Retry-After anger.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rate_limited": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "rate_limited",
                        "message": "För många anrop. Vänta och försök igen."
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "`warming_up`: API:t startar eller svarar inte just nu. Försök igen efter Retry-After (5 sekunder). `disabled`: API:t är inte tillgängligt just nu (driftfel). Försök igen senare.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "warming_up": {
                    "value": {
                      "state": "loading",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "warming_up",
                        "message": "API:t startar. Försök igen om några sekunder."
                      }
                    }
                  },
                  "disabled": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "disabled",
                        "message": "API:t är inte tillgängligt just nu."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "list_questions_options",
        "summary": "CORS-förfrågan",
        "tags": [
          "Frågor"
        ],
        "responses": {
          "204": {
            "description": "Svar på CORS-förfrågan. Ingen body.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              },
              "Access-Control-Allow-Methods": {
                "schema": {
                  "type": "string",
                  "const": "GET, OPTIONS"
                }
              },
              "Access-Control-Allow-Headers": {
                "schema": {
                  "type": "string",
                  "const": "content-type, accept, mcp-protocol-version"
                }
              },
              "Access-Control-Max-Age": {
                "schema": {
                  "type": "string",
                  "const": "86400"
                }
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            }
          }
        }
      }
    },
    "/api/v1/questions/{id}": {
      "description": "Tillåtna metoder: GET, OPTIONS (HEAD svarar som GET). POST, PUT, PATCH, DELETE ger 405 utan body, med Allow: GET, OPTIONS och Cache-Control: no-store.",
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Frågans id (uuid) från list_questions. Stora bokstäver godtas.",
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "get_question",
        "summary": "Hämta en fråga med facit",
        "description": "En fråga ur den här månadens urval, med facit och förklaring. Inga query-parametrar tillåts. correct_index är nollbaserat och pekar in i options.",
        "tags": [
          "Frågor"
        ],
        "responses": {
          "200": {
            "description": "ready med frågan, facit och förklaring.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlOk"
              },
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EnvelopeBase"
                    },
                    {
                      "type": "object",
                      "required": [
                        "state",
                        "data"
                      ],
                      "properties": {
                        "state": {
                          "type": "string",
                          "enum": [
                            "ready",
                            "empty"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/QuestionWithAnswer"
                        },
                        "message": {
                          "type": "string",
                          "description": "Finns bara när state är empty.",
                          "enum": [
                            "Inga frågor publicerade den här månaden.",
                            "Inga frågor publicerade för kursen den här månaden."
                          ]
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "state": "ready",
                  "data": {
                    "id": "00000000-0000-4000-8000-000000000001",
                    "version": "0123456789ab",
                    "level": "E",
                    "topic": "Exempelområde",
                    "question": "Exempel på frågetext.",
                    "options": [
                      "Alternativ 1",
                      "Alternativ 2",
                      "Alternativ 3",
                      "Alternativ 4"
                    ],
                    "course_url": "https://npmonstret.se/nationella-prov/matematik-ak9?utm_source=npmonstret-api&utm_medium=http&utm_campaign=urval-2026-11&utm_content=00000000",
                    "correct_index": 0,
                    "correct_answer": "Alternativ 1",
                    "explanation": "Exempel på förklaring."
                  },
                  "license": "CC BY-NC 4.0",
                  "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                  "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                  "source_url": "https://npmonstret.se/",
                  "release_id": "2026-11",
                  "api_version": "2",
                  "request_id": "00000000-0000-4000-8000-000000000000"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_param`: Okänd parameter, upprepad parameter, tomt värde, värde längre än 64 tecken, fel format på course eller id, eller level som inte är E, C eller A.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalid_param": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "invalid_param",
                        "message": "Okänd eller ogiltig parameter."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_param`: Parametrarna student, class, user, email och answer är aldrig tillåtna (oavsett stora eller små bokstäver).",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "forbidden_param": {
                    "value": {
                      "state": "unauthorized",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": null,
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "forbidden_param",
                        "message": "Parametern är inte tillåten i det öppna API:t."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Frågan finns inte i den här månadens urval. Är API:t avstängt blir svaret i stället en tom 404 utan body (Cache-Control: no-store).",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "not_found",
                        "message": "Frågan finns inte i den här månadens urval."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: För många anrop. Vänta det antal sekunder som Retry-After anger.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rate_limited": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "rate_limited",
                        "message": "För många anrop. Vänta och försök igen."
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "`warming_up`: API:t startar eller svarar inte just nu. Försök igen efter Retry-After (5 sekunder). `disabled`: API:t är inte tillgängligt just nu (driftfel). Försök igen senare.",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "warming_up": {
                    "value": {
                      "state": "loading",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "warming_up",
                        "message": "API:t startar. Försök igen om några sekunder."
                      }
                    }
                  },
                  "disabled": {
                    "value": {
                      "state": "error",
                      "data": null,
                      "license": "CC BY-NC 4.0",
                      "license_url": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv",
                      "attribution_md": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "attribution_html": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
                      "source_url": "https://npmonstret.se/",
                      "release_id": "2026-11",
                      "api_version": "2",
                      "request_id": "00000000-0000-4000-8000-000000000000",
                      "error": {
                        "code": "disabled",
                        "message": "API:t är inte tillgängligt just nu."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "get_question_options",
        "summary": "CORS-förfrågan",
        "tags": [
          "Frågor"
        ],
        "responses": {
          "204": {
            "description": "Svar på CORS-förfrågan. Ingen body.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Cors"
              },
              "Access-Control-Allow-Methods": {
                "schema": {
                  "type": "string",
                  "const": "GET, OPTIONS"
                }
              },
              "Access-Control-Allow-Headers": {
                "schema": {
                  "type": "string",
                  "const": "content-type, accept, mcp-protocol-version"
                }
              },
              "Access-Control-Max-Age": {
                "schema": {
                  "type": "string",
                  "const": "86400"
                }
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControlNoStore"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Off": {
        "description": "Tom 404 utan body. Ges när API:t är avstängt, och för procentkodade sökvägar under /api (t.ex. /api/v1%2Fcourses).",
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControlNoStore"
          }
        }
      }
    },
    "headers": {
      "CacheControlOk": {
        "description": "Lyckade svar (200) får cachas i upp till 5 minuter. Vercels CDN kan förkorta värdet mot klienten till «public, max-age=300».",
        "schema": {
          "type": "string",
          "examples": [
            "public, max-age=300"
          ]
        }
      },
      "CacheControlNoStore": {
        "description": "Fel och 429 cachas aldrig.",
        "schema": {
          "type": "string",
          "const": "no-store"
        }
      },
      "RetryAfter": {
        "description": "Sekunder att vänta innan nästa försök.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]+$"
        }
      },
      "Cors": {
        "description": "Öppen CORS utan credentials.",
        "schema": {
          "type": "string",
          "const": "*"
        }
      }
    },
    "schemas": {
      "EnvelopeBase": {
        "type": "object",
        "description": "Fälten som finns i varje svar med body, även vid fel.",
        "required": [
          "state",
          "data",
          "license",
          "license_url",
          "attribution_md",
          "attribution_html",
          "source_url",
          "release_id",
          "api_version",
          "request_id"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "ready",
              "empty",
              "loading",
              "unauthorized",
              "error"
            ]
          },
          "data": {},
          "license": {
            "type": "string",
            "const": "CC BY-NC 4.0"
          },
          "license_url": {
            "type": "string",
            "format": "uri",
            "const": "https://creativecommons.org/licenses/by-nc/4.0/deed.sv"
          },
          "attribution_md": {
            "type": "string",
            "const": "Fråga från [NPmonstret](https://npmonstret.se/?utm_source=npmonstret-api&utm_medium=attribution) · Licens: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.sv) · Övningsfråga i NP-format, inte ett nationellt prov.",
            "description": "Attribution i Markdown med länk till npmonstret.se."
          },
          "attribution_html": {
            "type": "string",
            "const": "Fråga från <a href=\"https://npmonstret.se/?utm_source=npmonstret-api&amp;utm_medium=attribution\">NPmonstret</a> · Licens: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.sv\" rel=\"license\">CC BY-NC 4.0</a> · Övningsfråga i NP-format, inte ett nationellt prov.",
            "description": "Attribution i HTML med länk till npmonstret.se."
          },
          "source_url": {
            "type": "string",
            "format": "uri",
            "const": "https://npmonstret.se/"
          },
          "release_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Månadens urval, t.ex. 2026-11. null när anropet stoppas redan vid valideringen."
          },
          "api_version": {
            "type": "string",
            "const": "2"
          },
          "request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Ange vid felanmälan."
          }
        }
      },
      "ErrorEnvelope": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EnvelopeBase"
          },
          {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "error",
                  "unauthorized",
                  "loading"
                ]
              },
              "data": {
                "type": "null"
              },
              "error": {
                "type": "object",
                "required": [
                  "code",
                  "message"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "invalid_param",
                      "forbidden_param",
                      "blocked",
                      "unknown_course",
                      "not_found",
                      "rate_limited",
                      "disabled",
                      "warming_up",
                      "internal_error"
                    ],
                    "description": "blocked och internal_error är reserverade och ges inte i dag."
                  },
                  "message": {
                    "type": "string",
                    "description": "Kort text på svenska."
                  }
                }
              }
            }
          }
        ]
      },
      "Course": {
        "type": "object",
        "required": [
          "course_slug",
          "subject",
          "release_id",
          "count",
          "course_url"
        ],
        "properties": {
          "course_slug": {
            "type": "string",
            "examples": [
              "matematik-ak9"
            ]
          },
          "subject": {
            "type": "string",
            "description": "Första ledet i course_slug.",
            "examples": [
              "matematik"
            ]
          },
          "release_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "description": "Antal frågor för kursen i månadens urval."
          },
          "course_url": {
            "type": "string",
            "format": "uri",
            "description": "Kurssida på npmonstret.se med utm-parametrar."
          }
        }
      },
      "Question": {
        "type": "object",
        "required": [
          "id",
          "version",
          "level",
          "topic",
          "question",
          "options",
          "course_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "string",
            "description": "Frågans version (opak sträng)."
          },
          "level": {
            "type": "string",
            "enum": [
              "E",
              "C",
              "A"
            ]
          },
          "topic": {
            "type": "string"
          },
          "question": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "course_url": {
            "type": "string",
            "format": "uri",
            "description": "Kurssida på npmonstret.se med utm-parametrar."
          }
        }
      },
      "QuestionWithAnswer": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Question"
          },
          {
            "type": "object",
            "required": [
              "correct_index",
              "correct_answer",
              "explanation"
            ],
            "properties": {
              "correct_index": {
                "type": "integer",
                "minimum": 0,
                "description": "Nollbaserat index i options."
              },
              "correct_answer": {
                "type": "string",
                "description": "Samma text som options[correct_index]."
              },
              "explanation": {
                "type": "string"
              }
            }
          }
        ]
      }
    }
  }
}
