{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/clarafintech/main/json-schema/clarafintech-transaction-v3-schema.json",
  "title": "TransactionV3",
  "x-generated": "2026-10-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clarafintech-openapi.json#/components/schemas/TransactionV3",
  "type": "object",
  "required": [
    "uuid",
    "type",
    "status",
    "amountValue"
  ],
  "properties": {
    "uuid": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "$ref": "#/$defs/TransactionType"
    },
    "transactionLabel": {
      "type": "string"
    },
    "status": {
      "oneOf": [
        {
          "$ref": "#/$defs/TransactionStatus"
        },
        {
          "$ref": "#/$defs/StatusObject"
        }
      ]
    },
    "amountValue": {
      "$ref": "#/$defs/Money"
    },
    "originalAmount": {
      "$ref": "#/$defs/Money"
    },
    "merchant": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "mcc": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "card": {
      "type": "object",
      "properties": {
        "uuid": {
          "type": "string",
          "format": "uuid"
        },
        "lastFourDigits": {
          "type": "string"
        },
        "maskedPan": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "user": {
      "$ref": "#/$defs/CardUser"
    },
    "labels": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "billingStatement": {
      "$ref": "#/$defs/BillingStatementV3"
    },
    "hasInvoice": {
      "type": [
        "boolean",
        "object"
      ]
    },
    "hasAttachments": {
      "type": [
        "boolean",
        "object"
      ]
    },
    "hasExtractedDocuments": {
      "type": [
        "boolean",
        "object"
      ]
    },
    "accountingFields": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "accountingStatus": {
      "$ref": "#/$defs/AccountingStatus"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "AccountingStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "NEEDS_REVIEW",
            "READY_TO_EXPORT",
            "EXPORTED"
          ],
          "description": "Accounting Module review status for this transaction, independent from the root-level auth/approval status field. Present for authorized operations (operation types OP and EC, exposed as AUTHORIZED and SYSTEM_TRANSACTION respectively); null for any other operation type."
        }
      },
      "additionalProperties": true
    },
    "BillingStatementV3": {
      "type": "object",
      "properties": {
        "uuid": {
          "type": "string",
          "format": "uuid"
        },
        "statementStartDate": {
          "type": "string",
          "format": "date"
        },
        "statementEndDate": {
          "type": "string",
          "format": "date"
        },
        "currency": {
          "type": "string",
          "enum": [
            "MXN",
            "BRL",
            "COP"
          ]
        },
        "totalAmount": {
          "type": "number"
        },
        "status": {
          "type": "string",
          "enum": [
            "OPEN",
            "CLOSED"
          ]
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": true
    },
    "CardUser": {
      "type": "object",
      "properties": {
        "uuid": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "fullName": {
          "type": "string"
        },
        "username": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email"
        }
      },
      "additionalProperties": true
    },
    "Money": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Decimal currency units, not cents."
        },
        "amount": {
          "type": "number",
          "description": "Decimal currency units, not cents. Some responses use amount instead of value."
        },
        "currency": {
          "type": "string",
          "enum": [
            "MXN",
            "BRL",
            "COP"
          ]
        }
      },
      "additionalProperties": true
    },
    "StatusObject": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "TransactionStatus": {
      "type": "string",
      "enum": [
        "NOTIFICATION",
        "PRE_AUTHORIZED",
        "AUTHORIZED",
        "REJECTED",
        "SYSTEM_TRANSACTION"
      ]
    },
    "TransactionType": {
      "type": "string",
      "enum": [
        "PURCHASE",
        "REFUND",
        "FEE",
        "CREDIT",
        "PAYMENT"
      ]
    }
  }
}