{
  "openapi": "3.1.0",
  "info": {
    "title": "Elven Trials API",
    "version": "1.1.0",
    "description": "REST API reference for sessions, user profiles, and content."
  },
  "servers": [
    {
      "url": "https://api.elventrials.com"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Get API status",
        "security": [],
        "responses": {
          "200": {
            "description": "The API is available."
          }
        }
      }
    },
    "/api/session": {
      "post": {
        "summary": "Create a session",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "format": "password"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authentication succeeded. The response contains a session token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "token"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The email address or password is invalid."
          },
          "429": {
            "description": "Too many authentication attempts."
          }
        },
        "description": "Authenticates an account using an email address and password. Returns a token for authenticated requests."
      }
    },
    "/api/me": {
      "get": {
        "summary": "Get the authenticated user\u2019s profile",
        "responses": {
          "200": {
            "description": "The authenticated user\u2019s profile."
          },
          "401": {
            "description": "The authentication token is missing, invalid, or expired."
          }
        }
      }
    },
    "/api/me/next": {
      "get": {
        "operationId": "getNextItem",
        "summary": "Get the next content item",
        "description": "Returns the next content item for the authenticated user. The data array is empty when no item is available.",
        "responses": {
          "200": {
            "description": "The next content item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "type",
                          "payload"
                        ],
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "question"
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "content"
                            ],
                            "properties": {
                              "content": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "question": {
                    "value": {
                      "data": [
                        {
                          "type": "question",
                          "payload": {
                            "content": "How are you?"
                          }
                        }
                      ]
                    }
                  },
                  "empty": {
                    "value": {
                      "data": []
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The authentication token is missing, invalid, or expired."
          },
          "503": {
            "description": "The service is unavailable."
          }
        }
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
