{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/benjipays-com/json-schema/benjipays-com-list-organizations-response-schema.json",
  "title": "ListOrganizationsResponse",
  "description": "Paginated list of organizations",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/benjipays-com-benji-pays-partner-api-openapi.yml#/components/schemas/ListOrganizationsResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrganizationListItem"
      },
      "description": "Array of organizations"
    },
    "pagination": {
      "type": "object",
      "properties": {
        "hasMore": {
          "type": "boolean",
          "description": "Whether more results are available"
        },
        "nextOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Offset for next page (null if no more pages)"
        },
        "prevOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Offset for previous page (null if first page)"
        },
        "limit": {
          "type": "number",
          "description": "Maximum number of results per page"
        },
        "offset": {
          "type": "number",
          "description": "Number of results skipped"
        }
      },
      "required": [
        "hasMore",
        "nextOffset",
        "prevOffset",
        "limit",
        "offset"
      ],
      "additionalProperties": false,
      "description": "Pagination metadata"
    }
  },
  "required": [
    "data",
    "pagination"
  ],
  "additionalProperties": false,
  "$defs": {
    "ApiParent": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "distributor",
            "partner"
          ],
          "description": "Parent type — distributor or partner"
        },
        "distributorExternalId": {
          "type": "string",
          "description": "Distributor external ID"
        },
        "partnerExternalId": {
          "description": "Partner external ID (present when type is partner)",
          "type": "string"
        },
        "partnerId": {
          "description": "Partner MongoDB ObjectId (present when type is partner)",
          "type": "string"
        }
      },
      "required": [
        "type",
        "distributorExternalId"
      ],
      "additionalProperties": false,
      "description": "API parent — who created the organization"
    },
    "OrganizationListItem": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Organization identifier (same value as path `organizationId`)"
        },
        "apiParent": {
          "$ref": "#/$defs/ApiParent"
        },
        "name": {
          "type": "string",
          "description": "Organization name"
        },
        "externalId": {
          "type": "string",
          "description": "Distributor's external ID for this organization"
        },
        "planId": {
          "type": "string",
          "description": "MongoDB ObjectId of the billing plan"
        },
        "status": {
          "type": "string",
          "description": "Organization status"
        },
        "closed": {
          "type": "boolean",
          "description": "Whether the organization is closed (derived from !enabled)"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
          "description": "ISO 8601 timestamp when organization was created"
        }
      },
      "required": [
        "id",
        "apiParent",
        "name",
        "externalId",
        "planId",
        "status",
        "closed",
        "createdAt"
      ],
      "additionalProperties": false,
      "description": "Organization list item"
    }
  }
}