{
  "openapi": "3.0.3",
  "info": {
    "title": "Payment Processing API",
    "version": "1.0.0",
    "description": "JOD-only atomic internal transfers. Send immutable UUID IDs on retries; first completion 201, replay 200, durable rejection retains original error. Scope payments:write for submit, payments:read for queries, payments:admin for reconciliation. Debit permission is owner/delegate; destination must allow incoming transfers. Scope and ownership are both enforced. Responses have X-Correlation-ID. Unknown fields, duplicate keys/elements, unsafe XML and coercion are rejected."
  },
  "servers": [
    {
      "url": "https://payments.example.invalid"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/payments": {
      "post": {
        "summary": "Submit one payment after transaction commit",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Payment"
              },
              "example": {
                "paymentId": "d92192df-f79a-4553-8120-5660d2eb1294",
                "fromAccount": "ACC-1001",
                "toAccount": "ACC-2002",
                "amount": "125.750",
                "date": "2026-10-28T13:30:00+03:00",
                "purpose": "Invoice payment INV-2048",
                "notes": "October services"
              }
            },
            "application/xml": {
              "schema": {
                "$ref": "#/components/schemas/Payment"
              },
              "example": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><payment><paymentId>d92192df-f79a-4553-8120-5660d2eb1294</paymentId><fromAccount>ACC-1001</fromAccount><toAccount>ACC-2002</toAccount><amount>125.750</amount><date>2026-10-28T13:30:00+03:00</date><purpose>Invoice payment INV-2048</purpose><notes>October services</notes></payment>"
            }
          }
        },
        "responses": {
          "201": {
            "description": "New completed payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                },
                "example": {
                  "paymentId": "d92192df-f79a-4553-8120-5660d2eb1294",
                  "fromAccount": "ACC-1001",
                  "toAccount": "ACC-2002",
                  "amount": "125.750",
                  "status": "COMPLETED",
                  "currency": "JOD",
                  "processedAt": "2026-10-28T10:30:01Z"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "Original completed receipt, replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                },
                "example": {
                  "paymentId": "d92192df-f79a-4553-8120-5660d2eb1294",
                  "fromAccount": "ACC-1001",
                  "toAccount": "ACC-2002",
                  "amount": "125.750",
                  "status": "COMPLETED",
                  "currency": "JOD",
                  "processedAt": "2026-10-28T10:30:01Z"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "MALFORMED_MESSAGE or VALIDATION_FAILED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN or TLS_REQUIRED (account existence is concealed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND (including concealed account/payment existence)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "406": {
            "description": "NOT_ACCEPTABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "ACCOUNT_NOT_ACTIVE, INSUFFICIENT_FUNDS, IDEMPOTENCY_CONFLICT, PAYMENT_LIMIT_EXCEEDED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED_MEDIA_TYPE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "TEMPORARILY_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/{paymentId}": {
      "get": {
        "summary": "Authorized status retrieval",
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored result (payment status may be REJECTED; see Error schema)",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Receipt"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              },
              "application/xml": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Receipt"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "MALFORMED_MESSAGE or VALIDATION_FAILED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN or TLS_REQUIRED (account existence is concealed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND (including concealed account/payment existence)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "406": {
            "description": "NOT_ACCEPTABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "ACCOUNT_NOT_ACTIVE, INSUFFICIENT_FUNDS, IDEMPOTENCY_CONFLICT, PAYMENT_LIMIT_EXCEEDED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED_MEDIA_TYPE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "TEMPORARILY_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/balance": {
      "get": {
        "summary": "Authorized current available balance",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "MALFORMED_MESSAGE or VALIDATION_FAILED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN or TLS_REQUIRED (account existence is concealed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND (including concealed account/payment existence)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "406": {
            "description": "NOT_ACCEPTABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "ACCOUNT_NOT_ACTIVE, INSUFFICIENT_FUNDS, IDEMPOTENCY_CONFLICT, PAYMENT_LIMIT_EXCEEDED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED_MEDIA_TYPE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "TEMPORARILY_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/reconciliation": {
      "get": {
        "summary": "Privileged read-only ledger and balance reconciliation",
        "responses": {
          "200": {
            "description": "Empty issues means reconciled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reconciliation"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Reconciliation"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "MALFORMED_MESSAGE or VALIDATION_FAILED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN or TLS_REQUIRED (account existence is concealed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND (including concealed account/payment existence)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "406": {
            "description": "NOT_ACCEPTABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "ACCOUNT_NOT_ACTIVE, INSUFFICIENT_FUNDS, IDEMPOTENCY_CONFLICT, PAYMENT_LIMIT_EXCEEDED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED_MEDIA_TYPE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "TEMPORARILY_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/retention": {
      "get": {
        "summary": "Read-only configurable minimum-retention archive review report",
        "responses": {
          "200": {
            "description": "Reports age cutoff and record count; performs no deletion",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "minimumRetentionDays": {
                      "type": "integer"
                    },
                    "cutoff": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "paymentsOlderThanMinimum": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "action": {
                      "type": "string"
                    }
                  }
                }
              },
              "application/xml": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "minimumRetentionDays": {
                      "type": "integer"
                    },
                    "cutoff": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "paymentsOlderThanMinimum": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "action": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "MALFORMED_MESSAGE or VALIDATION_FAILED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN or TLS_REQUIRED (account existence is concealed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND (including concealed account/payment existence)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "406": {
            "description": "NOT_ACCEPTABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "ACCOUNT_NOT_ACTIVE, INSUFFICIENT_FUNDS, IDEMPOTENCY_CONFLICT, PAYMENT_LIMIT_EXCEEDED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED_MEDIA_TYPE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "TEMPORARILY_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Delay in seconds before retrying with the SAME payment ID"
              },
              "X-Correlation-ID": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "Payment": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "paymentId",
          "fromAccount",
          "toAccount",
          "amount",
          "date",
          "purpose"
        ],
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "fromAccount": {
            "type": "string"
          },
          "toAccount": {
            "type": "string"
          },
          "amount": {
            "oneOf": [
              {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 10000,
                "multipleOf": 0.001
              },
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,3})?$"
              }
            ],
            "description": "Exact decimal, positive, maximum 10000.000; no rounding. JSON numbers parsed as BigDecimal."
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "purpose": {
            "type": "string",
            "maxLength": 255
          },
          "notes": {
            "type": "string",
            "maxLength": 1000
          }
        },
        "xml": {
          "name": "payment"
        }
      },
      "Receipt": {
        "type": "object",
        "required": [
          "paymentId",
          "fromAccount",
          "toAccount",
          "amount",
          "status",
          "currency",
          "processedAt"
        ],
        "properties": {
          "paymentId": {
            "type": "string"
          },
          "fromAccount": {
            "type": "string"
          },
          "toAccount": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "COMPLETED"
            ]
          },
          "currency": {
            "type": "string"
          },
          "processedAt": {
            "type": "string"
          }
        },
        "xml": {
          "name": "response"
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "status",
          "code",
          "message",
          "issues",
          "correlationId",
          "timestamp"
        ],
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "ERROR",
              "REJECTED"
            ]
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "correlationId": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "example": {
          "status": "ERROR",
          "code": "VALIDATION_FAILED",
          "message": "The payment could not be completed.",
          "issues": [
            {
              "field": "amount",
              "code": "INVALID_AMOUNT",
              "message": "The field does not meet the required constraints."
            }
          ],
          "correlationId": "84b2e7b7-df46-4a7e-aa50-87352a37fd4f",
          "timestamp": "2026-10-28T10:30:01Z"
        },
        "xml": {
          "name": "response"
        }
      },
      "Balance": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string"
          },
          "availableBalance": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          }
        },
        "xml": {
          "name": "response"
        }
      },
      "Reconciliation": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "issue": {
                  "type": "string"
                },
                "reference": {
                  "type": "string"
                }
              }
            }
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "xml": {
          "name": "response"
        }
      }
    }
  }
}
