{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nmi/json-schema/nmi-customer-response-schema.json",
  "title": "Customer Response",
  "description": "Customer 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/CustomerResponse",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "customer"
      ],
      "description": "Resource type identifier"
    },
    "id": {
      "type": "string",
      "description": "Customer vault ID"
    },
    "created": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Customer creation date in UTC ISO 8601 format"
    },
    "billing": {
      "type": "array",
      "description": "Array of billing addresses",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "billing"
            ],
            "description": "Resource type identifier"
          },
          "id": {
            "type": "string",
            "description": "Billing address ID (address_name)"
          },
          "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 or province"
          },
          "zip": {
            "type": "string",
            "description": "ZIP or postal 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",
              "null"
            ],
            "description": "Priority of the billing address"
          },
          "payment_details": {
            "$ref": "#/$defs/CustomerVaultPaymentDetailsResponse"
          }
        },
        "required": [
          "object",
          "id"
        ]
      }
    },
    "shipping": {
      "type": "array",
      "description": "Array of shipping addresses",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "shipping"
            ],
            "description": "Resource type identifier"
          },
          "id": {
            "type": "string",
            "description": "Shipping address ID (shipping_address_name)"
          },
          "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 or province"
          },
          "zip": {
            "type": "string",
            "description": "ZIP or postal 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",
              "null"
            ],
            "description": "Priority of the shipping address"
          }
        },
        "required": [
          "object",
          "id"
        ]
      }
    },
    "merchant_defined_fields": {
      "$ref": "#/$defs/MerchantDefinedFields",
      "description": "Merchant defined fields stored with the customer (`field_1` through `field_20`). Only non-empty values are included; returns an empty object when none are set."
    }
  },
  "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"
            }
          }
        }
      ]
    },
    "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"
        }
      }
    }
  }
}