{
  "openapi": "3.1.0",
  "info": {
    "title": "Agent Wallet (wallet.nuri.com)",
    "version": "2.0.0",
    "description": "Non-custodial AI agent wallet for Base USDC (x402, EVM MPP) and Bitcoin Lightning/Arkade/on-chain BTC (L402, Lightning MPP, BOLT11, user@domain). Auto cross-rail USDC <-> BTC/Lightning. Pass wallet_key in the body or as Authorization: Bearer npw1_..."
  },
  "servers": [
    {
      "url": "https://wallet.nuri.com"
    }
  ],
  "paths": {
    "/v1/wallet": {
      "post": {
        "operationId": "walletAction",
        "summary": "Run a wallet action (balance, receive, pay, or history)",
        "description": "Start Passkey setup by calling action=balance without wallet_key, then repeat with the returned request_id after approval to obtain wallet_key (npw1_...).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wallet result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/balance": {
      "post": {
        "operationId": "walletBalance",
        "summary": "Create/connect Passkey wallet or check Base USDC + Bitcoin Lightning/Arkade balance",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "wallet_key": {
                    "type": "string",
                    "description": "npw1_... key (omit on first call to start Passkey setup)"
                  },
                  "request_id": {
                    "type": "string",
                    "description": "Repeat with the same request_id after Passkey approval"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connect links (connect_required) or live balances (done)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/receive": {
      "post": {
        "operationId": "walletReceive",
        "summary": "Get a Lightning invoice (sats), Base USDC address, or Arkade address",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "wallet_key": {
                    "type": "string"
                  },
                  "rail": {
                    "type": "string",
                    "enum": [
                      "lightning",
                      "usdc",
                      "arkade"
                    ]
                  },
                  "amount_sats": {
                    "type": "integer",
                    "minimum": 100,
                    "description": "Required for rail=lightning"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice or deposit address",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/pay": {
      "post": {
        "operationId": "walletPay",
        "summary": "Pay any x402/L402 URL, BOLT11 invoice, Lightning Address, bc1.../bitcoin: BTC, ark1..., or 0x... Base USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "to"
                ],
                "properties": {
                  "wallet_key": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string",
                    "description": "https:// 402 URL, lnbc..., user@domain, bc1.../bitcoin:..., ark1..., or 0x..."
                  },
                  "amount": {
                    "type": "string",
                    "description": "USDC for 0x..., or decimal BTC for bc1... (e.g. '0.00025')"
                  },
                  "amount_sats": {
                    "type": "integer",
                    "description": "Sats for user@domain, ark1..., or bc1..."
                  },
                  "max_amount": {
                    "type": "string",
                    "description": "Max USD cap for 402/invoice payments"
                  },
                  "max_sats": {
                    "type": "integer",
                    "description": "Max sats cap for 402/invoice payments"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "GET",
                      "POST",
                      "PUT",
                      "PATCH",
                      "DELETE"
                    ]
                  },
                  "headers": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "body": {
                    "description": "JSON or string request body for 402 HTTP calls"
                  },
                  "dry_run": {
                    "type": "boolean"
                  },
                  "request_id": {
                    "type": "string",
                    "description": "Idempotency key (new id after raising a cap)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment receipt and upstream response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/history": {
      "post": {
        "operationId": "walletHistory",
        "summary": "List recent payments and receives",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "wallet_key": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recent history entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WalletRequest": {
        "type": "object",
        "required": [
          "action"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "balance",
              "receive",
              "pay",
              "history"
            ]
          },
          "wallet_key": {
            "type": "string",
            "description": "npw1_... key (or send Authorization: Bearer npw1_...)"
          },
          "request_id": {
            "type": "string"
          },
          "rail": {
            "type": "string",
            "enum": [
              "lightning",
              "usdc",
              "arkade"
            ]
          },
          "to": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "amount_sats": {
            "type": "integer"
          },
          "max_amount": {
            "type": "string"
          },
          "max_sats": {
            "type": "integer"
          },
          "method": {
            "type": "string"
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "body": {},
          "dry_run": {
            "type": "boolean"
          },
          "limit": {
            "type": "integer"
          }
        }
      }
    }
  }
}