{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nmi/json-schema/nmi-invoice-response-schema.json",
  "title": "Invoice Response",
  "description": "Invoice response matching InvoiceRestSerializer structure",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nmi-invoicing-api-openapi.yml#/components/schemas/InvoiceResponse",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "invoice"
      ],
      "description": "Resource type identifier"
    },
    "id": {
      "type": "integer",
      "description": "Invoice ID"
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "partially_paid",
        "paid",
        "closed",
        "overdue"
      ],
      "description": "Current status of the invoice"
    },
    "amount": {
      "type": "string",
      "description": "Total amount of the invoice. Format: `x.xx`"
    },
    "subtotal": {
      "type": [
        "number",
        "null"
      ],
      "description": "Subtotal amount before tax and shipping"
    },
    "payment_terms": {
      "type": "string",
      "description": "Payment terms for the invoice (e.g., 'Due Upon Receipt', '30 days')"
    },
    "payment_methods_allowed": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "cc",
          "ck",
          "cs"
        ]
      },
      "description": "Allowed payment methods: 'cc' = Credit Card, 'ck' = Check, 'cs' = Cash"
    },
    "processor_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Processor ID for payment processing"
    },
    "currency": {
      "type": "string",
      "description": "Currency code (ISO 4217, e.g., USD, EUR)"
    },
    "created_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Date and time when the invoice was created in UTC ISO 8601 format"
    },
    "updated_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Date and time when the invoice was last updated in UTC ISO 8601 format"
    },
    "billing_address": {
      "type": "object",
      "description": "Billing address information",
      "properties": {
        "first_name": {
          "type": "string",
          "description": "First name"
        },
        "last_name": {
          "type": "string",
          "description": "Last name"
        },
        "company": {
          "type": "string",
          "description": "Company name"
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "Email address"
        },
        "phone": {
          "type": "string",
          "description": "Phone number"
        },
        "fax": {
          "type": "string",
          "description": "Fax number"
        },
        "website": {
          "type": "string",
          "maxLength": 255,
          "description": "Website"
        },
        "address1": {
          "type": "string",
          "description": "Address line 1"
        },
        "address2": {
          "type": "string",
          "description": "Address line 2"
        },
        "city": {
          "type": "string",
          "description": "City"
        },
        "state": {
          "type": "string",
          "description": "State or province"
        },
        "zip": {
          "type": "string",
          "description": "ZIP or postal code"
        },
        "country": {
          "type": "string",
          "description": "Country code (ISO 3166-1 alpha-2)"
        }
      }
    },
    "shipping_address": {
      "type": "object",
      "description": "Shipping address information",
      "properties": {
        "first_name": {
          "type": "string",
          "description": "First name"
        },
        "last_name": {
          "type": "string",
          "description": "Last name"
        },
        "company": {
          "type": "string",
          "description": "Company name"
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "Email address"
        },
        "address1": {
          "type": "string",
          "description": "Address line 1"
        },
        "address2": {
          "type": "string",
          "description": "Address line 2"
        },
        "city": {
          "type": "string",
          "description": "City"
        },
        "state": {
          "type": "string",
          "description": "State or province"
        },
        "zip": {
          "type": "string",
          "description": "ZIP or postal code"
        },
        "country": {
          "type": "string",
          "description": "Country code (ISO 3166-1 alpha-2)"
        }
      }
    },
    "order_details": {
      "type": "object",
      "description": "Order details",
      "properties": {
        "order_id": {
          "type": "string",
          "description": "Order ID"
        },
        "ip_address": {
          "type": "string",
          "description": "IP address"
        },
        "order_description": {
          "type": "string",
          "description": "Order description"
        },
        "po_number": {
          "type": "string",
          "description": "Purchase order number"
        },
        "customer_id": {
          "type": "string",
          "description": "Customer ID"
        },
        "customer_tax_id": {
          "type": "string",
          "description": "Customer tax ID"
        },
        "tax": {
          "type": "string",
          "description": "Tax amount. Format: `x.xx`"
        },
        "shipping": {
          "type": "string",
          "description": "Shipping amount. Format: `x.xx`"
        },
        "discount_amount": {
          "type": "string",
          "description": "Discount amount. Format: `x.xx`"
        },
        "surcharge": {
          "type": "string",
          "description": "Surcharge amount. Format: `x.xx`"
        },
        "tip": {
          "type": "string",
          "description": "Tip amount. Format: `x.xx`"
        },
        "shipping_carrier": {
          "type": "string",
          "description": "Shipping carrier"
        },
        "tracking_number": {
          "type": "string",
          "description": "Tracking number"
        },
        "shipping_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Shipping date in UTC ISO 8601 format"
        }
      }
    },
    "merchant_defined_fields": {
      "$ref": "#/$defs/MerchantDefinedFields",
      "description": "Merchant defined fields (`field_1` through `field_20`). Only non-empty values are included; returns an empty object when none are set."
    }
  },
  "required": [
    "object",
    "id"
  ],
  "$defs": {
    "MerchantDefinedFields": {
      "type": "object",
      "title": "Merchant Defined Fields",
      "description": "Custom fields configured in the merchant control panel under Settings → Merchant Defined Fields (`field_1` through `field_20`).",
      "properties": {
        "field_1": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 1"
        },
        "field_2": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 2"
        },
        "field_3": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 3"
        },
        "field_4": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 4"
        },
        "field_5": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 5"
        },
        "field_6": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 6"
        },
        "field_7": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 7"
        },
        "field_8": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 8"
        },
        "field_9": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 9"
        },
        "field_10": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 10"
        },
        "field_11": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 11"
        },
        "field_12": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 12"
        },
        "field_13": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 13"
        },
        "field_14": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 14"
        },
        "field_15": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 15"
        },
        "field_16": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 16"
        },
        "field_17": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 17"
        },
        "field_18": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 18"
        },
        "field_19": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 19"
        },
        "field_20": {
          "type": "string",
          "maxLength": 255,
          "description": "Merchant defined field 20"
        }
      }
    }
  }
}