> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Campaign

> Google Ads キャンペーンのステータスと1日の予算、および各広告またはアセットに対する Google の審査結果を取得します。

Ayrshare で作成した Google Ads キャンペーンを取得します。名前、ステータス、1日の予算、各広告に対する Google の審査結果が含まれます。

## ヘッダーパラメータ

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## パスパラメータ

**id** `string` *required*

キャンペーンの作成時に返された `campaignId`。

## レスポンス

| フィールド | 内容 |
| - | - |
| `campaignId` | キャンペーンの ID |
| `name` | キャンペーン名 |
| `campaignStatus` | `active` または `paused` |
| `platformStatus` | Google 独自のステータス: `ENABLED`、`PAUSED`、または Google Ads で削除されたキャンペーンの場合は `REMOVED`。削除されたキャンペーンは、Ayrshare で最後に設定した `campaignStatus` を保持します |
| `budget` | 1日あたりの予算: `amount`、`currency`(広告アカウントの通貨)、`type`(`daily`) |
| `ads` | 各広告(検索)またはアセット(Performance Max)に対する Google の審査結果。[広告の審査](#ad-review)を参照してください |

## 広告の審査

Google は新しい広告をすべて広告ポリシーに照らして審査します。通常は1営業日以内に完了します。`ads` の各行には次の内容が含まれます:

| フィールド | 内容 |
| - | - |
| `adId` | 作成時に返された広告の ID |
| `approvalStatus` | Google の判定: `APPROVED`、`APPROVED_LIMITED`(一部の国では表示されないなど、制限付きで表示)、`AREA_OF_INTEREST_ONLY`、または `DISAPPROVED`。Google が判定するまでは、`UNKNOWN` や `UNSPECIFIED` などの別の値が入ります |
| `reviewStatus` | 審査の状況。例: `REVIEW_IN_PROGRESS` または `REVIEWED` |
| `policyTopics` | 制限または不承認の原因となったポリシー: `[{ "topic": "ALCOHOL", "type": "PROHIBITED" }]` |

不承認の広告は配信されません。Google Ads で広告を変更するか、ポリシーに準拠したテキストで新しいキャンペーンを作成してください。その時点で Google の審査結果を読み取れなかった場合、または数秒以上かかった場合、`ads` は省略されます。後でもう一度キャンペーンを読み取ってください。

また、Ayrshare は毎晩すべての審査結果を確認し、Google の判定が変わった場合は `type: "reviewChanged"` の `ads` Webhook を送信します。[Ads アクション](https://www.ayrshare.com/docs/apis/webhooks/actions.md#ads-action)を参照してください。

## アセットの審査

Google は Performance Max キャンペーンの各アセットを個別に審査します。`ads` にはアセットごとに1行が含まれます。各行には[広告の審査](#ad-review)と同じフィールドに加えて、次のフィールドが含まれます:

| フィールド | 内容 |
| - | - |
| `adId` | このキャンペーンでのアセットのキー: `asset:<assetGroupId>~<assetId>~<fieldType>`。ブランドアセットの場合は `asset:<campaignId>~<assetId>~<fieldType>` |
| `assetId` | Google のアセット ID |
| `fieldType` | 使用されている場所。例: `HEADLINE`、`MARKETING_IMAGE`、`SQUARE_MARKETING_IMAGE`、`BUSINESS_NAME`、`LOGO` |
| `primaryStatus` | 配信可能かどうか。例: `ELIGIBLE` または `NOT_ELIGIBLE` |

ビジネス名、ロゴ、横長ロゴはブランドアセットで、アセットグループではなくキャンペーンにリンクされます。これらにもアセットグループの行の後に行があり、キャンペーン ID をキーとする `asset:<campaignId>~<assetId>~<fieldType>` の形式です。`fieldType` は `BUSINESS_NAME`、`LOGO`、`LANDSCAPE_LOGO` のいずれかです。

## エラー

| コード | 発生条件 |
| - | - |
| `400` | キャンペーンがお客様のものではない、存在しない、または Google Ads アカウントにもう存在しない。連携した Google ユーザーが広告アカウントにアクセスできない場合や、Google Ads へのアクセスが取り消された場合も同様です。 |
| `370` | Google がリクエストを完了できなかった。もう一度お試しください。 |

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${API_KEY}`
  }
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {
    "Authorization": "Bearer API_KEY",
}

r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)

print(r.json())
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY"
    ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
    req.Header.Add("Authorization", "Bearer API_KEY")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetCampaign {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
            .header("Authorization", "Bearer API_KEY")
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

```json 200: Search Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567890",
  "name": "Fall sale",
  "campaignStatus": "active",
  "platformStatus": "ENABLED",
  "budget": { "amount": 25, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "71234567890",
      "approvalStatus": "APPROVED_LIMITED",
      "reviewStatus": "REVIEWED",
      "policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
    }
  ]
}
```

```json 200: Performance Max Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567891",
  "name": "Fall sale PMax",
  "campaignStatus": "paused",
  "platformStatus": "PAUSED",
  "budget": { "amount": 40, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "asset:6512345678~31234567890~HEADLINE",
      "assetId": "31234567890",
      "fieldType": "HEADLINE",
      "primaryStatus": "ELIGIBLE",
      "approvalStatus": "APPROVED",
      "reviewStatus": "REVIEWED",
      "policyTopics": []
    }
  ]
}
```

```json 400: Not Found theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 400,
  "message": "Campaign not found or you are not authorized to access it."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.