# 設定 Google Ads 搜尋 SERP 任務

**API:** Data API

**Endpoint:** `POST /v1/beta/dataforseo/serp/google/ads_search/task_post`

**Tags:** DataForSEO

將 Google 上針對某個關鍵字投放的廣告排入佇列，在 `tasks[0].id` 中傳回任務 `id`。採用 DataForSEO 的信封結構：資料位於 `tasks[0].result`，結果狀態位於 `tasks[0].status_code`——被拒絕的請求仍會回傳 HTTP 200。即時版本會立即回應，對單次查詢更簡單；當批次作業會超過一次工具呼叫的時間時，請使用佇列。

### 計費參考

- 計量方式：依回報的回應成本計量。
- 參考請求估算：0.02 美元。
- 參考客戶倍率：1.0。不得對已結算的客戶金額再次套用。

僅供參考的中繼資料，並非帳戶報價、保證價格或消費上限。資源額度並非 Felo 額度。最終費用依 Felo 計費記錄為準。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **no**

### application/json

Schema:

```json
{
  "type": "array",
  "items": {
    "type": [
      "object",
      "null"
    ],
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "advertiser_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "<p><em>廣告主識別碼</em><p><strong>未指定 <code>target</code> 時為必填欄位</strong></p><br><p>此陣列最多可指定 25 個值；<p>此參數的 <code>advertiser_ids</code> 值可在 <a href=\"http://docs.dataforseo.com/v3/serp/google/ads_advertisers/task_get/advanced/\" rel=\"noopener noreferrer\" target=\"_blank\">Google Ads Advertisers</a> 端點中找到；</p>"
          },
          "target": {
            "type": "string",
            "description": "<p><em>網域名稱</em><p><strong>未指定 <code>advertiser_ids</code> 時為必填欄位</strong><p>與廣告主帳戶關聯的網域</p>"
          },
          "location_code": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<p><em>搜尋引擎地點代碼</em><p>選填欄位<p><strong>如果使用此欄位，則無需指定 <code>location_name</code> 或 <code>location_coordinate</code></strong><p>可個別向 <code>https://api.dataforseo.com/v3/serp/google/ads_search/locations</code> 發出請求，取得搜尋引擎可用地點及其 <code>location_code</code> 的清單<p>範例：<p><code class=\"long-string\">2840</code></p><br><p><strong>注意：</strong>如果未指定 <code>location_name</code>、<code>location_code</code> 或 <code>location_coordinate</code>，將在所有可用地點中搜尋廣告</p>"
          },
          "depth": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<p><em>解析深度</em><p>選填欄位<p>SERP 結果數量<p>預設值：<code>40</code><p>最大值：<code>700</code></p><br><strong>帳戶將按每個最多包含 40 條結果的 SERP 計費；</strong><p>將深度設為 40 以上可能會產生額外費用<a href=\"https://dataforseo.com/help-center/how-many-results-scraped\" rel=\"noopener noreferrer\" target=\"_blank\">（如果搜尋引擎傳回超過 40 條結果）</a>；<p>費用可在<a title=\"Pricing\" href=\"https://dataforseo.com/pricing/serp/google-ads-search-serp-api\" target=\"_blank\" rel=\"noopener noreferrer\">定價頁</a>計算。"
          },
          "priority": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<p><em>任務優先順序</em><p>選填欄位<p>可取以下值：<p>1 – 一般執行優先順序（預設設定）<p>2 – 高執行優先順序</p><br>高執行優先順序的任務將額外收費。<p>費用可在<a title=\"Pricing\" href=\"https://dataforseo.com/pricing/serp/google-ads-search-serp-api\" target=\"_blank\" rel=\"noopener noreferrer\">定價頁</a>計算。"
          },
          "pingback_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>任務完成通知 URL</em><p>選填欄位<p>任務完成後，我們會向你指定的 URL 傳送 GET 請求進行通知<p>可將 ‘$id’ 字串用作 <code>$id</code> 變數，將 ‘$tag’ 用作經 URL 編碼的 <code>$tag</code> 變數。傳送請求前我們會設定必要的值。<p>範例：<p><code>http://your-server.com/pingscript?id=$id</code><p><code>http://your-server.com/pingscript?id=$id&amp;tag=$tag</code><p><strong>注意：</strong><code>pingback_url</code> 中的特殊字元會進行 URL 編碼；<p>例如，<code>#</code> 字元會編碼為 <code>%23</code></p><br><p>詳情請參閱我們的<a href=\"https://dataforseo.com/help-center/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">說明中心</a></p>"
          },
          "postback_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>用於傳送任務結果的 URL</em><p>選填欄位<p>任務完成後，我們會將其結果以 <code>gzip</code> 格式壓縮，並向你指定的 <code>postback_url</code> 傳送 POST 請求<p>可將 ‘$id’ 字串用作 <code>$id</code> 變數，將 ‘$tag’ 用作經 URL 編碼的 <code>$tag</code> 變數。傳送請求前我們會設定必要的值。<p>範例：<p><code>http://your-server.com/postbackscript?id=$id</code><p><code>http://your-server.com/postbackscript?id=$id&amp;tag=$tag</code><p><strong>注意：</strong><code>postback_url</code> 中的特殊字元會進行 URL 編碼；<p>例如，<code>#</code> 字元會被編碼為 <code>%23</code></p><br><p>詳情請參閱我們的 <a href=\"https://dataforseo.com/help-center/pingbacks-postbacks-with-dataforseo-api\" target=\"_blank\" rel=\"noopener noreferrer\">說明中心</a></p>"
          },
          "postback_data": {
            "type": "string",
            "description": "<p><em>postback_url 資料類型</em><p><strong>指定 <code>postback_url</code> 時為必填欄位</strong><p>對應於用來設定任務的函式<p>可取的值為：<p><code>advanced</code></p>"
          },
          "location_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>搜尋引擎地點全名</em><p>選填欄位<p><strong>如果使用此欄位，則無需指定 <code>location_code</code> 或 <code>location_coordinate</code></strong><p>可個別向 <code>https://api.dataforseo.com/v3/serp/google/ads_search/locations</code> 發出請求，取得搜尋引擎可用地點及其 <code>location_name</code> 的清單<p>範例：<p><code class=\"long-string\">London,England,United Kingdom</code></p><br><p><strong>注意：</strong>如果未指定 <code>location_name</code>、<code>location_code</code> 或 <code>location_coordinate</code>，將在所有可用地點中搜尋廣告</p>"
          },
          "location_coordinate": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>地點的 GPS 座標</em><p>選填欄位<p><strong>如果使用此欄位，則無需指定 <code>location_name</code> 或 <code>location_code</code></strong><p>範例：<p><code class=\"long-string\">52.6178549,-155.352142</code></p><br><p><strong>注意：</strong>如果未指定 <code>location_name</code>、<code>location_code</code> 或 <code>location_coordinate</code>，將在所有可用地點中搜尋廣告</p>"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>使用者自訂任務識別碼</em><p>選填欄位<p><em>字元數上限為 255</em><p>可使用此參數識別任務，並將其與結果對應<p>指定的 <code>tag</code> 值可在回應的 <code>data</code> 物件中找到</p>"
          },
          "platform": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>廣告平台</em><p>選填欄位<p>可能的值：<code>all</code>、<code>google_play</code>、<code>google_maps</code>、<code>google_search</code>、<code>google_shopping</code>、<code>youtube</code><p>預設值：<code>all</code></p>"
          },
          "format": {
            "type": [
              "string",
              "null"
            ],
            "description": "<p><em>廣告格式</em><p>選填欄位<p>可能的值：<code>all</code>、<code>text</code>、<code>image</code>、<code>video</code></p>"
          },
          "date_from": {
            "type": "string",
            "description": "<p><em>時間範圍的開始日期</em><p>選填欄位<p>指定 <code>date_to</code> 時為必填欄位； </p><br><p>日期格式：<code>\"yyyy-mm-dd\"</code><p>最小值：2018-05-31<p>最大值：今天的日期<p>範例：<p><code>\"2020-01-01\"</code></p>"
          },
          "date_to": {
            "type": "string",
            "description": "<p><em>時間範圍的結束日期</em><p>選填欄位<p>指定 <code>date_from</code> 時為必填欄位； </p><br><p>日期格式：<code>\"yyyy-mm-dd\"</code><p>最小值：2018-05-31<p>最大值：今天的日期<p>範例：<p><code>\"2020-01-01\"</code></p>"
          }
        },
        "example": [
          {
            "location_code": 2840,
            "platform": "google_search",
            "advertiser_ids": [
              "AR13752565271262920705",
              "AR02439908557932462081"
            ]
          }
        ]
      }
    ]
  },
  "example": [
    {
      "location_code": 2840,
      "platform": "google_search",
      "advertiser_ids": [
        "AR13752565271262920705",
        "AR02439908557932462081"
      ]
    }
  ]
}
```

## Responses

### 200 — 操作成功

Headers:
- `X-Request-Id` (string) — 聯絡 Felo 支援時需提供的請求識別碼。

**application/json**

Schema: object | null

```json
{
  "type": [
    "object",
    "null"
  ],
  "oneOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_SerpGoogleAdsSearchTaskPostResponseInfo"
    }
  ]
}
```

### 400 — 無法處理該要求。請檢查請求參數。

### 401 — 需要有效的 Felo API 金鑰。

### 402 — 由於未符合計費要求，要求無法繼續。

### 403 — 該帳戶無權執行此操作。

### 429 — 已達到要求或支出上限。

### 502 — 服務無法完成該要求。

### 503 — API 或計費服務暫時無法使用。

### 504 — 服務在處理要求時逾時。

### default — 錯誤回應；上游透傳回應可能採用供應商格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_BaseResponseInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseInfo`

```json
{
  "properties": {
    "version": {
      "type": [
        "string",
        "null"
      ],
      "description": "API 的目前版本"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "一般狀態碼\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "一般資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "總執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中的任務數",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中傳回錯誤的任務數",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務識別碼\n我們系統中 UUID 格式的唯一任務識別碼"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "任務的狀態碼\n由 DataForSEO 產生，範圍如下：10000-60000\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務的資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "result 陣列中的元素數",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "URL 路徑"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "包含你在 POST 請求中指定的相同參數"
    }
  }
}
```

### Response36Afe1097B20_SerpGoogleAdsSearchTaskPostResponseInfo

`#/components/schemas/Response36Afe1097B20_SerpGoogleAdsSearchTaskPostResponseInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseInfo"
    },
    {
      "type": "object",
      "properties": {
        "tasks": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_SerpGoogleAdsSearchTaskPostTaskInfo"
              }
            ]
          },
          "description": "<em>任務陣列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_SerpGoogleAdsSearchTaskPostTaskInfo

`#/components/schemas/Response36Afe1097B20_SerpGoogleAdsSearchTaskPostTaskInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo"
    },
    {
      "type": "object",
      "properties": {
        "result": {
          "type": [
            "object",
            "null"
          ],
          "description": "<em>結果陣列</em><br>在此情況下，該值將為 <code>null</code>"
        }
      }
    }
  ]
}
```
