{
  "openapi": "3.1.0",
  "info": {
    "title": "Find Key & BPM Public Resource API",
    "version": "1.1.0",
    "description": "Read-only discovery plus deterministic BPM-delay, chord-key, and Camelot calculations. Inputs are validated and never stored."
  },
  "servers": [
    {
      "url": "https://findkeybpm.com"
    }
  ],
  "paths": {
    "/api/agent/resources": {
      "get": {
        "operationId": "findKeyBpmResource",
        "summary": "List or search published site resources",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching public resources",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or conflicting query"
          }
        }
      }
    },
    "/api/agent/tools/bpm-delay": {
      "post": {
        "operationId": "convertBpmDelay",
        "summary": "Convert BPM to page-identical delay values or delay milliseconds to BPM",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "direction",
                      "bpm"
                    ],
                    "properties": {
                      "direction": {
                        "const": "bpm_to_ms"
                      },
                      "bpm": {
                        "type": "number",
                        "minimum": 20,
                        "maximum": 400
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "direction",
                      "delay_ms",
                      "note_id",
                      "feel_id"
                    ],
                    "properties": {
                      "direction": {
                        "const": "ms_to_bpm"
                      },
                      "delay_ms": {
                        "type": "number",
                        "minimum": 1,
                        "maximum": 60000
                      },
                      "note_id": {
                        "enum": [
                          "1/1",
                          "1/2",
                          "1/4",
                          "1/8",
                          "1/16",
                          "1/32"
                        ]
                      },
                      "feel_id": {
                        "enum": [
                          "straight",
                          "dotted",
                          "triplet"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic conversion result"
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/api/agent/tools/key-from-chords": {
      "post": {
        "operationId": "findKeysFromChords",
        "summary": "List every best-fitting key shown by the chord page",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "chords"
                ],
                "properties": {
                  "chords": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 24,
                    "uniqueItems": true,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "root_semitone",
                        "quality"
                      ],
                      "properties": {
                        "root_semitone": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 11
                        },
                        "quality": {
                          "enum": [
                            "maj",
                            "min",
                            "dim",
                            "dom7",
                            "maj7",
                            "min7"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Possible keys without forcing ambiguity"
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/api/agent/tools/camelot-key": {
      "post": {
        "operationId": "lookupCamelotKey",
        "summary": "Look up the selected Camelot key and page-identical compatible moves",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "pattern": "^(?:[1-9]|1[0-2])[AB]$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Camelot relationship result"
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    }
  }
}
