{
  "openapi": "3.1.0",
  "info": {
    "title": "H1DR4 SKYNET prepaid research API",
    "version": "2.0.0",
    "description": "Wallet-private public-source conversation and evidence dossiers. Buy Base USDC credits, explicitly reserve a per-run maximum, then settle accounted costs plus published margin. 100% of recognized margin funds buyback and burn; unused credits and cost allocations are excluded. Status, not this static document, determines readiness/pricing. Old free agent and flat-price x402 investigation endpoints return migration instructions without dispatch or payment."
  },
  "servers": [
    {
      "url": "https://h1dr4.dev/api/v1"
    }
  ],
  "paths": {
    "/skynet/status": {
      "get": {
        "summary": "Live readiness, credit pricing and verified buyback receipts",
        "operationId": "getSkynetStatus",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        }
      }
    },
    "/skynet/auth/challenge": {
      "post": {
        "summary": "Create exact five-minute one-use wallet sign-in message",
        "operationId": "postSkynetAuthChallenge",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "wallet": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "wallet"
                ]
              }
            }
          }
        }
      }
    },
    "/skynet/auth/login": {
      "post": {
        "summary": "Verify message signature and issue SKYNET-scoped session",
        "operationId": "postSkynetAuthLogin",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "wallet": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "nonce": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  }
                },
                "required": [
                  "wallet",
                  "nonce",
                  "signature"
                ]
              }
            }
          }
        }
      }
    },
    "/skynet/account": {
      "get": {
        "summary": "Read authenticated wallet credit balance",
        "operationId": "getSkynetAccount",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        }
      }
    },
    "/skynet/invoices": {
      "get": {
        "summary": "List this wallet\u2019s recent credit invoices",
        "operationId": "getSkynetInvoices",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        }
      },
      "post": {
        "summary": "Create a Base USDC credit invoice",
        "operationId": "postSkynetInvoices",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount_micros": {
                    "type": "integer",
                    "minimum": 1000000,
                    "maximum": 500000000
                  }
                },
                "required": [
                  "amount_micros"
                ]
              }
            }
          }
        }
      }
    },
    "/skynet/invoices/{id}/confirm": {
      "post": {
        "summary": "Verify a canonical six-confirmation exact USDC transfer",
        "operationId": "postSkynetInvoicesIdConfirm",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tx_hash": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{64}$"
                  },
                  "log_index": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "tx_hash"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/skynet/cases": {
      "get": {
        "summary": "List this wallet\u2019s private investigations",
        "operationId": "getSkynetCases",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        }
      },
      "post": {
        "summary": "Create a private investigation",
        "operationId": "postSkynetCases",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "brief": {
                    "type": "object",
                    "properties": {
                      "subject": {
                        "type": "string",
                        "maxLength": 180
                      },
                      "kind": {
                        "type": "string",
                        "enum": [
                          "entity",
                          "person",
                          "alias",
                          "company",
                          "organization",
                          "project",
                          "account",
                          "public_profile",
                          "wallet",
                          "domain",
                          "contract",
                          "event",
                          "claim"
                        ]
                      },
                      "objective": {
                        "type": "string",
                        "maxLength": 1000
                      },
                      "identifiers": {
                        "type": "array",
                        "maxItems": 12,
                        "items": {
                          "type": "string",
                          "maxLength": 250
                        }
                      },
                      "chain": {
                        "type": "string",
                        "enum": [
                          "base",
                          "ethereum",
                          "arbitrum",
                          "optimism",
                          "polygon"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/skynet/cases/{id}": {
      "get": {
        "summary": "Read owned investigation, conversation and dossier",
        "operationId": "getSkynetCasesId",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/skynet/runs/{id}": {
      "get": {
        "summary": "Read owned saved run and billing status",
        "operationId": "getSkynetRunsId",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/skynet/runs": {
      "post": {
        "summary": "Reserve a quoted budget and execute one idempotent research run",
        "operationId": "postSkynetRuns",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "run": {
                      "type": "object"
                    },
                    "case": {
                      "type": "object"
                    },
                    "account": {
                      "type": "object"
                    }
                  }
                }
              },
              "application/x-ndjson": {
                "schema": {
                  "type": "string",
                  "description": "When stream=true: reserved, phase, heartbeat and complete newline-delimited events. Complete contains the saved run, case and account."
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "402": {
            "description": "Insufficient prepaid credits"
          },
          "409": {
            "description": "Conflicting state, stale quote or pending confirmations"
          },
          "503": {
            "description": "Service not configured or unavailable"
          },
          "202": {
            "description": "Idempotent replay of an active run; no new inference"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "request": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 4000
                  },
                  "case_id": {
                    "type": "string"
                  },
                  "idempotency_key": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{8,100}$"
                  },
                  "pricing_revision": {
                    "type": "string"
                  },
                  "max_charge_micros": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  },
                  "background": {
                    "type": "boolean",
                    "description": "Requires configured, recently checked-in background worker. Returns 202 after durable reservation. No stream is kept open."
                  }
                },
                "required": [
                  "request",
                  "case_id",
                  "idempotency_key",
                  "pricing_revision",
                  "max_charge_micros"
                ]
              }
            }
          }
        }
      }
    },
    "/skynet/cases/{id}/work": {
      "post": {
        "summary": "Save owned case notes and known-source pins without inference or credit spending",
        "operationId": "postSkynetCaseWork",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string",
                    "maxLength": 8000
                  },
                  "pinned_source_ids": {
                    "type": "array",
                    "maxItems": 30,
                    "items": {
                      "type": "string"
                    },
                    "description": "Only source IDs already in this case."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Owned case including updated work"
          },
          "400": {
            "description": "Invalid work or unknown source ID"
          },
          "401": {
            "description": "Wallet authentication required"
          },
          "404": {
            "description": "Case not found or not owned"
          }
        }
      }
    },
    "/skynet/cases/{id}/context": {
      "get": {
        "summary": "Export owned portable case and any saved partial collection; excludes financial authority",
        "operationId": "getSkynetCaseContext",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Versioned portable case"
          },
          "401": {
            "description": "Sign in required"
          },
          "404": {
            "description": "Not owned or absent"
          }
        }
      }
    },
    "/skynet/context/preview": {
      "post": {
        "summary": "Validate portable case without saving or spending",
        "operationId": "previewSkynetContext",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "context"
                ],
                "properties": {
                  "context": {
                    "type": "object",
                    "description": "h1dr4.skynet.case version 1, at most 600 KB; treated as untrusted imported context"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normalized case"
          },
          "400": {
            "description": "Invalid or oversize context"
          }
        }
      }
    },
    "/skynet/cases/import": {
      "post": {
        "summary": "Import into a new private case; no balances or jobs imported",
        "operationId": "importSkynetContext",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "context"
                ],
                "properties": {
                  "context": {
                    "type": "object",
                    "description": "h1dr4.skynet.case version 1, at most 600 KB; treated as untrusted imported context"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normalized case"
          },
          "400": {
            "description": "Invalid or oversize context"
          }
        },
        "security": [
          {
            "SkynetSession": []
          }
        ]
      }
    },
    "/skynet/runs/{id}/cancel": {
      "post": {
        "summary": "Cancel only a queued job and atomically refund its full hold",
        "operationId": "cancelQueuedSkynetRun",
        "security": [
          {
            "SkynetSession": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled before dispatch"
          },
          "409": {
            "description": "Worker already dispatched the job"
          },
          "404": {
            "description": "Run absent or not owned"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SkynetSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "SKYNET-scoped token from the wallet challenge/login sequence. Distinct from H1DR4 mission authentication."
      }
    }
  }
}
