> ## 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.

# 広告

> 広告プラットフォームを引数として受け取る 1 組の操作で、Ayrshare GraphQL API を通じてブーストされた広告を管理します。

広告の操作は広告プラットフォームを引数として受け取るため、同じ操作が Ayrshare がサポートするすべての広告プラットフォームで動作します。現在サポートされているのは `FACEBOOK` と `INSTAGRAM` です。

各操作は対応する [REST の広告エンドポイント](/docs/apis/ads/overview)を呼び出し、そのレスポンスを変更せずに返します。認証と制限は REST と同じです。呼び出しが失敗すると GraphQL エラーが返されます。`extensions.status` には REST のステータスが、REST のエラーに Ayrshare のエラーコードがある場合は `extensions.code` にそのコードが含まれます。[エラー](/docs/apis/graphql/errors)を参照してください。広告の操作には広告アドオンが必要です。アドオンがない場合、すべての呼び出しは `extensions.status` が `403`、`extensions.code` が `399` のエラーを返します。

<h2 id="operations">
  操作
</h2>

| 操作 | 種類 | REST エンドポイント |
| - | - | - |
| `adAccounts` | Query | `GET /ads/{platform}/accounts` |
| `adTargetingSearch` | Query | `GET /ads/{platform}/interests`、`/regions` または `/cities` |
| `ads` | Query | `GET /ads/{platform}/ads` |
| `adHistory` | Query | `GET /ads/{platform}/history` |
| `updateAd` | Mutation | `PUT /ads/{platform}/ads` |

すべての操作は、User Profile を操作するためのオプションの `profileKey` も受け取ります。いずれも REST のレスポンスを JSON として返すため、フィールドの選択は受け付けません。

<h2 id="list-ad-accounts">
  広告アカウントを一覧表示する
</h2>

まずここから始めます。操作で `accountId` が求められる場合は、このレスポンスに含まれる `accountId` の値を使用してください。

```graphql theme={"system"}
query {
  adAccounts(platform: FACEBOOK, limit: 10)
}
```

<h2 id="search-targeting-options">
  ターゲティングオプションを検索する
</h2>

`kind` で検索の種類を選択します。オーディエンスのターゲティングには `INTERESTS`、地域には `REGIONS` または `CITIES` を使用します。各 kind は、それぞれに対応する引数のみを受け付けます。たとえば、`countryCode` と `regionId` は `CITIES` でのみ機能し、`INTERESTS` には `search` が必要です。

```graphql theme={"system"}
query {
  adTargetingSearch(platform: INSTAGRAM, kind: INTERESTS, search: "running")
}
```

```graphql theme={"system"}
query {
  adTargetingSearch(platform: FACEBOOK, kind: CITIES, search: "Austin", countryCode: "US")
}
```

<h2 id="list-ads">
  広告を一覧表示する
</h2>

`campaignId`、`accountId`、`adId`、`postId`、`socialPostId` のうち少なくとも 1 つを渡してください。`socialPostId` はネットワーク独自の投稿 ID で、Ayrshare 経由で公開されていない投稿に使用します。

```graphql theme={"system"}
query {
  ads(platform: FACEBOOK, accountId: "act_1234567890")
}
```

<h2 id="see-what-an-ad-has-cost">
  広告の費用を確認する
</h2>

```graphql theme={"system"}
query {
  adHistory(platform: FACEBOOK, startDate: "2026-09-01", endDate: "2026-09-30")
}
```

<h2 id="pause-or-resume-an-ad">
  広告を一時停止または再開する
</h2>

`updateAd` は実際の広告費に影響します。`PAUSED` は支出を停止し、`ACTIVE` は再開し、`DELETED` または `ARCHIVED` は広告を終了します。同じステータスは広告の広告セットとキャンペーンにも設定されるため、その広告セットまたはキャンペーン内の他の広告も同様に変更されます。

```graphql theme={"system"}
mutation {
  updateAd(platform: FACEBOOK, adId: "120210000000000000", status: PAUSED)
}
```

<Note>
  これらの操作による投稿のブーストは近日提供予定です。それまでは、`boostFacebookPost` または `instagramBoostPost`、あるいは [Facebook](/docs/apis/ads/facebook/boost-post) または [Instagram](/docs/apis/ads/instagram/boost-post) の REST ブーストエンドポイントを使用してください。
</Note>

`facebookAdAccounts` や `instagramAds` などのプラットフォームごとの操作も、変更なく引き続き動作します。


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