{
  "openapi": "3.1.0",
  "info": {
    "title": "SteadyMetric Cloud Reports",
    "version": "1.1.0",
    "description": "Prepare deterministic reports from supplied data. API keys do not authorize payments. A verified payment is required before downloading a report. Ten professional local tools do not have hosted execution endpoints."
  },
  "servers": [
    {
      "url": "https://getsteadymetric.com"
    }
  ],
  "security": [
    {
      "accountKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "accountKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "smk_ + 64 hexadecimal characters",
        "description": "Create and revoke in /account/. Keep keys on your server. Same account access for all cloud report tools."
      }
    },
    "schemas": {
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tool": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ready_for_payment",
              "paid",
              "reversed"
            ]
          },
          "amountUsd": {
            "type": "string"
          },
          "downloadUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "artifactSha256": {
            "type": "string"
          },
          "summary": {
            "type": "object"
          }
        },
        "required": [
          "id",
          "tool",
          "status"
        ]
      }
    }
  },
  "paths": {
    "/api/commerce/status": {
      "get": {
        "operationId": "serviceStatus",
        "security": [],
        "summary": "Service and payment provider availability",
        "responses": {
          "200": {
            "description": "Current readiness, prices and input limits"
          }
        }
      }
    },
    "/api/commerce/orders": {
      "get": {
        "operationId": "listReports",
        "summary": "List recent reports owned by this account",
        "responses": {
          "200": {
            "description": "Recent orders in this account"
          },
          "401": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "prepareReport",
        "summary": "Compute and save a report before requesting payment",
        "description": "Maximum input UTF-8 size: 1 MiB. Overall body: 2 MiB. Up to 5000 supported input rows. A UUID v4 idempotency key must be retained for retries with unchanged input. Individual tool schemas and limitations are linked from /tool-catalog.json.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "tool",
                  "input",
                  "idempotencyKey",
                  "consent"
                ],
                "properties": {
                  "tool": {
                    "type": "string",
                    "enum": [
                      "catalog",
                      "margin",
                      "invoice",
                      "agent",
                      "usdc",
                      "spec",
                      "dependencies",
                      "plans",
                      "purchase",
                      "tender",
                      "meter",
                      "seats",
                      "payout",
                      "rag",
                      "sla",
                      "tokens",
                      "batch",
                      "balance",
                      "treasury",
                      "vesting"
                    ]
                  },
                  "input": {
                    "type": "string",
                    "maxLength": 1048576,
                    "description": "Source JSON serialized as a string; Invoice Check also accepts its documented normalized CSV."
                  },
                  "consent": {
                    "const": true
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "maxAgeHours": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 720
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Prepared report, not a paid order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/commerce/orders/{id}": {
      "get": {
        "operationId": "getReportOrder",
        "summary": "Inspect an owned order and its verified payment status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/commerce/orders/{id}/download": {
      "get": {
        "operationId": "downloadPaidReport",
        "summary": "Download an integrity-checked paid report",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Private report JSON",
            "headers": {
              "X-Artifact-SHA256": {
                "schema": {
                  "type": "string"
                },
                "description": "SHA-256 of the exact response bytes"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request rejected or unavailable. No payment is implied by this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}