{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/swarmspace-net/json-schema/swarmspace-net-funding-envelope-schema.json",
  "title": "FundingEnvelope",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/swarmspace-net-api-openapi.json#/components/schemas/FundingEnvelope",
  "type": "object",
  "properties": {
    "funding": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^fund_[a-f0-9]{32}$"
        },
        "provider": {
          "type": "string",
          "enum": [
            "stripe",
            "base_usdc"
          ]
        },
        "test_mode": {
          "type": "boolean"
        },
        "kind": {
          "type": "string",
          "enum": [
            "feature_sponsorship",
            "donation"
          ]
        },
        "developer_request_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^dev_[a-f0-9]{32}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "amount": {
          "type": "string",
          "pattern": "^\\d+\\.\\d{2}$"
        },
        "currency": {
          "type": "string",
          "const": "USD"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "paid",
            "partially_refunded",
            "refunded",
            "disputed",
            "expired"
          ]
        },
        "credited_amount": {
          "type": "string",
          "pattern": "^\\d+\\.\\d{2}$"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "payment": {
          "anyOf": [
            {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "checkout"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "type",
                    "url"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "wallet_transfer"
                    },
                    "network": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "recipient": {
                      "type": "string"
                    },
                    "sender": {
                      "type": "string"
                    },
                    "amount": {
                      "type": "string",
                      "pattern": "^\\d+\\.\\d{2}$"
                    },
                    "atomic_amount": {
                      "type": "string"
                    },
                    "signature_message": {
                      "type": "string"
                    },
                    "claim_url": {
                      "type": "string"
                    },
                    "instructions": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "network",
                    "token",
                    "recipient",
                    "sender",
                    "amount",
                    "atomic_amount",
                    "signature_message",
                    "claim_url",
                    "instructions"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "provider",
        "test_mode",
        "kind",
        "developer_request_id",
        "amount",
        "currency",
        "status",
        "credited_amount",
        "created_at",
        "expires_at",
        "payment"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "funding"
  ],
  "additionalProperties": false
}