{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-campaign-manager/json-schema/google-campaign-manager-targeting-template-schema.json",
  "title": "TargetingTemplate",
  "description": "Contains properties of a targeting template. A targeting template encapsulates targeting information which can be reused across multiple ads.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-campaign-manager-targeting-templates-api-openapi.yml#/components/schemas/TargetingTemplate",
  "type": "object",
  "properties": {
    "subaccountId": {
      "format": "int64",
      "type": "string",
      "description": "Subaccount ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert."
    },
    "dayPartTargeting": {
      "$ref": "#/$defs/DayPartTargeting",
      "description": "Time and day targeting criteria."
    },
    "technologyTargeting": {
      "$ref": "#/$defs/TechnologyTargeting",
      "description": "Technology platform targeting criteria."
    },
    "name": {
      "type": "string",
      "description": "Name of this targeting template. This field is required. It must be less than 256 characters long and unique within an advertiser."
    },
    "id": {
      "format": "int64",
      "description": "ID of this targeting template. This is a read-only, auto-generated field.",
      "type": "string"
    },
    "contextualKeywordTargeting": {
      "$ref": "#/$defs/ContextualKeywordTargeting",
      "description": "Optional. Contextual keyword targeting criteria."
    },
    "geoTargeting": {
      "$ref": "#/$defs/GeoTargeting",
      "description": "Geographical targeting criteria."
    },
    "listTargetingExpression": {
      "$ref": "#/$defs/ListTargetingExpression",
      "description": "Remarketing list targeting criteria."
    },
    "languageTargeting": {
      "$ref": "#/$defs/LanguageTargeting",
      "description": "Language targeting criteria."
    },
    "keyValueTargetingExpression": {
      "$ref": "#/$defs/KeyValueTargetingExpression",
      "description": "Key-value targeting criteria."
    },
    "accountId": {
      "type": "string",
      "description": "Account ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert.",
      "format": "int64"
    },
    "advertiserIdDimensionValue": {
      "$ref": "#/$defs/DimensionValue",
      "description": "Dimension value for the ID of the advertiser. This is a read-only, auto-generated field."
    },
    "kind": {
      "type": "string",
      "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#targetingTemplate\"."
    },
    "advertiserId": {
      "type": "string",
      "description": "Advertiser ID of this targeting template. This is a required field on insert and is read-only after insert.",
      "format": "int64"
    }
  },
  "$defs": {
    "Browser": {
      "properties": {
        "minorVersion": {
          "type": "string",
          "description": "Minor version number (number after first dot on left) of this browser. For example, for Chrome 5.0.375.86 beta, this field should be set to 0. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is."
        },
        "dartId": {
          "format": "int64",
          "description": "DART ID of this browser. This is the ID used when generating reports.",
          "type": "string"
        },
        "majorVersion": {
          "description": "Major version number (leftmost number) of this browser. For example, for Chrome 5.0.376.86 beta, this field should be set to 5. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is.",
          "type": "string"
        },
        "kind": {
          "type": "string",
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#browser\"."
        },
        "browserVersionId": {
          "description": "ID referring to this grouping of browser and version numbers. This is the ID used for targeting.",
          "type": "string",
          "format": "int64"
        },
        "name": {
          "type": "string",
          "description": "Name of this browser."
        }
      },
      "description": "Contains information about a browser that can be targeted by ads.",
      "type": "object"
    },
    "City": {
      "description": "Contains information about a city that can be targeted by ads.",
      "type": "object",
      "properties": {
        "regionCode": {
          "type": "string",
          "description": "Region code of the region to which this city belongs."
        },
        "countryDartId": {
          "format": "int64",
          "description": "DART ID of the country to which this city belongs.",
          "type": "string"
        },
        "metroDmaId": {
          "type": "string",
          "format": "int64",
          "description": "ID of the metro region (DMA) to which this city belongs."
        },
        "regionDartId": {
          "description": "DART ID of the region to which this city belongs.",
          "format": "int64",
          "type": "string"
        },
        "metroCode": {
          "type": "string",
          "description": "Metro region code of the metro region (DMA) to which this city belongs."
        },
        "dartId": {
          "type": "string",
          "format": "int64",
          "description": "DART ID of this city. This is the ID used for targeting and generating reports."
        },
        "countryCode": {
          "type": "string",
          "description": "Country code of the country to which this city belongs."
        },
        "name": {
          "type": "string",
          "description": "Name of this city."
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#city\".",
          "type": "string"
        }
      }
    },
    "ConnectionType": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "ID of this connection type.",
          "format": "int64"
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#connectionType\".",
          "type": "string"
        },
        "name": {
          "description": "Name of this connection type.",
          "type": "string"
        }
      },
      "description": "Contains information about an internet connection type that can be targeted by ads. Clients can use the connection type to target mobile vs. broadband users."
    },
    "ContextualKeyword": {
      "properties": {
        "keyword": {
          "description": "The keyword that can be targeted by ads.",
          "type": "string"
        }
      },
      "description": "Contains information about a Contextual Keyword that can be targeted by ads.",
      "type": "object"
    },
    "ContextualKeywordTargeting": {
      "description": "Contextual Keyword Targeting.",
      "type": "object",
      "properties": {
        "keywords": {
          "type": "array",
          "description": "Contextual keywords that this ad targets",
          "items": {
            "$ref": "#/$defs/ContextualKeyword"
          }
        }
      }
    },
    "Country": {
      "description": "Contains information about a country that can be targeted by ads.",
      "properties": {
        "name": {
          "description": "Name of this country.",
          "type": "string"
        },
        "countryCode": {
          "type": "string",
          "description": "Country code."
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#country\".",
          "type": "string"
        },
        "tvDataProviders": {
          "description": "Output only. The TV data providers supported in this country.",
          "items": {
            "enum": [
              "INVALID_TV_DATA_PROVIDER",
              "INTAGE_JP",
              "IBOPE_AR",
              "IBOPE_BR",
              "IBOPE_CL",
              "IBOPE_CO",
              "TNS_VN",
              "COMSCORE_NATIONAL_US",
              "COMSCORE_CA",
              "SAMBA_AU"
            ],
            "type": "string"
          },
          "readOnly": true,
          "type": "array"
        },
        "dartId": {
          "description": "DART ID of this country. This is the ID used for targeting and generating reports.",
          "type": "string",
          "format": "int64"
        },
        "sslEnabled": {
          "type": "boolean",
          "description": "Whether ad serving supports secure servers in this country."
        }
      },
      "type": "object"
    },
    "DayPartTargeting": {
      "description": "Day Part Targeting.",
      "properties": {
        "daysOfWeek": {
          "items": {
            "type": "string",
            "enum": [
              "SUNDAY",
              "MONDAY",
              "TUESDAY",
              "WEDNESDAY",
              "THURSDAY",
              "FRIDAY",
              "SATURDAY"
            ]
          },
          "type": "array",
          "description": "Days of the week when the ad will serve. Acceptable values are: - \"SUNDAY\" - \"MONDAY\" - \"TUESDAY\" - \"WEDNESDAY\" - \"THURSDAY\" - \"FRIDAY\" - \"SATURDAY\" "
        },
        "userLocalTime": {
          "description": "Whether or not to use the user's local time. If false, the America/New York time zone applies.",
          "type": "boolean"
        },
        "hoursOfDay": {
          "items": {
            "format": "int32",
            "type": "integer"
          },
          "type": "array",
          "description": "Hours of the day when the ad will serve, where 0 is midnight to 1 AM and 23 is 11 PM to midnight. Can be specified with days of week, in which case the ad would serve during these hours on the specified days. For example if Monday, Wednesday, Friday are the days of week specified and 9-10am, 3-5pm (hours 9, 15, and 16) is specified, the ad would serve Monday, Wednesdays, and Fridays at 9-10am and 3-5pm. Acceptable values are 0 to 23, inclusive."
        }
      },
      "type": "object"
    },
    "DimensionValue": {
      "type": "object",
      "description": "Represents a DimensionValue resource.",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID associated with the value if available."
        },
        "value": {
          "type": "string",
          "description": "The value of the dimension."
        },
        "dimensionName": {
          "description": "The name of the dimension.",
          "type": "string"
        },
        "matchType": {
          "type": "string",
          "enum": [
            "EXACT",
            "BEGINS_WITH",
            "CONTAINS",
            "WILDCARD_EXPRESSION"
          ],
          "description": "Determines how the 'value' field is matched when filtering. If not specified, defaults to EXACT. If set to WILDCARD_EXPRESSION, '*' is allowed as a placeholder for variable length character sequences, and it can be escaped with a backslash. Note, only paid search dimensions ('dfa:paidSearch*') allow a matchType other than EXACT."
        },
        "etag": {
          "type": "string",
          "description": "The eTag of this response for caching purposes."
        },
        "kind": {
          "description": "The kind of resource this is, in this case dfareporting#dimensionValue.",
          "type": "string"
        }
      }
    },
    "GeoTargeting": {
      "type": "object",
      "properties": {
        "cities": {
          "description": "Cities to be targeted. For each city only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a city, do not target or exclude the country of the city, and do not target the metro or region of the city.",
          "items": {
            "$ref": "#/$defs/City"
          },
          "type": "array"
        },
        "postalCodes": {
          "items": {
            "$ref": "#/$defs/PostalCode"
          },
          "description": "Postal codes to be targeted. For each postal code only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a postal code, do not target or exclude the country of the postal code.",
          "type": "array"
        },
        "countries": {
          "description": "Countries to be targeted or excluded from targeting, depending on the setting of the excludeCountries field. For each country only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting or excluding a country, do not target regions, cities, metros, or postal codes in the same country.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Country"
          }
        },
        "excludeCountries": {
          "type": "boolean",
          "description": "Whether or not to exclude the countries in the countries field from targeting. If false, the countries field refers to countries which will be targeted by the ad."
        },
        "metros": {
          "items": {
            "$ref": "#/$defs/Metro"
          },
          "description": "Metros to be targeted. For each metro only dmaId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a metro, do not target or exclude the country of the metro.",
          "type": "array"
        },
        "regions": {
          "items": {
            "$ref": "#/$defs/Region"
          },
          "description": "Regions to be targeted. For each region only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a region, do not target or exclude the country of the region.",
          "type": "array"
        }
      },
      "description": "Geographical Targeting."
    },
    "KeyValueTargetingExpression": {
      "description": "Key Value Targeting Expression.",
      "type": "object",
      "properties": {
        "expression": {
          "description": "Keyword expression being targeted by the ad.",
          "type": "string"
        }
      }
    },
    "Language": {
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of this language."
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#language\".",
          "type": "string"
        },
        "id": {
          "description": "Language ID of this language. This is the ID used for targeting and generating reports.",
          "type": "string",
          "format": "int64"
        },
        "languageCode": {
          "type": "string",
          "description": "Format of language code is an ISO 639 two-letter language code optionally followed by an underscore followed by an ISO 3166 code. Examples are \"en\" for English or \"zh_CN\" for Simplified Chinese."
        }
      },
      "description": "Contains information about a language that can be targeted by ads.",
      "type": "object"
    },
    "LanguageTargeting": {
      "description": "Language Targeting.",
      "type": "object",
      "properties": {
        "languages": {
          "description": "Languages that this ad targets. For each language only languageId is required. The other fields are populated automatically when the ad is inserted or updated.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Language"
          }
        }
      }
    },
    "ListTargetingExpression": {
      "type": "object",
      "properties": {
        "expression": {
          "type": "string",
          "description": "Expression describing which lists are being targeted by the ad."
        }
      },
      "description": "Remarketing List Targeting Expression."
    },
    "Metro": {
      "properties": {
        "metroCode": {
          "description": "Metro code of this metro region. This is equivalent to dma_id.",
          "type": "string"
        },
        "dmaId": {
          "description": "DMA ID of this metro region. This is the ID used for targeting and generating reports, and is equivalent to metro_code.",
          "format": "int64",
          "type": "string"
        },
        "countryCode": {
          "description": "Country code of the country to which this metro region belongs.",
          "type": "string"
        },
        "dartId": {
          "format": "int64",
          "type": "string",
          "description": "DART ID of this metro region."
        },
        "name": {
          "description": "Name of this metro region.",
          "type": "string"
        },
        "countryDartId": {
          "description": "DART ID of the country to which this metro region belongs.",
          "format": "int64",
          "type": "string"
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#metro\".",
          "type": "string"
        }
      },
      "type": "object",
      "description": "Contains information about a metro region that can be targeted by ads."
    },
    "MobileCarrier": {
      "description": "Contains information about a mobile carrier that can be targeted by ads.",
      "properties": {
        "kind": {
          "type": "string",
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#mobileCarrier\"."
        },
        "countryCode": {
          "description": "Country code of the country to which this mobile carrier belongs.",
          "type": "string"
        },
        "name": {
          "description": "Name of this mobile carrier.",
          "type": "string"
        },
        "countryDartId": {
          "type": "string",
          "format": "int64",
          "description": "DART ID of the country to which this mobile carrier belongs."
        },
        "id": {
          "format": "int64",
          "type": "string",
          "description": "ID of this mobile carrier."
        }
      },
      "type": "object"
    },
    "OperatingSystem": {
      "properties": {
        "name": {
          "description": "Name of this operating system.",
          "type": "string"
        },
        "desktop": {
          "type": "boolean",
          "description": "Whether this operating system is for desktop."
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#operatingSystem\".",
          "type": "string"
        },
        "mobile": {
          "type": "boolean",
          "description": "Whether this operating system is for mobile."
        },
        "dartId": {
          "format": "int64",
          "description": "DART ID of this operating system. This is the ID used for targeting.",
          "type": "string"
        }
      },
      "type": "object",
      "description": "Contains information about an operating system that can be targeted by ads."
    },
    "OperatingSystemVersion": {
      "description": "Contains information about a particular version of an operating system that can be targeted by ads.",
      "properties": {
        "kind": {
          "type": "string",
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#operatingSystemVersion\"."
        },
        "majorVersion": {
          "type": "string",
          "description": "Major version (leftmost number) of this operating system version."
        },
        "name": {
          "type": "string",
          "description": "Name of this operating system version."
        },
        "operatingSystem": {
          "$ref": "#/$defs/OperatingSystem",
          "description": "Operating system of this operating system version."
        },
        "minorVersion": {
          "description": "Minor version (number after the first dot) of this operating system version.",
          "type": "string"
        },
        "id": {
          "type": "string",
          "format": "int64",
          "description": "ID of this operating system version."
        }
      },
      "type": "object"
    },
    "PlatformType": {
      "type": "object",
      "properties": {
        "id": {
          "description": "ID of this platform type.",
          "type": "string",
          "format": "int64"
        },
        "kind": {
          "type": "string",
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#platformType\"."
        },
        "name": {
          "description": "Name of this platform type.",
          "type": "string"
        }
      },
      "description": "Contains information about a platform type that can be targeted by ads."
    },
    "PostalCode": {
      "description": "Contains information about a postal code that can be targeted by ads.",
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#postalCode\"."
        },
        "code": {
          "type": "string",
          "description": "Postal code. This is equivalent to the id field."
        },
        "countryCode": {
          "description": "Country code of the country to which this postal code belongs.",
          "type": "string"
        },
        "countryDartId": {
          "description": "DART ID of the country to which this postal code belongs.",
          "format": "int64",
          "type": "string"
        },
        "id": {
          "type": "string",
          "description": "ID of this postal code."
        }
      }
    },
    "Region": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of this region."
        },
        "kind": {
          "description": "Identifies what kind of resource this is. Value: the fixed string \"dfareporting#region\".",
          "type": "string"
        },
        "dartId": {
          "description": "DART ID of this region.",
          "type": "string",
          "format": "int64"
        },
        "countryCode": {
          "type": "string",
          "description": "Country code of the country to which this region belongs."
        },
        "regionCode": {
          "description": "Region code.",
          "type": "string"
        },
        "countryDartId": {
          "type": "string",
          "description": "DART ID of the country to which this region belongs.",
          "format": "int64"
        }
      },
      "description": "Contains information about a region that can be targeted by ads."
    },
    "TechnologyTargeting": {
      "type": "object",
      "description": "Technology Targeting.",
      "properties": {
        "operatingSystemVersions": {
          "type": "array",
          "description": "Operating system versions that this ad targets. To target all versions, use operatingSystems. For each operating system version, only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system version, do not set targeting for the corresponding operating system in operatingSystems.",
          "items": {
            "$ref": "#/$defs/OperatingSystemVersion"
          }
        },
        "browsers": {
          "items": {
            "$ref": "#/$defs/Browser"
          },
          "type": "array",
          "description": "Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated."
        },
        "platformTypes": {
          "description": "Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/PlatformType"
          }
        },
        "operatingSystems": {
          "description": "Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system.",
          "items": {
            "$ref": "#/$defs/OperatingSystem"
          },
          "type": "array"
        },
        "connectionTypes": {
          "description": "Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ConnectionType"
          }
        },
        "mobileCarriers": {
          "description": "Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes.",
          "items": {
            "$ref": "#/$defs/MobileCarrier"
          },
          "type": "array"
        }
      }
    }
  }
}