{
  "openapi": "3.1.0",
  "info": {
    "title": "Umarise Core API",
    "description": "Independent proof infrastructure. Anchor SHA-256 hashes to Bitcoin via OpenTimestamps.",
    "version": "1.0.0",
    "contact": {
      "email": "j.fassbender@umarise.com",
      "url": "https://umarise.com/developers"
    }
  },
  "servers": [
    {
      "url": "https://core.umarise.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/v1-core-origins": {
      "post": {
        "operationId": "anchorHash",
        "summary": "Register a SHA-256 hash",
        "description": "Registers a SHA-256 hash in the Umarise registry. The hash is aggregated into a Merkle tree and anchored to Bitcoin via OpenTimestamps within 10-20 minutes.",
        "security": [{"ApiKeyAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["hash"],
                "properties": {
                  "hash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$",
                    "description": "SHA-256 hash as 64-character lowercase hex string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Hash registered",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "origin_id": {"type": "string", "format": "uuid"},
                    "short_token": {"type": "string"},
                    "hash": {"type": "string"},
                    "hash_algo": {"type": "string"},
                    "captured_at": {"type": "string", "format": "date-time"},
                    "device_signed": {"type": "boolean"}
                  }
                }
              }
            }
          },
          "400": {"description": "Invalid hash format"},
          "401": {"description": "Missing or invalid API key"},
          "409": {"description": "Hash already registered"},
          "429": {"description": "Rate limit exceeded"}
        }
      }
    },
    "/v1-core-verify": {
      "post": {
        "operationId": "verifyHash",
        "summary": "Check if a hash exists",
        "description": "Check whether a SHA-256 hash has been registered. No authentication required.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["hash"],
                "properties": {
                  "hash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$",
                    "description": "SHA-256 hash as 64-character lowercase hex string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "exists": {"type": "boolean"},
                    "origin_id": {"type": "string", "format": "uuid"},
                    "captured_at": {"type": "string", "format": "date-time"},
                    "ots_status": {"type": "string", "enum": ["pending", "anchored"]}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1-core-resolve": {
      "get": {
        "operationId": "resolveOrigin",
        "summary": "Look up an attestation",
        "description": "Look up an existing attestation by origin_id or short_token. No authentication required.",
        "parameters": [
          {
            "name": "origin_id",
            "in": "query",
            "schema": {"type": "string", "format": "uuid"},
            "description": "The origin identifier"
          },
          {
            "name": "token",
            "in": "query",
            "schema": {"type": "string"},
            "description": "The 8-character short token"
          }
        ],
        "responses": {
          "200": {
            "description": "Attestation details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "origin_id": {"type": "string", "format": "uuid"},
                    "short_token": {"type": "string"},
                    "hash": {"type": "string"},
                    "captured_at": {"type": "string", "format": "date-time"},
                    "ots_status": {"type": "string"},
                    "bitcoin_block_height": {"type": "integer"},
                    "anchored_at": {"type": "string", "format": "date-time"}
                  }
                }
              }
            }
          },
          "404": {"description": "Origin not found"}
        }
      }
    },
    "/v1-core-proof": {
      "get": {
        "operationId": "getProof",
        "summary": "Download .ots proof",
        "description": "Download the OpenTimestamps binary proof file. No authentication required.",
        "parameters": [
          {
            "name": "origin_id",
            "in": "query",
            "required": true,
            "schema": {"type": "string", "format": "uuid"}
          }
        ],
        "responses": {
          "200": {
            "description": "Binary .ots proof file",
            "content": {
              "application/octet-stream": {}
            }
          },
          "202": {"description": "Proof not yet available"},
          "404": {"description": "Origin or proof not found"}
        }
      }
    },
    "/v1-core-health": {
      "get": {
        "operationId": "healthCheck",
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "Service status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {"type": "string"},
                    "version": {"type": "string"}
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key with prefix um_live_ (production) or um_test_ (sandbox)"
      }
    }
  }
}
