Edit a Google campaign's device, location, excluded location, or language targeting
curl --request PUT \
--url https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"targeting": {
"devices": [
"MOBILE"
],
"excludedLocations": [
"example"
]
}
}
'import requests
url = "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting"
payload = { "targeting": {
"devices": ["MOBILE"],
"excludedLocations": ["example"]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({targeting: {devices: ['MOBILE'], excludedLocations: ['example']}})
};
fetch('https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'targeting' => [
'devices' => [
'MOBILE'
],
'excludedLocations' => [
'example'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting"
payload := strings.NewReader("{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"adGroupId": "<string>",
"campaignId": "<string>",
"devices": [
{
"bidModifier": 123,
"device": "MOBILE",
"included": true
}
],
"excludedLocations": [
{
"canonicalName": "<string>",
"countryCode": "<string>",
"geoTargetId": "<string>",
"name": "<string>",
"negative": true,
"type": "<string>"
}
],
"languages": [
{
"code": "<string>",
"id": "<string>",
"name": "<string>"
}
],
"locationTargetingType": "presence",
"locations": [
{
"canonicalName": "<string>",
"countryCode": "<string>",
"geoTargetId": "<string>",
"name": "<string>",
"negative": true,
"type": "<string>"
}
],
"updated": [
"devices"
]
}{
"error": {
"code": "<string>",
"details": {},
"message": "<string>",
"param": "<string>",
"retryHint": "<string>",
"retryable": true,
"type": "<string>"
}
}Campaigns
Edit a Google campaign's device, location, excluded location, or language targeting
Ad Campaigns. Can spend money or change spend: needs the ads:spend scope and X-Aisa-Confirm: spend; without the header the request is refused with confirmation_required and nothing is sent. Changes who a campaign can reach, which changes its delivery and spend. Changes a Google campaign’s device, location, excluded location or language targeting after it was created. Google only; every other platform returns 501. Google Ads compliance row M.10: geo and language targeting set at creation must stay editable afterwards. Send at least one of devices, locations, excludedLocations, languages, locationTargetingType.
PUT
https://api.aisa.one
/
apis
/
v1
/
ads
/
campaigns
/
{campaignId}
/
targeting
Edit a Google campaign's device, location, excluded location, or language targeting
curl --request PUT \
--url https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"targeting": {
"devices": [
"MOBILE"
],
"excludedLocations": [
"example"
]
}
}
'import requests
url = "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting"
payload = { "targeting": {
"devices": ["MOBILE"],
"excludedLocations": ["example"]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({targeting: {devices: ['MOBILE'], excludedLocations: ['example']}})
};
fetch('https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'targeting' => [
'devices' => [
'MOBILE'
],
'excludedLocations' => [
'example'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting"
payload := strings.NewReader("{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"targeting\": {\n \"devices\": [\n \"MOBILE\"\n ],\n \"excludedLocations\": [\n \"example\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"adGroupId": "<string>",
"campaignId": "<string>",
"devices": [
{
"bidModifier": 123,
"device": "MOBILE",
"included": true
}
],
"excludedLocations": [
{
"canonicalName": "<string>",
"countryCode": "<string>",
"geoTargetId": "<string>",
"name": "<string>",
"negative": true,
"type": "<string>"
}
],
"languages": [
{
"code": "<string>",
"id": "<string>",
"name": "<string>"
}
],
"locationTargetingType": "presence",
"locations": [
{
"canonicalName": "<string>",
"countryCode": "<string>",
"geoTargetId": "<string>",
"name": "<string>",
"negative": true,
"type": "<string>"
}
],
"updated": [
"devices"
]
}{
"error": {
"code": "<string>",
"details": {},
"message": "<string>",
"param": "<string>",
"retryHint": "<string>",
"retryable": true,
"type": "<string>"
}
}Request contract
- Method and path: PUT /apis/v1/ads/campaigns/{campaignId}/targeting
- Availability: enabled
- Request URL template:
https://api.aisa.one/apis/v1/ads/campaigns/{campaignId}/targeting - campaignId: path; required
- connectionId: query; required
- X-Aisa-Confirm: header; optional
{
"operationId": "put_aisa_ads_apis_v1_ads_campaigns_campaignid_targeting",
"method": "PUT",
"path": "/apis/v1/ads/campaigns/{campaignId}/targeting",
"servers": [
{
"url": "https://api.aisa.one"
}
],
"parameters": [
{
"description": "Google platform campaign ID",
"in": "path",
"name": "campaignId",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "The ads connection (adc_...) the request runs on: one of yours, from GET /apis/v1/ads/connections. On a request with a JSON body it may be sent as a top-level body member instead.",
"in": "query",
"name": "connectionId",
"required": true,
"schema": {
"pattern": "^adc_[0-9A-Za-z]+$",
"type": "string"
}
},
{
"description": "Required with the value \"spend\" when the request can spend money or change spend. Without it the request is refused with 409 confirmation_required, which describes what would happen; nothing is sent to the ad platform.",
"in": "header",
"name": "X-Aisa-Confirm",
"required": false,
"schema": {
"enum": [
"spend"
],
"type": "string"
}
}
],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"content": {
"application/json": {
"example": {
"connectionId": "adc_7f3k2m9q",
"targeting": {
"devices": [
"MOBILE"
],
"excludedLocations": [
"example"
]
}
},
"schema": {
"additionalProperties": true,
"properties": {
"connectionId": {
"description": "The ads connection (adc_...), when not sent as the connectionId query parameter.",
"pattern": "^adc_[0-9A-Za-z]+$",
"type": "string"
},
"platform": {
"description": "Filled from the connection when omitted.",
"enum": [
"google"
],
"type": "string"
},
"targeting": {
"properties": {
"devices": {
"description": "Devices to include. Devices not listed become excluded (negative) criteria, same contract as the existing devices-only edit.",
"items": {
"oneOf": [
{
"enum": [
"MOBILE",
"DESKTOP",
"TABLET",
"CONNECTED_TV"
],
"type": "string"
},
{
"properties": {
"bidModifier": {
"description": "Bid modifier for this device; devices without one use the campaign's base bid.",
"type": "number"
},
"device": {
"enum": [
"MOBILE",
"DESKTOP",
"TABLET",
"CONNECTED_TV"
],
"type": "string"
}
},
"required": [
"bidModifier",
"device"
],
"type": "object"
}
]
},
"type": "array"
},
"excludedLocations": {
"description": "Locations the campaign never serves in, as a bare country-code array or the nested countries/regions/cities/zips/metros shape. Replaces the excluded set; [] removes every exclusion.",
"oneOf": [
{
"items": {
"description": "ISO 3166-1 alpha-2 country code.",
"type": "string"
},
"type": "array"
},
{
"additionalProperties": false,
"properties": {
"cities": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"countries": {
"items": {
"type": "string"
},
"type": "array"
},
"metros": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"regions": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"zips": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
}
},
"type": "object"
}
]
},
"languages": {
"description": "Google's language codes (ISO 639-1, plus variants such as `zh_CN`), e.g. [\"en\", \"de\"].",
"items": {
"type": "string"
},
"type": "array"
},
"locationTargetingType": {
"description": "Google only. Who a campaign's location targeting reaches (Google's `campaign.geo_target_type_setting.positive_geo_target_type`). `presence`: people in, or regularly in, the targeted locations.",
"enum": [
"presence",
"presence_or_interest"
],
"type": "string"
},
"locations": {
"description": "Bare country-code array, or the nested creation-time shape (countries/regions/cities/zips/metros).",
"oneOf": [
{
"items": {
"description": "ISO 3166-1 alpha-2 country code.",
"type": "string"
},
"type": "array"
},
{
"properties": {
"cities": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"countries": {
"items": {
"type": "string"
},
"type": "array"
},
"metros": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"regions": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
},
"zips": {
"items": {
"oneOf": [
{
"description": "The geo target constant id alone.",
"type": "string"
},
{
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
]
},
"type": "array"
}
},
"type": "object"
}
]
}
},
"type": "object"
}
},
"required": [
"targeting"
],
"type": "object"
}
}
},
"required": true
},
"x-aisa-status": "enabled",
"components": {
"securitySchemes": {
"bearerAuth": {
"scheme": "bearer",
"type": "http"
}
}
}
}
Cost and request rules
No additional charge for this operation. Ad spend is billed separately by the ad platform to your connected ad account.Authorizations
Headers
Query Parameters
Body
application/json
Response
Targeting updated