{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/safetyculture/json-schema/safetyculture-s12-contractors-v1-list-contractor-companies-request-schema.json",
  "title": "s12.contractors.v1.ListContractorCompaniesRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/safetyculture-companies-api-openapi.yml#/components/schemas/s12.contractors.v1.ListContractorCompaniesRequest",
  "type": "object",
  "properties": {
    "filter": {
      "description": "Additional filters to apply to the request.",
      "allOf": [
        {
          "$ref": "#/$defs/s12.contractors.v1.ContractorCompanyFilter"
        }
      ]
    },
    "sort_field": {
      "description": "The field to sort by.",
      "allOf": [
        {
          "$ref": "#/$defs/s12.contractors.v1.ContractorCompanySortField"
        }
      ]
    },
    "sort_direction": {
      "description": "The sort order.",
      "allOf": [
        {
          "$ref": "#/$defs/s12.common.SortDirection"
        }
      ]
    },
    "page_size": {
      "type": "integer",
      "format": "int32",
      "description": "The number of companies to return in a single request."
    },
    "page_token": {
      "type": "string",
      "description": "If present, will fetch the next page of results. This must be the value of `next_page_token` from the response."
    },
    "include_compliance_stats": {
      "type": "boolean",
      "description": "Deprecated. This does nothing. Compliance statistics are now always included in the response."
    },
    "include_user_credential_compliance_stats": {
      "type": "boolean",
      "description": "Temporary migration flag. When true, includes user credential compliance statistics in the response. Defaults to false."
    }
  },
  "$defs": {
    "s12.common.SortDirection": {
      "type": "string",
      "enum": [
        "SORT_DIRECTION_UNSPECIFIED",
        "SORT_DIRECTION_ASC",
        "SORT_DIRECTION_DESC"
      ],
      "default": "SORT_DIRECTION_UNSPECIFIED",
      "title": "Common set of sorting directions as used by lists"
    },
    "s12.contractors.v1.AddressDirectoryFilter": {
      "type": "object",
      "properties": {
        "country_codes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Filter by specific country codes (ISO 3166-1 alpha-2).\nCase-insensitive. Multiple values use OR logic (returns companies matching ANY code).\nExample: [\"US\", \"AU\"] returns companies in US OR Australia."
        },
        "administrative_areas": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Filter by specific administrative area names (administrative_area_level_1).\nCase-insensitive. Multiple values use OR logic (returns companies matching ANY area).\nExamples: US states (\"CA\", \"NY\"), Canadian provinces (\"ON\", \"BC\"),\nUK counties, Australian states (\"NSW\", \"VIC\").\nWhen combined with country_codes, uses AND logic\n(e.g., country_codes=[\"US\"] AND administrative_areas=[\"CA\"] returns only US companies in California)."
        }
      },
      "description": "Filter options for address directory queries.\nAll filtering is case-insensitive (e.g., \"US\", \"us\", \"Us\" all match \"US\")."
    },
    "s12.contractors.v1.ComplianceFilterType": {
      "type": "string",
      "enum": [
        "COMPLIANCE_FILTER_TYPE_HAS_EXPIRED_DOCUMENTS",
        "COMPLIANCE_FILTER_TYPE_HAS_EXPIRING_SOON_DOCUMENTS",
        "COMPLIANCE_FILTER_TYPE_HAS_PENDING_APPROVAL_DOCUMENTS",
        "COMPLIANCE_FILTER_TYPE_HAS_INCOMPLETE_REQUIREMENTS",
        "COMPLIANCE_FILTER_TYPE_HAS_EXPIRED_USER_CREDENTIALS",
        "COMPLIANCE_FILTER_TYPE_HAS_EXPIRING_SOON_USER_CREDENTIALS",
        "COMPLIANCE_FILTER_TYPE_HAS_PENDING_APPROVAL_USER_CREDENTIALS"
      ],
      "description": "ComplianceFilterType specifies the type of document compliance issue to filter by.\n\n - COMPLIANCE_FILTER_TYPE_HAS_EXPIRED_DOCUMENTS: Filter for companies with expired documents.\n - COMPLIANCE_FILTER_TYPE_HAS_EXPIRING_SOON_DOCUMENTS: Filter for companies with documents expiring soon.\n - COMPLIANCE_FILTER_TYPE_HAS_PENDING_APPROVAL_DOCUMENTS: Filter for companies with documents pending approval.\n - COMPLIANCE_FILTER_TYPE_HAS_INCOMPLETE_REQUIREMENTS: Filter for companies with incomplete requirements.\n - COMPLIANCE_FILTER_TYPE_HAS_EXPIRED_USER_CREDENTIALS: Filter for companies with expired user credentials.\n - COMPLIANCE_FILTER_TYPE_HAS_EXPIRING_SOON_USER_CREDENTIALS: Filter for companies with user credentials expiring soon.\n - COMPLIANCE_FILTER_TYPE_HAS_PENDING_APPROVAL_USER_CREDENTIALS: Filter for companies with user credentials pending approval."
    },
    "s12.contractors.v1.ContractorCompanyFilter": {
      "type": "object",
      "properties": {
        "search": {
          "type": "string",
          "description": "Optional. The search string to filter by. If not provided, all unfiltered results will be returned."
        },
        "company_type_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional. The company type IDs to filter by. If not provided, all company types will be returned."
        },
        "contractor_company_statuses": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/s12.contractors.v1.ContractorCompanyStatus"
          },
          "description": "Optional. The contractor company statuses to filter by. If not provided, all statuses will be returned."
        },
        "needs_attention": {
          "type": "boolean",
          "description": "Deprecated. Will currently override compliance_filters if set.\nWhether to include only companies that need attention due to non-compliance."
        },
        "compliance_filters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/s12.contractors.v1.ComplianceFilterType"
          },
          "description": "Optional. Filter by specific compliance issues (OR logic between selected types).\nIf empty, no compliance filtering is applied.\nCompanies will be returned if they match ANY of the selected compliance filter types."
        },
        "address_filter": {
          "description": "Optional. Filter by address-related criteria (country and/or administrative area).\nFiltering is case-insensitive. Multiple values within the same filter type use OR logic.\nCountry and administrative area filters combine with AND logic.",
          "allOf": [
            {
              "$ref": "#/$defs/s12.contractors.v1.AddressDirectoryFilter"
            }
          ]
        },
        "site_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional. The site IDs to filter by. If provided, only companies linked to at\nleast one of the given (non-archived) sites are returned. If empty, no site\nfiltering is applied. Multiple site IDs use OR logic."
        }
      },
      "description": "ContractorCompanyFilter is used to filter contractor companies."
    },
    "s12.contractors.v1.ContractorCompanySortField": {
      "type": "string",
      "enum": [
        "COMPANY_SORT_FIELD_COMPANY_TYPE_NAME",
        "COMPANY_SORT_FIELD_COMPANY_NAME",
        "COMPANY_SORT_FIELD_COMPANY_STATUS",
        "COMPANY_SORT_FIELD_OUTSTANDING_DOCUMENT_REQUESTS"
      ],
      "description": "ContractorCompanySortField is used to define the sorting criteria of contractor companies.\n\n - COMPANY_SORT_FIELD_COMPANY_TYPE_NAME: Sort by company type name.\n - COMPANY_SORT_FIELD_COMPANY_NAME: Sort by company name.\n - COMPANY_SORT_FIELD_COMPANY_STATUS: Sort by company status.\n - COMPANY_SORT_FIELD_OUTSTANDING_DOCUMENT_REQUESTS: Sort by the number of outstanding document requests."
    },
    "s12.contractors.v1.ContractorCompanyStatus": {
      "type": "string",
      "enum": [
        "CONTRACTOR_COMPANY_STATUS_ACTIVE",
        "CONTRACTOR_COMPANY_STATUS_PENDING",
        "CONTRACTOR_COMPANY_STATUS_DEACTIVATED"
      ],
      "description": "The status of a contractor company.\n\n - CONTRACTOR_COMPANY_STATUS_ACTIVE: The company is active.\n - CONTRACTOR_COMPANY_STATUS_PENDING: The company is pending approval.\n - CONTRACTOR_COMPANY_STATUS_DEACTIVATED: The company is deactivated."
    }
  }
}