{
  "openapi": "3.1.0",
  "info": {
    "title": "MeasureHub Public API",
    "version": "1.0.0",
    "description": "Programmatic access to studies, study content, participant sessions, results and instrument licences. Authenticate with a personal API key: `Authorization: Bearer mh_live_...`. Rate limits: 120 requests/minute and 10,000 requests/day per key."
  },
  "servers": [
    {
      "url": "https://registry.porto.ac/api/public/v1"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mh_live_*"
      }
    }
  },
  "paths": {
    "/studies": {
      "get": {
        "summary": "List your studies",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "draft",
                "live",
                "closed"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a study under an approved licence",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "licenseRequestId",
                  "title"
                ],
                "properties": {
                  "licenseRequestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/studies/{id}": {
      "get": {
        "summary": "Retrieve a study",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Update title, description, status or schedule",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/studies/{id}/content": {
      "get": {
        "summary": "Rendering-ready study content (modules, questions, items, translations)",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/studies/{id}/sessions": {
      "get": {
        "summary": "List participant sessions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Start a session and receive its session token",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/studies/{id}/results": {
      "get": {
        "summary": "Pull results",
        "parameters": [
          {
            "name": "dataset",
            "in": "query",
            "schema": {
              "enum": [
                "responses",
                "scores",
                "sessions",
                "paradata"
              ]
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "enum": [
                "json",
                "csv"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/responses": {
      "post": {
        "summary": "Submit responses for a session",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/finish": {
      "post": {
        "summary": "Complete a session and run automatic scoring",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/instruments": {
      "get": {
        "summary": "Browse the public instrument catalogue",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/licenses": {
      "get": {
        "summary": "List your instrument licences",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Request a new instrument licence",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}