{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/benjipays-com/json-schema/benjipays-com-list-customers-response-schema.json",
  "title": "ListCustomersResponse",
  "description": "Paginated customer list response (summary DTO only — no accounting passthrough)",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/benjipays-com-customers-api-openapi.yml#/components/schemas/ListCustomersResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CustomerSummary"
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "total": {
          "type": "number",
          "description": "Total matching customers across all pages"
        },
        "limit": {
          "type": "number"
        },
        "offset": {
          "type": "number"
        },
        "hasMore": {
          "type": "boolean"
        },
        "nextOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "prevOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "total",
        "limit",
        "offset",
        "hasMore",
        "nextOffset",
        "prevOffset"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "data",
    "pagination"
  ],
  "additionalProperties": false,
  "$defs": {
    "CustomerAutoPaySettings": {
      "type": "object",
      "properties": {
        "applyCreditMemos": {
          "type": "boolean"
        },
        "autoProcessingDisabled": {
          "type": "boolean"
        },
        "delayDays": {
          "type": "number"
        },
        "surchargingDisabled": {
          "type": "boolean"
        },
        "autoProcessAmountSkip": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "applyCreditMemos",
        "autoProcessingDisabled",
        "delayDays",
        "surchargingDisabled",
        "autoProcessAmountSkip"
      ],
      "additionalProperties": false,
      "description": "Per-customer auto-pay / processing overrides."
    },
    "CustomerBillingAddress": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "line1": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "line2": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "city": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "region": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "postalCode": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "country": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "line1",
            "city",
            "postalCode",
            "country"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Billing address normalized across accounting systems."
    },
    "CustomerEmail": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "source": {
          "type": "string"
        }
      },
      "required": [
        "email"
      ],
      "additionalProperties": false,
      "description": "Customer email entry (Benji emails[] slimmed for the API)."
    },
    "CustomerPortalSettings": {
      "type": "object",
      "properties": {
        "portalAccessDisabled": {
          "type": "boolean"
        },
        "defaultLanguage": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "forceSavePaymentMethod": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "description": "Customer-level override of \"force save payment method\": `true` = force, `false` = never, `null` = inherit (from the parent profile customer when parent profiles are enabled, otherwise from the portal setting). This is the stored customer value, not the resolved effective value."
        }
      },
      "required": [
        "portalAccessDisabled",
        "defaultLanguage",
        "forceSavePaymentMethod"
      ],
      "additionalProperties": false,
      "description": "Per-customer portal overrides (portal.* company settings)."
    },
    "CustomerSummary": {
      "type": "object",
      "properties": {
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Accounting system customer ID (same value accepted by GET /customers/:customerId)"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Customer display name from the accounting system"
        },
        "email": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "phone": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "active": {
          "type": "boolean"
        },
        "isProject": {
          "description": "QBO-only (Jobs/sub-customers); omitted entirely for QBD, Xero, and Business Central.",
          "type": "boolean"
        },
        "parents": {
          "description": "Sub-customer/job hierarchy, direct parent first. QBO/QBD only; omitted entirely for Xero/Business Central.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "id"
            ],
            "additionalProperties": false
          }
        },
        "balance": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO 4217 currency code when available"
        },
        "billingAddress": {
          "$ref": "#/$defs/CustomerBillingAddress"
        },
        "createdDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "lastModifiedDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "emails": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CustomerEmail"
          }
        },
        "paymentMethodsCount": {
          "type": "number"
        },
        "autoPaySettings": {
          "$ref": "#/$defs/CustomerAutoPaySettings"
        },
        "emailRemindersDisabled": {
          "type": "boolean"
        },
        "portalSettings": {
          "$ref": "#/$defs/CustomerPortalSettings"
        },
        "accounting": {
          "description": "Full stored customer object (fields from the accounting system plus our own). Only present on GET /customers/:customerId when include=accounting.",
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      },
      "required": [
        "id",
        "name",
        "email",
        "phone",
        "active",
        "balance",
        "currency",
        "billingAddress",
        "createdDate",
        "lastModifiedDate",
        "emails",
        "paymentMethodsCount",
        "autoPaySettings",
        "emailRemindersDisabled",
        "portalSettings"
      ],
      "additionalProperties": false,
      "description": "Benji-controlled camelCase customer summary. Top-level = stable API; optional `accounting` = full stored customer (accounting-system fields plus our own; detail + include=accounting only)."
    }
  }
}