{
  "$ref": "#/definitions/receipt-v2",
  "definitions": {
    "receipt-v2": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "const": "0.2"
            },
            "kind": {
              "type": "string",
              "enum": [
                "spend",
                "earn"
              ],
              "default": "spend"
            },
            "agent": {
              "type": "string"
            },
            "nonce": {
              "type": "integer",
              "minimum": 0
            },
            "ts": {
              "type": "string"
            },
            "policy_v": {
              "type": "string"
            },
            "request": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "body_hash": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "headers_hash": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "method",
                "url",
                "body_hash"
              ],
              "additionalProperties": false
            },
            "decision": {
              "type": "string",
              "enum": [
                "allow",
                "deny",
                "rejected"
              ]
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "price": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "amount": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    },
                    "asset": {
                      "type": "string"
                    },
                    "fee": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "gross": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "feeBps": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "feeAuthority": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "amount",
                    "currency"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ]
            },
            "facilitator": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "payai",
                        "corbits",
                        "svmacc",
                        "self",
                        "local"
                      ]
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "response": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "body_hash": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ]
            },
            "prev_receipt_hash": {
              "type": [
                "string",
                "null"
              ]
            },
            "receipt_hash": {
              "type": "string"
            },
            "protocol": {
              "type": "string",
              "const": "x402"
            },
            "tx_sig": {
              "type": [
                "string",
                "null"
              ]
            },
            "payment_requirements_hash": {
              "type": [
                "string",
                "null"
              ]
            },
            "payment_response": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "v",
            "agent",
            "nonce",
            "ts",
            "policy_v",
            "request",
            "decision",
            "reason",
            "price",
            "facilitator",
            "response",
            "prev_receipt_hash",
            "receipt_hash",
            "protocol",
            "tx_sig"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "const": "0.2"
            },
            "kind": {
              "type": "string",
              "enum": [
                "spend",
                "earn"
              ],
              "default": "spend"
            },
            "agent": {
              "type": "string"
            },
            "nonce": {
              "type": "integer",
              "minimum": 0
            },
            "ts": {
              "type": "string"
            },
            "policy_v": {
              "type": "string"
            },
            "request": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "body_hash": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "headers_hash": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "method",
                "url",
                "body_hash"
              ],
              "additionalProperties": false
            },
            "decision": {
              "type": "string",
              "enum": [
                "allow",
                "deny",
                "rejected"
              ]
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "price": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "amount": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    },
                    "asset": {
                      "type": "string"
                    },
                    "fee": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "gross": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "feeBps": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "feeAuthority": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "amount",
                    "currency"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ]
            },
            "facilitator": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "payai",
                        "corbits",
                        "svmacc",
                        "self",
                        "local"
                      ]
                    },
                    {
                      "type": "string",
                      "format": "uri"
                    }
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "response": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "body_hash": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ]
            },
            "prev_receipt_hash": {
              "type": [
                "string",
                "null"
              ]
            },
            "receipt_hash": {
              "type": "string"
            },
            "protocol": {
              "type": "string",
              "const": "mpp"
            },
            "mpp_challenge_id": {
              "type": "string"
            },
            "mpp_credential_type": {
              "type": "string",
              "const": "crypto"
            },
            "mpp_settlement_tx": {
              "type": "string"
            },
            "mpp_settlement_slot": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "tx_sig": {
              "type": [
                "string",
                "null"
              ]
            },
            "payment_requirements_hash": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "v",
            "agent",
            "nonce",
            "ts",
            "policy_v",
            "request",
            "decision",
            "reason",
            "price",
            "facilitator",
            "response",
            "prev_receipt_hash",
            "receipt_hash",
            "protocol",
            "mpp_challenge_id",
            "mpp_credential_type",
            "mpp_settlement_tx",
            "mpp_settlement_slot"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}