{
  "openapi": "3.1.0",
  "info": {
    "title": "Hermes Bank Agent API",
    "version": "0.1.0",
    "description": "Draft API contract for AI agents using Hermes prepaid card workflows."
  },
  "servers": [
    {
      "url": "https://hermes-bank-site.vercel.app",
      "description": "Current static demo host. Production API will run behind the same Hermes surface."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/balances": {
      "get": {
        "summary": "Read Hermes balances",
        "operationId": "getBalances",
        "responses": {
          "200": {
            "description": "Current balances",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balances"
                }
              }
            }
          }
        }
      }
    },
    "/api/payment-intents": {
      "post": {
        "summary": "Create crypto payment intent",
        "operationId": "createPaymentIntent",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentIntentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment intent"
          }
        }
      }
    },
    "/api/agent-card-issue": {
      "post": {
        "summary": "Issue card for an agent",
        "operationId": "issueAgentCard",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentCardIssueRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Issued card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedCard"
                }
              }
            }
          }
        }
      }
    },
    "/api/cards/{cardId}": {
      "get": {
        "summary": "Read issued card",
        "operationId": "getCard",
        "parameters": [
          {
            "name": "cardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Issued card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedCard"
                }
              }
            }
          }
        }
      }
    },
    "/api/transactions": {
      "get": {
        "summary": "Read transaction ledger",
        "operationId": "getTransactions",
        "responses": {
          "200": {
            "description": "Ledger events"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "Balances": {
        "type": "object",
        "properties": {
          "cryptoBalance": {
            "type": "object",
            "properties": {
              "asset": {
                "type": "string",
                "example": "USDC"
              },
              "available": {
                "type": "number",
                "example": 2788.5
              }
            }
          },
          "fulfillmentBalance": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "example": "USD"
              },
              "available": {
                "type": "number",
                "example": 1870
              }
            }
          },
          "pendingSpend": {
            "type": "number",
            "example": 0
          },
          "issuedVolume": {
            "type": "number",
            "example": 50
          }
        }
      },
      "PaymentIntentRequest": {
        "type": "object",
        "required": ["amount", "asset", "purpose"],
        "properties": {
          "amount": {
            "type": "number",
            "example": 25.75
          },
          "asset": {
            "type": "string",
            "example": "USDC"
          },
          "purpose": {
            "type": "string",
            "example": "agent_card_order"
          }
        }
      },
      "AgentCardIssueRequest": {
        "type": "object",
        "required": ["agentId", "mission", "cardType", "country", "amount"],
        "properties": {
          "agentId": {
            "type": "string",
            "example": "research-agent-04"
          },
          "mission": {
            "type": "string",
            "example": "buy dataset access"
          },
          "cardType": {
            "type": "string",
            "example": "Hermes Prepaid Visa"
          },
          "country": {
            "type": "string",
            "example": "US"
          },
          "amount": {
            "type": "number",
            "example": 25
          },
          "policy": {
            "type": "object"
          }
        }
      },
      "IssuedCard": {
        "type": "object",
        "properties": {
          "cardId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "DELIVERED"
          },
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "recipient": {
            "type": "string"
          },
          "delivery": {
            "type": "object"
          }
        }
      }
    }
  }
}
