{
  "openapi": "3.1.0",
  "info": {
    "title": "ArkPool Statistics and Boost API",
    "version": "1.1.0",
    "description": "Public operator-reported pool aggregates and user-authorized Boost contributions via Ark or Lightning. Creating an intent prepares a payment request; it does not send funds. No wallet-send, miner lookup, enrollment or administration API. Base mining quotes are unchanged; boosts add proportional rewards. Reading this schema grants no spending permission."
  },
  "servers": [
    {
      "url": "https://arkpool.org"
    }
  ],
  "security": [],
  "paths": {
    "/stats.json": {
      "get": {
        "operationId": "getPublicSnapshot",
        "summary": "Read timestamped pool aggregates and bounded history",
        "description": "No query parameters or credentials. Poll no faster than 300 seconds. Use measured_at as the window endpoint; null means unknown. Reject unknown schemas, timestamps over one minute in the future, and data older than fifteen minutes. Accepted upstream shares alone do not prove miner credit or payment. History points are overlapping hourly windows and must not be summed as daily totals.",
        "responses": {
          "200": {
            "description": "Available snapshot, Cache-Control: no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Snapshot"
                }
              }
            }
          },
          "400": {
            "description": "Query parameters are not supported"
          },
          "405": {
            "description": "Only GET and HEAD are supported"
          },
          "503": {
            "description": "Snapshot unavailable, invalid or stale; do not interpret as zero activity"
          }
        }
      },
      "head": {
        "operationId": "checkPublicSnapshot",
        "summary": "Read availability headers without a body",
        "responses": {
          "200": {
            "description": "Snapshot available"
          },
          "400": {
            "description": "Query parameters unsupported"
          },
          "503": {
            "description": "Snapshot unavailable"
          }
        }
      }
    },
    "/api/boost/summary": {
      "get": {
        "operationId": "getBoostSummary",
        "summary": "Discover current Boost policy, rails and bounds",
        "description": "Read-only, no credentials/query parameters. Respect enabled flag. Poll no faster than once per minute.",
        "security": [],
        "responses": {
          "200": {
            "description": "Current capability or disabled state; no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoostSummary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; query strings not supported"
          },
          "403": {
            "description": "Request forbidden"
          },
          "405": {
            "description": "Wrong HTTP method"
          },
          "409": {
            "description": "Needs reconciliation; no automatic retry"
          },
          "429": {
            "description": "Rate limited; back off read-only checks"
          },
          "503": {
            "description": "Unavailable or uncertain; do not blindly retry creation or payment"
          }
        }
      }
    },
    "/api/boost/intents": {
      "post": {
        "operationId": "createBoostIntent",
        "summary": "Prepare one user-authorized contribution; does not send money",
        "description": "Persist exact body and random key before one POST. Persist returned capability before paying. Mainnet only. No automatic POST retry after timeout, 409 or uncertain issuance; no new key to bypass uncertainty. Wallet payment requires separate user-authorized wallet tooling. See agent recovery workflow.",
        "security": [],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{32,128}$"
            },
            "description": "Fresh cryptographically random request identity saved before sending; not permission for automatic uncertain retry."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoostCreate"
              },
              "examples": {
                "ark": {
                  "value": {
                    "rail": "ark",
                    "policy_version": "boost-next-payout-v3"
                  }
                },
                "lightning": {
                  "value": {
                    "rail": "lightning",
                    "policy_version": "boost-next-payout-v3",
                    "amount_sats": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inspect status and preserve status_token; not payment confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoostCreated"
                }
              }
            }
          },
          "201": {
            "description": "Inspect status and preserve status_token; not payment confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoostCreated"
                }
              }
            }
          },
          "202": {
            "description": "Inspect status and preserve status_token; not payment confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoostCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; query strings not supported"
          },
          "401": {
            "description": "Missing or invalid status capability"
          },
          "403": {
            "description": "Request forbidden"
          },
          "405": {
            "description": "Wrong HTTP method"
          },
          "409": {
            "description": "Needs reconciliation; no automatic retry"
          },
          "429": {
            "description": "Rate limited; back off read-only checks"
          },
          "503": {
            "description": "Unavailable or uncertain; do not blindly retry creation or payment"
          }
        }
      }
    },
    "/api/boost/status": {
      "get": {
        "operationId": "getBoostStatus",
        "summary": "Read a saved contribution request using its private capability",
        "description": "No query parameters. Authorization: Bearer status_token. Poll every15–30seconds with backoff; do not resend after timeout or unknown state. Stop continuous polling at credited/held.",
        "security": [
          {
            "BoostStatusCapability": []
          }
        ],
        "responses": {
          "200": {
            "description": "Private current status; no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoostStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; query strings not supported"
          },
          "401": {
            "description": "Missing or invalid status capability"
          },
          "403": {
            "description": "Request forbidden"
          },
          "405": {
            "description": "Wrong HTTP method"
          },
          "409": {
            "description": "Needs reconciliation; no automatic retry"
          },
          "429": {
            "description": "Rate limited; back off read-only checks"
          },
          "503": {
            "description": "Unavailable or uncertain; do not blindly retry creation or payment"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Count": {
        "type": [
          "integer",
          "null"
        ],
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "Hashrate": {
        "type": [
          "number",
          "null"
        ],
        "minimum": 0,
        "maximum": 9007199254740991,
        "description": "TH/s estimated from verified work, not device telemetry"
      },
      "Stats": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "total_paid_sats",
          "accepted_shares_1h",
          "hashrate_5m_ths",
          "hashrate_1h_ths",
          "active_workers_5m",
          "active_miners_1h",
          "upstream_accepted_1h",
          "upstream_rejected_1h",
          "last_payout_at"
        ],
        "properties": {
          "total_paid_sats": {
            "$ref": "#/components/schemas/Count",
            "description": "All-time confirmed miner payouts in sats"
          },
          "unpaid_sats": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Pool-wide earned sats minus confirmed payouts, including fractional balances and payments in progress. Not the amount eligible at the next settlement. Presentation precision only; not a financial transaction API."
          },
          "boost_pending": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Optional aggregate: confirmed Boost credit awaits a confirmed hourly settlement covering its eligibility cutoff. False after all affected miners are covered; fractional carry may remain. Null or absent means unknown. Does not expose tip amounts or identities."
          },
          "last_payment_sats": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Total confirmed sats for the latest hourly cutoff with confirmed payments. Excludes pending or failed payments."
          },
          "last_payment_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Latest recorded confirmation time within that hourly payout round, not its settlement cutoff."
          },
          "paid_sats_24h": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Confirmed miner payments recorded in the preceding 24 hours ending at measured_at."
          },
          "accepted_shares_1h": {
            "$ref": "#/components/schemas/Count",
            "description": "Verified accounting purchases in the trailing hour; legacy field name, not raw upstream acceptances"
          },
          "hashrate_5m_ths": {
            "$ref": "#/components/schemas/Hashrate",
            "description": "Legacy five-minute estimate; use hashrate_1h_ths for the headline"
          },
          "hashrate_1h_ths": {
            "$ref": "#/components/schemas/Hashrate"
          },
          "active_workers_5m": {
            "$ref": "#/components/schemas/Count",
            "description": "Legacy five-minute work activity; not a connection count"
          },
          "active_miners_1h": {
            "$ref": "#/components/schemas/Count",
            "description": "Distinct miners with verified work in the trailing hour"
          },
          "upstream_accepted_1h": {
            "$ref": "#/components/schemas/Count"
          },
          "upstream_rejected_1h": {
            "$ref": "#/components/schemas/Count"
          },
          "last_payout_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Latest confirmed settlement cutoff, not upstream revenue receipt time"
          },
          "last_payout_boost_sats": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Bonus credited for the latest confirmed payout round; fractional balances may carry. Null when unavailable or bonus recipients are not all confirmed for that cutoff. Not an additional amount to add to the payout total."
          }
        }
      },
      "HistoryPoint": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "measured_at",
          "hashrate_5m_ths",
          "accepted_shares_1h"
        ],
        "properties": {
          "measured_at": {
            "type": "string",
            "format": "date-time"
          },
          "hashrate_5m_ths": {
            "type": "number",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "hashrate_1h_ths": {
            "type": "number",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "accepted_shares_1h": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        }
      },
      "Snapshot": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schema_version",
          "measured_at",
          "refresh_interval_seconds",
          "stats",
          "history"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "measured_at": {
            "type": "string",
            "format": "date-time"
          },
          "refresh_interval_seconds": {
            "type": "integer",
            "const": 300
          },
          "stats": {
            "$ref": "#/components/schemas/Stats"
          },
          "status": {
            "type": "object",
            "additionalProperties": false,
            "description": "Periodic operator observations, not availability guarantees. Unknown if check time is missing or over fifteen minutes old.",
            "properties": {
              "checked_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "mining": {
                "enum": [
                  "active",
                  "quiet",
                  "unavailable",
                  "unknown"
                ]
              },
              "tor": {
                "enum": [
                  "healthy",
                  "unavailable",
                  "unknown"
                ]
              },
              "ark": {
                "enum": [
                  "connected",
                  "unavailable",
                  "unknown"
                ]
              },
              "payouts": {
                "enum": [
                  "current",
                  "pending",
                  "delayed",
                  "unknown"
                ]
              }
            }
          },
          "history": {
            "type": "array",
            "maxItems": 289,
            "items": {
              "$ref": "#/components/schemas/HistoryPoint"
            }
          },
          "history_source": {
            "type": "string",
            "const": "verified_work_ledger"
          }
        }
      },
      "BoostPolicy": {
        "type": "object",
        "required": [
          "version",
          "miner_bps",
          "basis",
          "allocation",
          "retained_destination"
        ],
        "properties": {
          "version": {
            "const": "boost-next-payout-v3"
          },
          "miner_bps": {
            "const": 10000
          },
          "basis": {
            "const": "net_received"
          },
          "allocation": {
            "const": "base_earnings_next_payout"
          },
          "retained_destination": {
            "const": "none"
          }
        }
      },
      "BoostEstimate": {
        "type": "object",
        "required": [
          "state",
          "calculated_at",
          "estimate",
          "target_cutoff",
          "estimated_bonus_bps"
        ],
        "properties": {
          "state": {
            "enum": [
              "none",
              "queued",
              "credited"
            ]
          },
          "calculated_at": {
            "type": "string",
            "format": "date-time"
          },
          "estimate": {
            "const": true
          },
          "target_cutoff": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "estimated_bonus_bps": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          }
        },
        "description": "Provisional aggregate only, not a promised multiplier or payment proof."
      },
      "BoostSummary": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "enabled"
            ],
            "properties": {
              "enabled": {
                "const": false
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "enabled",
              "policy",
              "rails",
              "min_sats",
              "max_sats",
              "ark_amount_mode",
              "next_payout_boost"
            ],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "policy": {
                "$ref": "#/components/schemas/BoostPolicy"
              },
              "rails": {
                "type": "array",
                "items": {
                  "enum": [
                    "ark",
                    "lightning"
                  ]
                },
                "minItems": 1,
                "uniqueItems": true
              },
              "min_sats": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              },
              "max_sats": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              },
              "ark_amount_mode": {
                "const": "wallet"
              },
              "next_payout_boost": {
                "$ref": "#/components/schemas/BoostEstimate"
              }
            }
          }
        ]
      },
      "BoostCreate": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "rail",
              "policy_version"
            ],
            "additionalProperties": false,
            "properties": {
              "rail": {
                "const": "ark"
              },
              "policy_version": {
                "const": "boost-next-payout-v3"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rail",
              "policy_version",
              "amount_sats"
            ],
            "additionalProperties": false,
            "properties": {
              "rail": {
                "const": "lightning"
              },
              "policy_version": {
                "const": "boost-next-payout-v3"
              },
              "amount_sats": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              }
            }
          }
        ],
        "description": "Recommended current v3 flow: Ark amount selected in wallet, Lightning exact amount specified here. Respect live summary bounds."
      },
      "BoostStatus": {
        "type": "object",
        "required": [
          "intent_id",
          "status",
          "receipt_confirmed",
          "allocation_committed",
          "policy_version"
        ],
        "properties": {
          "intent_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{32,128}$"
          },
          "status": {
            "enum": [
              "awaiting_payment",
              "confirming",
              "funded_pending",
              "credited",
              "held",
              "issuance_uncertain"
            ]
          },
          "receipt_confirmed": {
            "type": "boolean"
          },
          "allocation_committed": {
            "type": "boolean"
          },
          "policy_version": {
            "type": "string"
          },
          "rail": {
            "enum": [
              "ark",
              "lightning"
            ]
          },
          "amount_mode": {
            "enum": [
              "wallet",
              "fixed"
            ]
          },
          "amount_sats": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000
          },
          "payment_request": {
            "type": "string",
            "maxLength": 8192,
            "description": "Pay only when awaiting_payment, rail and amount match, and expiry is in the future. Never reuse."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "eligible_cutoff": {
            "type": "string",
            "format": "date-time"
          },
          "safe_to_start_new": {
            "type": "boolean",
            "description": "Recovery metadata, not permission to automatically create or pay a replacement."
          }
        },
        "description": "funded_pending means confirmed receipt awaiting allocation. credited means pool accounting allocation, not proof of miner wallet settlement."
      },
      "BoostCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BoostStatus"
          },
          {
            "type": "object",
            "required": [
              "status_token"
            ],
            "properties": {
              "status_token": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{32,128}$"
              }
            }
          }
        ],
        "description": "Save the capability immediately, including for issuance_uncertain; a creation response does not mean payment was sent."
      }
    },
    "securitySchemes": {
      "BoostStatusCapability": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private status_token returned once on intent creation. Not a wallet credential. Never include in URLs or logs."
      }
    }
  },
  "externalDocs": {
    "description": "Agent workflow and uncertain-payment recovery",
    "url": "https://arkpool.org/SKILL.md#boost-miners"
  }
}
