{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/cosuno/main/json-schema/cosuno-subcontractor-response-schema.json",
  "title": "SubcontractorResponse",
  "x-generated": "2026-10-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cosuno-openapi.json#/components/schemas/SubcontractorResponse",
  "properties": {
    "name": {
      "type": "string",
      "description": "Company name of the subcontractor.",
      "maxLength": 255
    },
    "website": {
      "type": [
        "string",
        "null"
      ],
      "description": "Website URL of the subcontractor.",
      "maxLength": 200
    },
    "street": {
      "type": [
        "string",
        "null"
      ],
      "description": "Street address of the subcontractor's operating location.",
      "maxLength": 200
    },
    "postalCode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Postal/ZIP code of the subcontractor's operating location.",
      "maxLength": 100
    },
    "city": {
      "type": [
        "string",
        "null"
      ],
      "description": "City of the subcontractor's operating location.",
      "maxLength": 100
    },
    "registrationPostalCode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Postal/ZIP code of the subcontractor's registered (legal) address.",
      "maxLength": 100
    },
    "registrationCity": {
      "type": [
        "string",
        "null"
      ],
      "description": "City of the subcontractor's registered (legal) address.",
      "maxLength": 100
    },
    "companySize": {
      "allOf": [
        {
          "$ref": "#/$defs/COMPANY_SIZE"
        }
      ],
      "nullable": true,
      "description": "Size category of the subcontractor's company."
    },
    "countryCode": {
      "allOf": [
        {
          "$ref": "#/$defs/COUNTRY_CODE"
        }
      ],
      "nullable": true,
      "description": "ISO 3166-1 alpha-2 country code of the subcontractor's operating location."
    },
    "workCategoryNames": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "description": "Names of the work categories (trades) the subcontractor offers."
    },
    "moreInfo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Free-form internal notes about the subcontractor."
    },
    "isBanned": {
      "type": "boolean",
      "description": "Whether the subcontractor is blocked from being invited to tenders in your company."
    },
    "isFavorite": {
      "type": "boolean",
      "description": "Whether the subcontractor is marked as a favorite in your company."
    },
    "nationalId": {
      "type": [
        "string",
        "null"
      ],
      "description": "National business registration number (e.g. Handelsregisternummer in Germany).",
      "maxLength": 255
    },
    "foundingYear": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "Year the subcontractor's company was founded."
    },
    "ownerName": {
      "type": [
        "string",
        "null"
      ],
      "description": "Name of the subcontractor's owner or managing director.",
      "maxLength": 255
    },
    "revenueYear": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "Year that `yearlyRevenue` refers to."
    },
    "taxId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Tax identification number (e.g. Steuernummer or USt-IdNr. in Germany).",
      "maxLength": 255
    },
    "yearlyRevenue": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "Annual revenue of the subcontractor for `revenueYear`."
    },
    "orderAreaType": {
      "$ref": "#/$defs/ORDER_AREA_TYPE",
      "description": "How the subcontractor's service area is expressed: by radius around its location, by states, by country, or not specified."
    },
    "orderRadius": {
      "allOf": [
        {
          "$ref": "#/$defs/ORDER_RADIUS"
        }
      ],
      "nullable": true,
      "description": "Radius (in km) around the subcontractor's operating location in which it accepts work. Applies when `orderAreaType` is set to the radius option."
    },
    "orderAreaStateCodes": {
      "items": {
        "$ref": "#/$defs/STATE_CODE"
      },
      "type": [
        "array",
        "null"
      ],
      "description": "State codes the subcontractor accepts work in. Applies when `orderAreaType` is set to the states option."
    },
    "orderAreaCountryCode": {
      "allOf": [
        {
          "$ref": "#/$defs/COUNTRY_CODE"
        }
      ],
      "nullable": true,
      "description": "ISO 3166-1 alpha-2 country code the subcontractor accepts work in. Applies when `orderAreaType` is set to the country option."
    },
    "id": {
      "type": "string",
      "description": "ID of the subcontractor."
    },
    "aboutUs": {
      "type": "string",
      "description": "Public self-description provided by the subcontractor."
    },
    "contacts": {
      "items": {
        "$ref": "#/$defs/ContactResponse"
      },
      "type": "array",
      "description": "Contacts associated with the subcontractor."
    },
    "externalSource": {
      "type": "string",
      "description": "Identifier of the external system this subcontractor was imported from, if any."
    },
    "externalId": {
      "type": "string",
      "description": "Identifier of this subcontractor within the external system, if any."
    },
    "customFields": {
      "items": {
        "$ref": "#/$defs/MappedCustomField"
      },
      "type": "array",
      "description": "Values for the custom fields defined on subcontractors in your company."
    }
  },
  "required": [
    "name",
    "id",
    "contacts",
    "workCategoryNames"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "COMPANY_SIZE": {
      "type": "string",
      "enum": [
        "size_1_4",
        "size_5_9",
        "size_10_19",
        "size_20_49",
        "size_50_99",
        "size_100_199",
        "size_200_499",
        "size_500plus"
      ],
      "nullable": false
    },
    "CONTACT_TITLE": {
      "type": "string",
      "enum": [
        "mr",
        "ms"
      ],
      "nullable": false
    },
    "COUNTRY_CODE": {
      "type": "string",
      "enum": [
        "AW",
        "AF",
        "AO",
        "AI",
        "AX",
        "AL",
        "AD",
        "AE",
        "AR",
        "AM",
        "AS",
        "AQ",
        "TF",
        "AG",
        "AU",
        "AT",
        "AZ",
        "BI",
        "BE",
        "BJ",
        "BF",
        "BD",
        "BG",
        "BH",
        "BS",
        "BA",
        "BL",
        "SH",
        "BY",
        "BZ",
        "BM",
        "BO",
        "BQ",
        "BR",
        "BB",
        "BN",
        "BT",
        "BV",
        "BW",
        "CF",
        "CA",
        "CC",
        "CH",
        "CL",
        "CN",
        "CI",
        "CM",
        "CD",
        "CG",
        "CK",
        "CO",
        "KM",
        "CV",
        "CR",
        "CU",
        "CW",
        "CX",
        "KY",
        "CY",
        "CZ",
        "DE",
        "DJ",
        "DM",
        "DK",
        "DO",
        "DZ",
        "EC",
        "EG",
        "ER",
        "EH",
        "ES",
        "EE",
        "ET",
        "FI",
        "FJ",
        "FK",
        "FR",
        "FO",
        "FM",
        "GA",
        "GB",
        "GE",
        "GG",
        "GH",
        "GI",
        "GN",
        "GP",
        "GM",
        "GW",
        "GQ",
        "GR",
        "GD",
        "GL",
        "GT",
        "GF",
        "GU",
        "GY",
        "HK",
        "HM",
        "HN",
        "HR",
        "HT",
        "HU",
        "ID",
        "IM",
        "IN",
        "IO",
        "IE",
        "IR",
        "IQ",
        "IS",
        "IL",
        "IT",
        "JM",
        "JE",
        "JO",
        "JP",
        "KZ",
        "KE",
        "KG",
        "KH",
        "KI",
        "KN",
        "KR",
        "XK",
        "KW",
        "LA",
        "LB",
        "LR",
        "LY",
        "LC",
        "LI",
        "LK",
        "LS",
        "LT",
        "LU",
        "LV",
        "MO",
        "MF",
        "MA",
        "MC",
        "MD",
        "MG",
        "MV",
        "MX",
        "MH",
        "MK",
        "ML",
        "MT",
        "MM",
        "ME",
        "MN",
        "MP",
        "MZ",
        "MR",
        "MS",
        "MQ",
        "MU",
        "MW",
        "MY",
        "YT",
        "NA",
        "NC",
        "NE",
        "NF",
        "NG",
        "NI",
        "NU",
        "NL",
        "NO",
        "NP",
        "NR",
        "NZ",
        "OM",
        "PK",
        "PA",
        "PN",
        "PE",
        "PH",
        "PW",
        "PG",
        "PL",
        "PR",
        "KP",
        "PT",
        "PY",
        "PS",
        "PF",
        "QA",
        "RE",
        "RO",
        "RU",
        "RW",
        "SA",
        "SD",
        "SN",
        "SG",
        "GS",
        "SJ",
        "SB",
        "SL",
        "SV",
        "SM",
        "SO",
        "PM",
        "RS",
        "SS",
        "ST",
        "SR",
        "SK",
        "SI",
        "SE",
        "SZ",
        "SX",
        "SC",
        "SY",
        "TC",
        "TD",
        "TG",
        "TH",
        "TJ",
        "TK",
        "TM",
        "TL",
        "TO",
        "TT",
        "TN",
        "TR",
        "TV",
        "TW",
        "TZ",
        "UG",
        "UA",
        "UM",
        "UY",
        "US",
        "UZ",
        "VA",
        "VC",
        "VE",
        "VG",
        "VI",
        "VN",
        "VU",
        "WF",
        "WS",
        "YE",
        "ZA",
        "ZM",
        "ZW"
      ],
      "nullable": false
    },
    "ContactResponse": {
      "properties": {
        "isPerson": {
          "type": "boolean",
          "description": "Whether this contact represents an individual person (`true`) or a generic company contact channel such as a shared inbox or department (`false`)."
        },
        "email": {
          "type": [
            "string",
            "null"
          ],
          "description": "Email address of the contact.",
          "format": "email",
          "maxLength": 200
        },
        "title": {
          "allOf": [
            {
              "$ref": "#/$defs/CONTACT_TITLE"
            }
          ],
          "nullable": true,
          "description": "Form of address (e.g. Mr., Mrs., Dr.).",
          "maxLength": 200
        },
        "firstName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Given name of the contact.",
          "maxLength": 100
        },
        "lastName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Family name of the contact.",
          "maxLength": 100
        },
        "jobTitle": {
          "type": [
            "string",
            "null"
          ],
          "description": "Role or title of the contact within their organisation.",
          "maxLength": 100
        },
        "phone": {
          "type": [
            "string",
            "null"
          ],
          "description": "Business phone number of the contact.",
          "maxLength": 200
        },
        "mobilePhone": {
          "type": [
            "string",
            "null"
          ],
          "description": "Mobile phone number of the contact.",
          "maxLength": 200
        },
        "fax": {
          "type": [
            "string",
            "null"
          ],
          "description": "Fax number of the contact.",
          "maxLength": 200
        },
        "id": {
          "type": "string",
          "description": "Unique identifier of the contact."
        }
      },
      "required": [
        "isPerson",
        "id"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "MappedCustomField": {
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number",
              "format": "double"
            },
            {
              "type": "boolean"
            },
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "label"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "ORDER_AREA_TYPE": {
      "type": "string",
      "enum": [
        "radius",
        "state",
        "country",
        "worldwide"
      ],
      "nullable": false
    },
    "ORDER_RADIUS": {
      "type": "string",
      "enum": [
        "km_20",
        "km_50",
        "km_100",
        "km_200",
        "km_350",
        "km_500",
        "km_750",
        "km_1000",
        "km_2000",
        "km_3000",
        "unlimited"
      ],
      "nullable": false
    },
    "STATE_CODE": {
      "type": "string",
      "enum": [
        "DE_BW",
        "DE_BY",
        "DE_BE",
        "DE_BB",
        "DE_HB",
        "DE_HH",
        "DE_HE",
        "DE_MV",
        "DE_NI",
        "DE_NW",
        "DE_RP",
        "DE_SL",
        "DE_SN",
        "DE_ST",
        "DE_SH",
        "DE_TH"
      ],
      "nullable": false
    }
  }
}