{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/monerium/main/json-schema/monerium-payment-schema.json",
  "title": "Payment",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/monerium-openapi.yml#/components/schemas/Payment",
  "type": "object",
  "properties": {
    "id": {
      "allOf": [
        {
          "$ref": "#/$defs/UUID"
        },
        {
          "description": "The ID of the payment."
        }
      ]
    },
    "orderId": {
      "allOf": [
        {
          "$ref": "#/$defs/UUID"
        },
        {
          "description": "The ID of the order associated with the payment."
        }
      ]
    },
    "direction": {
      "description": "The direction of funds relative to the Monerium\naccount:\n\n- `in`: Funds were received into the account.\n- `out`: Funds were sent from the account.\n",
      "type": "string",
      "enum": [
        "in",
        "out"
      ]
    },
    "currency": {
      "$ref": "#/$defs/Currency"
    },
    "amount": {
      "description": "The payment amount.",
      "type": "string"
    },
    "counterpart": {
      "$ref": "#/$defs/CounterpartResponse"
    },
    "memo": {
      "$ref": "#/$defs/Memo"
    },
    "referenceNumber": {
      "description": "Structured SEPA reference.",
      "$ref": "#/$defs/ReferenceNumber"
    },
    "reference": {
      "description": "An Account Servicer Reference is a payment identifier primarly used in ISO 20022 messaging standars, assigned by Monerium to uniquely identify a transaction.",
      "type": "string"
    },
    "type": {
      "description": "The payment scheme or type assigned by the payment provider:\n\n- `INTERNAL`: Payment between accounts held at the same financial institution.\n- `INST`: SEPA Instant Credit Transfer.\n- `TIPS`: TARGET Instant Payment.\n- `TARGET2`: Payment received through TARGET2.\n- `SEPA`: SEPA Credit Transfer.\n- `SWIFT`: International payment via the SWIFT network.\n",
      "type": "string",
      "enum": [
        "INTERNAL",
        "INST",
        "TIPS",
        "TARGET2",
        "SEPA",
        "SWIFT"
      ]
    },
    "uetr": {
      "description": "A Unique End-to-end Transaction Reference is a tracking code used to follow international wire transfers across the SWIFT payment network.",
      "type": "string",
      "maxLength": 36,
      "minLength": 36
    },
    "instructionId": {
      "description": "An Instruction Identification is a point-to-point payment identifier primarily used in ISO 20022 messaging standards, assinged by the sending party.",
      "type": "string"
    },
    "meta": {
      "type": "object",
      "properties": {
        "processedAt": {
          "description": "When was the payment processed. Only visible when the payment has been processed. The timestamp in [RFC3339](https://tools.ietf.org/html/rfc3339) format. It includes the date, time to the second, and optional fractional seconds, followed by 'Z' to indicate UTC time.",
          "$ref": "#/$defs/TimeStamp"
        }
      }
    }
  },
  "required": [
    "id",
    "orderId",
    "direction",
    "currency",
    "amount",
    "counterpart"
  ],
  "$defs": {
    "Address": {
      "description": "The public key of the blockchain account.",
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]{40}$"
    },
    "BankAccount": {
      "description": "Used for generic bank account details, when IBAN is not available.",
      "type": "object",
      "properties": {
        "standard": {
          "description": "The standard of the bank account. This is used to identify generic bank account.",
          "type": "string",
          "enum": [
            "account"
          ]
        },
        "accountNumber": {
          "description": "The account number of the bank account.",
          "type": "string"
        },
        "address": {
          "description": "Address of the bank account holder.",
          "type": "string"
        },
        "bic": {
          "description": "The BIC (Bank Identifier Code) of the bank.",
          "type": "string"
        }
      },
      "required": [
        "standard",
        "accountNumber",
        "address"
      ]
    },
    "Chain": {
      "oneOf": [
        {
          "title": "Ethereum",
          "type": "string",
          "enum": [
            "ethereum"
          ],
          "description": "Ethereum mainnet"
        },
        {
          "title": "Gnosis",
          "type": "string",
          "enum": [
            "gnosis"
          ],
          "description": "Gnosis Chain"
        },
        {
          "title": "Polygon",
          "type": "string",
          "enum": [
            "polygon"
          ],
          "description": "Polygon PoS"
        },
        {
          "title": "Arbitrum",
          "type": "string",
          "enum": [
            "arbitrum"
          ],
          "description": "Arbitrum"
        },
        {
          "title": "Linea",
          "type": "string",
          "enum": [
            "linea"
          ],
          "description": "Linea"
        },
        {
          "title": "Base",
          "type": "string",
          "enum": [
            "base"
          ],
          "description": "Base"
        },
        {
          "title": "Noble",
          "type": "string",
          "enum": [
            "noble"
          ],
          "description": "Noble"
        },
        {
          "title": "Sepolia",
          "type": "string",
          "enum": [
            "sepolia"
          ],
          "description": "Sepolia testnet"
        },
        {
          "title": "Chiado",
          "type": "string",
          "enum": [
            "chiado"
          ],
          "description": "Chiado Gnosis testnet"
        },
        {
          "title": "Amoy",
          "type": "string",
          "enum": [
            "amoy"
          ],
          "description": "Amoy Polygon testnet"
        },
        {
          "title": "Arbitrum Sepolia",
          "type": "string",
          "enum": [
            "arbitrumsepolia"
          ],
          "description": "Arbitrum Sepolia testnet"
        },
        {
          "title": "Linea Sepolia",
          "type": "string",
          "enum": [
            "lineasepolia"
          ],
          "description": "Linea Sepolia testnet"
        },
        {
          "title": "Base Sepolia",
          "type": "string",
          "enum": [
            "basesepolia"
          ],
          "description": "Base Sepolia testnet"
        },
        {
          "title": "Noble Grand",
          "type": "string",
          "enum": [
            "grand"
          ],
          "description": "Noble Grand testnet"
        }
      ]
    },
    "CounterpartResponse": {
      "description": "The counterpart represents the other party involved in a financial transaction, such as the recipient of a payment or the payer. The counterpart can be either an individual or a corporate. It includes identifying information such as account details, name, and country.",
      "type": "object",
      "properties": {
        "identifier": {
          "description": "Counterpart account information.",
          "oneOf": [
            {
              "title": "IBAN",
              "type": "object",
              "required": [
                "standard",
                "iban"
              ],
              "properties": {
                "standard": {
                  "description": "An International Bank Account Number (IBAN) is used to send and receive payments from bank accounts. The IBAN may contain spaces.",
                  "type": "string",
                  "enum": [
                    "iban"
                  ]
                },
                "iban": {
                  "$ref": "#/$defs/IBAN"
                }
              }
            },
            {
              "title": "Cross-chain",
              "type": "object",
              "required": [
                "standard",
                "address",
                "chain"
              ],
              "properties": {
                "standard": {
                  "description": "Used to send cross chain transaction from one wallet to another on a different blockchain.",
                  "type": "string",
                  "enum": [
                    "chain"
                  ]
                },
                "address": {
                  "$ref": "#/$defs/Address"
                },
                "chain": {
                  "$ref": "#/$defs/Chain"
                }
              }
            },
            {
              "$ref": "#/$defs/BankAccount",
              "title": "Bank Account"
            }
          ]
        },
        "details": {
          "description": "Details about the counterpart. Empty for cross-chain orders.",
          "oneOf": [
            {
              "title": "Redeem orders for individuals",
              "type": "object",
              "description": "The counterpart is an individual.",
              "required": [
                "firstName",
                "lastName",
                "country"
              ],
              "properties": {
                "own": {
                  "description": "Indicates a personal own payout.",
                  "type": "boolean"
                },
                "firstName": {
                  "description": "The first name of the individual. The middle name(s) can also be included here.",
                  "type": "string",
                  "minLength": 2
                },
                "lastName": {
                  "description": "The last name of the individual.",
                  "type": "string",
                  "minLength": 2
                },
                "country": {
                  "description": "The two-letter country code (ISO 3166-1 alpha-2) representing the country where the counterpart lives. For more information, refer to the [ISO 3166-1 alpha-2 standard](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).",
                  "$ref": "#/$defs/CountryCode"
                }
              }
            },
            {
              "title": "Redeem orders for corporations",
              "type": "object",
              "required": [
                "companyName",
                "country"
              ],
              "properties": {
                "companyName": {
                  "description": "Used for outgoing payments when the recipient is a company",
                  "type": "string"
                },
                "country": {
                  "description": "The two-letter country code (ISO 3166-1 alpha-2) representing the country where the counterpart is located. For more information, refer to the [ISO 3166-1 alpha-2 standard](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).",
                  "$ref": "#/$defs/CountryCode"
                }
              }
            },
            {
              "title": "Issue orders",
              "type": "object",
              "required": [
                "name"
              ],
              "properties": {
                "name": {
                  "description": "The sender name. This can be a corporate or an individual.",
                  "type": "string"
                },
                "address": {
                  "description": "The sender's postal address, if requested by the sender's bank.",
                  "type": "string"
                }
              }
            }
          ]
        }
      },
      "required": [
        "details",
        "identifier"
      ]
    },
    "CountryCode": {
      "description": "Two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)",
      "type": "string",
      "maxLength": 2,
      "minLength": 2
    },
    "Currency": {
      "description": "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.",
      "type": "string",
      "enum": [
        "eur",
        "usd",
        "gbp",
        "isk"
      ]
    },
    "IBAN": {
      "description": "The IBAN is a unique identifier for a bank account across different countries and includes a two-letter country code, two check digits, and a number of alphanumeric characters. It may include spaces for readability but should be stored without spaces.",
      "type": "string",
      "pattern": "^(?:[A-Z]{2}[0-9]{2}(?:\\s?[0-9A-Z]{4}){1,7}\\s?[0-9A-Z]{1,4})$"
    },
    "Memo": {
      "description": "UTF-8 Payment reference supplied by the sender to provide additional information. Can be used as filter parameters when querying orders.\n",
      "type": "string",
      "maxLength": 140,
      "minLength": 5
    },
    "ReferenceNumber": {
      "description": "UTF-8 Payment reference. Structured identifier for a transaction or order, typically used for automatic payment reconciliation\n",
      "type": "string",
      "maxLength": 35,
      "minLength": 0
    },
    "TimeStamp": {
      "description": "The timestamp in [RFC3339](https://tools.ietf.org/html/rfc3339) format. It includes the date, time to the second, and optional fractional seconds, followed by 'Z' to indicate UTC time.",
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"
    },
    "UUID": {
      "type": "string",
      "format": "UUID",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
    }
  }
}