{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lune/json-schema/lune-paginated-client-accounts-schema.json",
  "title": "PaginatedClientAccounts",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lune-client-accounts-api-openapi.yml#/components/schemas/PaginatedClientAccounts",
  "allOf": [
    {
      "$ref": "#/$defs/PaginatedBase"
    },
    {
      "type": "object",
      "required": [
        "data"
      ],
      "properties": {
        "data": {
          "type": "array",
          "description": "An array of Client Account objects\n\nPart of a paginated response.\n",
          "items": {
            "$ref": "#/$defs/ClientAccountWithAnalyticSummary"
          }
        }
      }
    }
  ],
  "$defs": {
    "AccountBase": {
      "type": "object",
      "required": [
        "id",
        "name",
        "organisation_id",
        "organisation_type",
        "handle",
        "currency",
        "type",
        "logo",
        "beneficiary",
        "bundle_portfolio_id",
        "external_pages_visibility"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "The Account's unique identifier"
        },
        "name": {
          "type": "string",
          "description": "The Account's name"
        },
        "organisation_id": {
          "type": "string",
          "description": "The unique identifier of the organisation this account belongs to"
        },
        "organisation_type": {
          "$ref": "#/$defs/AccountOrganisationType"
        },
        "handle": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[a-z0-9-_]+$",
          "description": "`handle` is a client defined URL-friendly string that identifies the account.\n\nThe `handle` is unique per organisation and account type.\n"
        },
        "currency": {
          "$ref": "#/$defs/AccountCurrencyCode"
        },
        "type": {
          "$ref": "#/$defs/AccountType"
        },
        "logo": {
          "type": [
            "string",
            "null"
          ],
          "description": "The account logo"
        },
        "beneficiary": {
          "type": [
            "string",
            "null"
          ],
          "description": "Retirement beneficiary\n\nThis is the name that appears on future retirements that are made in this account.\nIf none is present, the organisation beneficiary will be used instead.\n",
          "minLength": 1
        },
        "bundle_portfolio_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Bundle portfolio id tied to the account."
        },
        "external_pages_visibility": {
          "$ref": "#/$defs/AccountExternalPagesVisibility"
        }
      }
    },
    "AccountCurrencyCode": {
      "type": "string",
      "description": "The account's currency.\n\nISO 4217 3 character currency code.\n\nNote: Lune does not support all currency codes.\n",
      "enum": [
        "GBP",
        "EUR",
        "USD",
        "SEK",
        "CHF",
        "PLN",
        "DKK",
        "NOK",
        "BGN",
        "INR",
        "SGD",
        "AED",
        "AUD",
        "HUF",
        "ISK",
        "CZK",
        "CAD"
      ]
    },
    "AccountExternalPagesVisibility": {
      "description": "Controls the visibility of external pages such as sustainability and analytics pages.\n\n`public` pages are visible to everyone.\n`private` pages are only visible through a verified JWT.\n`hidden` pages not visible.\n\nDefaults to `hidden`.\n",
      "type": "string",
      "enum": [
        "public",
        "hidden",
        "private"
      ]
    },
    "AccountIdempotencyKey": {
      "type": "string",
      "maxLength": 100,
      "description": "A unique identifier provided by the client.\n\n`idempotency_key` is unique per account type.\n\nIf an account with the same `idempotency_key` already exists, the API returns\nHTTP 409 Conflict with error code `account_idempotency_already_exists`.\n"
    },
    "AccountOrganisationType": {
      "type": "string",
      "description": "Indicates whether the account's organisation acts as a shipper or supplier.\n\nLegacy accounts without a stored value are returned as `shipper`.\n",
      "enum": [
        "shipper",
        "supplier"
      ]
    },
    "AccountType": {
      "type": "string",
      "description": "The account's type.\n",
      "enum": [
        "live",
        "test"
      ]
    },
    "ClientAccount": {
      "description": "Client accounts are designed for clients working with multi-tenancy applications.\n\nClient accounts are created programmatically. The API key (created in live or test mode) determines whether the Client account is a live or test account.\n\nCreate a Client Account for each of your customers to segregate their API operations.\n\nUse the special `Lune-Account` header to perform operations against a specific Client Account.\n",
      "allOf": [
        {
          "$ref": "#/$defs/AccountBase"
        }
      ],
      "type": "object",
      "required": [
        "scope"
      ],
      "properties": {
        "scope": {
          "type": "string",
          "enum": [
            "client_account"
          ]
        },
        "idempotency_key": {
          "oneOf": [
            {
              "$ref": "#/$defs/AccountIdempotencyKey"
            },
            {
              "$ref": "#/$defs/NullEnum"
            }
          ]
        }
      }
    },
    "ClientAccountWithAnalyticSummary": {
      "allOf": [
        {
          "$ref": "#/$defs/ClientAccount"
        },
        {
          "type": "object",
          "required": [
            "last_active_date",
            "number_of_estimates",
            "total_emissions"
          ],
          "properties": {
            "last_active_date": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "The time of the last estimate created by the account. If the account | has never created an estimate, this is null."
            },
            "number_of_estimates": {
              "type": "number",
              "description": "All-time number of estimates created by given account."
            },
            "total_emissions": {
              "type": "string",
              "description": "All-time tCO2e calculated in estimates created by given account."
            }
          }
        }
      ]
    },
    "NullEnum": {
      "type": [
        "string",
        "null"
      ],
      "x-lune-name": "Null",
      "description": "The property is set to `null`.",
      "enum": [
        null
      ]
    },
    "PaginatedBase": {
      "type": "object",
      "required": [
        "has_more",
        "next_cursor"
      ],
      "properties": {
        "has_more": {
          "type": "boolean",
          "description": "Whether or not there are more elements available after this set.\n\nIf false, this set comprises the end of the array.\n\nPart of a paginated response.\n"
        },
        "next_cursor": {
          "description": "The cursor value to be used as the after parameter for fetching the next page of results.\n\n`null` if `has_more` is `false`.\n",
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}