{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/observeinc/json-schema/observeinc-service-account-list-response-schema.json",
  "title": "ServiceAccountListResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/observeinc-service-accounts-api-openapi.yml#/components/schemas/ServiceAccount-ListResponse",
  "type": "object",
  "required": [
    "serviceAccounts",
    "meta"
  ],
  "properties": {
    "serviceAccounts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ServiceAccount-Resource"
      }
    },
    "meta": {
      "$ref": "#/$defs/Meta"
    }
  },
  "$defs": {
    "Meta": {
      "description": "List Response Metadata",
      "type": "object",
      "required": [
        "totalCount"
      ],
      "properties": {
        "totalCount": {
          "description": "The total number of resources available, independent of pagination.\nThe API may return -1 if the total count is unknown or cannot be computed\nin reasonable time.\n",
          "type": "integer",
          "format": "int64"
        }
      }
    },
    "OAuthExternalIntegrationRef": {
      "title": "OAuthExternalIntegrationRef",
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/ObjectId"
        }
      }
    },
    "ObjectId": {
      "type": "string",
      "format": "ObjectId"
    },
    "RbacGroupRef": {
      "title": "RbacGroupRef",
      "description": "Reference to an RBAC group, including id, label, and description.",
      "type": "object",
      "required": [
        "id",
        "legacyId",
        "label",
        "description"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/ObjectId"
        },
        "legacyId": {
          "type": "string",
          "description": "Deprecated. For compatibility with legacy APIs.",
          "deprecated": true
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "ServiceAccount-ExternalOAuth": {
      "title": "ServiceAccountExternalOAuth",
      "type": "object",
      "required": [
        "integration",
        "subject"
      ],
      "properties": {
        "integration": {
          "$ref": "#/$defs/OAuthExternalIntegrationRef"
        },
        "subject": {
          "type": "string",
          "description": "The external identity subject (JWT sub/oid claim) this service account is bound to."
        }
      }
    },
    "ServiceAccount-Resource": {
      "title": "ServiceAccountObject",
      "type": "object",
      "required": [
        "id",
        "label",
        "description",
        "createdBy",
        "createdAt",
        "updatedBy",
        "updatedAt",
        "disabled",
        "externalOAuth"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/ObjectId"
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "createdBy": {
          "$ref": "#/$defs/User"
        },
        "createdAt": {
          "$ref": "#/$defs/Time"
        },
        "updatedBy": {
          "$ref": "#/$defs/User"
        },
        "updatedAt": {
          "$ref": "#/$defs/Time"
        },
        "disabled": {
          "type": "boolean",
          "description": "Whether the service account is disabled. Disabling a service account will delete all of its API tokens."
        },
        "apiTokenCount": {
          "type": "integer",
          "format": "int64",
          "description": "Number of API tokens for this service account. Includes recently expired and disabled tokens. Only populated when the expand query parameter is set to true."
        },
        "rbacGroups": {
          "type": "array",
          "description": "RBAC groups this service account belongs to. Only populated when the expand query parameter is set to true.",
          "items": {
            "$ref": "#/$defs/RbacGroupRef"
          }
        },
        "externalOAuth": {
          "description": "The external OAuth binding for this service account, or null if no binding exists.",
          "anyOf": [
            {
              "$ref": "#/$defs/ServiceAccount-ExternalOAuth"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "Time": {
      "type": "string",
      "format": "RFC3339"
    },
    "User": {
      "title": "User",
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "title": "User Identifier",
          "$ref": "#/$defs/ObjectId"
        },
        "label": {
          "title": "User Label",
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "locale": {
          "type": "string"
        }
      }
    }
  }
}