{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nmi/json-schema/nmi-billing-address-response-schema.json",
  "title": "Billing Address Response",
  "description": "Billing address response matching CustomerRestSerializer structure",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nmi-customers-api-openapi.yml#/components/schemas/BillingAddressResponse",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "billing"
      ],
      "description": "Resource type identifier"
    },
    "id": {
      "type": "string",
      "description": "Billing address ID"
    },
    "first_name": {
      "type": "string",
      "description": "First name"
    },
    "last_name": {
      "type": "string",
      "description": "Last name"
    },
    "company": {
      "type": "string",
      "description": "Company name"
    },
    "address1": {
      "type": "string",
      "description": "Address line 1"
    },
    "address2": {
      "type": "string",
      "description": "Address line 2"
    },
    "city": {
      "type": "string",
      "description": "City"
    },
    "state": {
      "type": "string",
      "description": "State"
    },
    "zip": {
      "type": "string",
      "description": "ZIP code"
    },
    "country": {
      "type": "string",
      "description": "Country code (ISO 3166-1 alpha-2)"
    },
    "phone": {
      "type": "string",
      "description": "Phone number"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Email address"
    },
    "fax": {
      "type": "string",
      "description": "Fax number"
    },
    "priority": {
      "type": "integer",
      "description": "Billing address priority"
    },
    "payment_details": {
      "$ref": "#/$defs/CustomerVaultPaymentDetailsResponse"
    }
  },
  "required": [
    "object",
    "id"
  ],
  "$defs": {
    "CustomerVaultPaymentDetailsResponse": {
      "title": "Customer Vault Payment Details",
      "description": "Masked payment method on a customer vault billing record response.",
      "oneOf": [
        {
          "type": "object",
          "title": "Credit card on file",
          "additionalProperties": false,
          "required": [
            "card_number",
            "card_exp"
          ],
          "properties": {
            "card_number": {
              "type": "string",
              "description": "Masked card number"
            },
            "card_exp": {
              "type": "string",
              "description": "Card expiration date. Format: `MMYY`"
            }
          }
        },
        {
          "type": "object",
          "title": "ACH on file",
          "additionalProperties": false,
          "properties": {
            "check_account": {
              "type": "string",
              "description": "Masked bank account number"
            },
            "check_aba": {
              "type": "string",
              "description": "Bank routing number"
            },
            "check_name": {
              "type": "string",
              "description": "Name on the ACH account"
            },
            "account_type": {
              "type": "string",
              "enum": [
                "checking",
                "savings"
              ],
              "description": "ACH account type"
            },
            "account_holder_type": {
              "type": "string",
              "enum": [
                "personal",
                "business"
              ],
              "description": "ACH account holder type"
            },
            "sec_code": {
              "type": "string",
              "description": "Standard Entry Class code"
            }
          }
        }
      ]
    }
  }
}