{
  "openapi": "3.1.1",
  "info": {
    "title": "Rapportly API — fictieve testomgeving",
    "version": "1.0.0-draft",
    "description": "Drie simulatorroutes. Geen klantinhoud, bestanden, provider, credits, verzending of webhooks. Dit is geen specificatie van alle productieacties."
  },
  "x-rapportly-status": "fictieve-simulator-geen-productieacties",
  "servers": [
    {
      "url": "https://api.rapportly.io/api/rapportly/v1"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/test/scenarios": {
      "get": {
        "responses": {
          "200": {
            "description": "Alleen de voor deze testsleutel beschikbare actie-ids en vaste scenarios.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Scenarios"
                }
              }
            }
          },
          "400": {
            "description": "Corrigeer de invoer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende, ongeldige of verkeerde omgevingssleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "403": {
            "description": "Gebruiker, sleutel of pakket weigert toegang.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "429": {
            "description": "Respecteer Retry-After voordat je hetzelfde verzoek herhaalt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "503": {
            "description": "Tijdelijk niet veilig beschikbaar; herhaal later met dezelfde sleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          }
        },
        "summary": "Beschikbare fictieve scenario-codes en actie-ids",
        "operationId": "testScenarios"
      }
    },
    "/test/opdrachten": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "scenario": "succes",
                "actie": "rapport.start"
              },
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "actie",
                  "scenario"
                ],
                "properties": {
                  "scenario": {
                    "enum": [
                      "succes",
                      "verwerking_mislukt",
                      "creditbudget_bereikt",
                      "toegang_geweigerd"
                    ]
                  },
                  "actie": {
                    "type": "string",
                    "description": "Kies een id uit GET /test/scenarios; beschikbaarheid volgt de rechten van deze testsleutel."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Gereed of mislukt. Lees status: HTTP200 alleen bewijst geen geslaagde oefenopdracht.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "202": {
            "description": "Bezig. Vraag de status na ongeveer vijf seconden opnieuw op.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "402": {
            "description": "Gesimuleerd creditbudget bereikt; er zijn geen credits afgeschreven.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "403": {
            "description": "Gesimuleerde weigering of werkelijke autorisatiefout.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/Testopdracht"
                    },
                    {
                      "$ref": "#/components/schemas/Fout"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Corrigeer de invoer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende, ongeldige of verkeerde omgevingssleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "429": {
            "description": "Respecteer Retry-After voordat je hetzelfde verzoek herhaalt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "503": {
            "description": "Tijdelijk niet veilig beschikbaar; herhaal later met dezelfde sleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "409": {
            "description": "Dezelfde Idempotency-Key is al voor een andere actie/scenario gebruikt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "required": true,
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "minLength": 8,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$",
              "maxLength": 128,
              "type": "string"
            },
            "description": "Zelfde actie/scenario: dezelfde sleutel herhalen. Andere opdracht: nieuwe sleutel."
          }
        ],
        "summary": "Start een fictieve opdracht",
        "operationId": "testOpdrachtStarten"
      }
    },
    "/test/opdrachten/{id}": {
      "get": {
        "responses": {
          "200": {
            "description": "Gereed of mislukt. Lees status: HTTP200 alleen bewijst geen geslaagde oefenopdracht.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "202": {
            "description": "Bezig. Vraag de status na ongeveer vijf seconden opnieuw op.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "402": {
            "description": "Gesimuleerd creditbudget bereikt; er zijn geen credits afgeschreven.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Testopdracht"
                }
              }
            }
          },
          "403": {
            "description": "Gesimuleerde weigering of werkelijke autorisatiefout.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/Testopdracht"
                    },
                    {
                      "$ref": "#/components/schemas/Fout"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Niet gevonden, niet van deze sleutel of na zeven dagen verlopen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "400": {
            "description": "Corrigeer de invoer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende, ongeldige of verkeerde omgevingssleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "429": {
            "description": "Respecteer Retry-After voordat je hetzelfde verzoek herhaalt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          },
          "503": {
            "description": "Tijdelijk niet veilig beschikbaar; herhaal later met dezelfde sleutel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fout"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "required": true,
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "summary": "Status van de eigen fictieve opdracht",
        "operationId": "testOpdrachtLezen"
      }
    }
  },
  "components": {
    "schemas": {
      "Fout": {
        "type": "object",
        "description": "Een poortfout kan code, detail of een error-object bevatten. Verwerk primair de HTTP-status.",
        "properties": {
          "code": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "error": {
            "type": "object"
          },
          "omgeving": {
            "const": "test"
          },
          "fictief": {
            "const": true
          }
        }
      },
      "Testopdracht": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "opdracht_id",
          "actie",
          "omgeving",
          "fictief",
          "credits",
          "aangemaakt_op",
          "verloopt_op",
          "status"
        ],
        "properties": {
          "opdracht_id": {
            "type": "string",
            "format": "uuid"
          },
          "actie": {
            "type": "string"
          },
          "omgeving": {
            "const": "test"
          },
          "fictief": {
            "const": true
          },
          "credits": {
            "const": 0
          },
          "aangemaakt_op": {
            "type": "string",
            "format": "date-time"
          },
          "verloopt_op": {
            "type": "string",
            "format": "date-time"
          },
          "herhaald": {
            "type": "boolean"
          },
          "status": {
            "enum": [
              "bezig",
              "gereed",
              "mislukt",
              "geweigerd"
            ]
          },
          "code": {
            "type": "string"
          },
          "resultaat": {
            "required": [
              "titel",
              "tekst"
            ],
            "properties": {
              "titel": {
                "const": "Fictief Rapportly-testresultaat"
              },
              "tekst": {
                "const": "Dit is vaste oefeninhoud. Er is geen klantopdracht uitgevoerd."
              }
            },
            "additionalProperties": false,
            "type": "object"
          }
        }
      },
      "Scenarios": {
        "type": "object",
        "required": [
          "omgeving",
          "fictief",
          "credits",
          "scenarios",
          "acties",
          "beperkingen",
          "geldigheid_dagen",
          "maximum_opdrachten_per_sleutel"
        ],
        "properties": {
          "omgeving": {
            "const": "test"
          },
          "fictief": {
            "const": true
          },
          "credits": {
            "const": 0
          },
          "scenarios": {
            "type": "array",
            "items": {
              "enum": [
                "succes",
                "verwerking_mislukt",
                "creditbudget_bereikt",
                "toegang_geweigerd"
              ]
            }
          },
          "acties": {
            "type": "array",
            "items": {
              "required": [
                "id",
                "recht"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "recht": {
                  "type": "string"
                }
              },
              "type": "object"
            }
          },
          "beperkingen": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "geldigheid_dagen": {
            "const": 7
          },
          "maximum_opdrachten_per_sleutel": {
            "const": 1000
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "bearerFormat": "Rapportly testsleutel",
        "description": "Gebruik uitsluitend een rply_test_-sleutel uit Account → Koppelingen.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
