> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# v2 Account Activity API 移行ガイド

このガイドでは、従来の Enterprise Account Activity API から V2 Account Activity API への移行方法を説明します。核となる機能は変わりませんが、X API v2 との一貫性を保つために、エンドポイントの構造と認証方式が更新されています。

<div id="summary-of-changes">
  ### 変更点の概要
</div>

* **API 形式**: エンドポイントのベースパスが /1.1/account\_activity/ から /2/account\_activity/ に変更されます。
* **Webhook 管理**: Webhook の作成、一覧取得、検証（CRC）、削除は [V2 Webhooks API](https://github.com/m-rosinsky/XWebhookTest/blob/main/app.py) によって処理されます。
* **認証**: V2 エンドポイントでは次のいずれかが必要です:
  * ユーザー単位のアクション（例: ユーザーを購読する）には **OAuthUser**（3-legged OAuth）。
  * アプリケーションレベルのアクション（例: 購読の一覧取得／削除）には **OAuth2 App Only**（ベアラートークン）。
  * V1.1 では要件がさまざまで、多くの場合 OAuth 1.0a が使用されていました。
* **エンドポイント対応表**:

| V1.1 Endpoint                                                                   | V2 Equivalent / Action                                                        | Notes                                                                                    |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| POST /1.1/account\_activity/webhooks.json?url=\<URL>                            | POST /2/webhooks                                                              | [Docs](https://docs.x.com/x-api/webhooks/introduction)。OAuth2AppOnly が必要です。              |
| GET /1.1/account\_activity/webhooks.json                                        | GET /2/webhooks                                                               | [Docs](https://docs.x.com/x-api/webhooks/introduction)。OAuth2AppOnly が必要です。              |
| PUT /1.1/account\_activity/webhooks/:webhook\_id.json                           | PUT /2/webhooks/:webhook\_id                                                  | CRC をトリガーします。[Docs](https://docs.x.com/x-api/webhooks/introduction)。OAuth2AppOnly が必要です。 |
| DELETE /1.1/account\_activity/webhooks/:webhook\_id.json                        | DELETE /2/webhooks/:webhook\_id                                               | [Docs](https://docs.x.com/x-api/webhooks/introduction)。OAuth2AppOnly が必要です。              |
| POST /1.1/account\_activity/webhooks/:webhook\_id/subscriptions/all.json        | POST /2/account\_activity/webhooks/:webhook\_id/subscriptions/all             | OAuthUser が必要です。                                                                         |
| GET /1.1/account\_activity/subscriptions/count.json                             | GET /2/account\_activity/subscriptions/count                                  | OAuth2AppOnly が必要です。                                                                     |
| GET /1.1/account\_activity/webhooks/:webhook\_id/subscriptions/all.json         | GET /2/account\_activity/webhooks/:webhook\_id/subscriptions/all              | OAuthUser が必要です。                                                                         |
| GET /1.1/account\_activity/webhooks/:webhook\_id/subscriptions/all/list.json    | GET /2/account\_activity/webhooks/:webhook\_id/subscriptions/all/list         | OAuth2AppOnly が必要です。                                                                     |
| DELETE /1.1/account\_activity/webhooks/:webhook\_id/subscriptions/:user\_id/all | DELETE /2/account\_activity/webhooks/:webhook\_id/subscriptions/:user\_id/all | OAuth2AppOnly が必要です。                                                                     |
| DELETE /1.1/account\_activity/webhooks/:webhook\_id/subscriptions/all           | Deprecated / No Direct Equivalent                                             | 個別に削除するか、DELETE /2/webhooks/:webhook\_id によって webhook を削除してください。                         |

* **レスポンス形式**: AAAPI ドキュメントで、成功およびエラーレスポンスの構造を確認してください。

移行時には、新しいベースパスを使用するようにコードを更新し、認証フローを調整し、[V2 Webhooks API](https://docs.x.com/x-api/webhooks/introduction) を使用して webhook を管理してください。

<div id="how-to-migrate">
  ### 移行方法
</div>

* **パッケージを決定する**:
  * Account Activity API へのアクセス用に Enterprise か Self-serve のパッケージを選択し、次の点を検討してください:
    * 必要な webhook の数。
    * 現在および将来見込みのサブスクリプション数／認可ユーザー数。
    * X クライアントアプリケーションの数。
    * 希望するサポートレベル（フォーラムによるサポートか、マネージド Enterprise の 1:1 サポートか）。
    * 料金の詳細（Enterprise については営業担当にお問い合わせください）。
* **認証を OAuth 2.0 に更新する**:
  * 使用している X App に「Read, Write, and Access Direct Messages」の権限が付与されていることを確認します。
  * V2 エンドポイントでは OAuth 2.0 を使用するように更新します。スコープが変更された場合は、ユーザーを再認可してください。
  * 開発者コンソールを使用して次を管理します:
    * OAuth 2.0 Access Token。
    * Client ID と Client Secret。
* **Webhook を確認または再設定する**:
  * 既存の webhook URL を使用するか、新しいものを設定します（例: [https://your\\\_domain.com/webhook/twitter）。](https://your\\_domain.com/webhook/twitter）。)
  * [V2 Webhooks API ドキュメント](https://docs.x.com/x-api/webhooks/introduction)に従って、webhook を登録および管理します。
* **サンプル App:**
  * [Simple webhook server](https://github.com/m-rosinsky/XWebhookTest/blob/main/app.py)
    * CRC チェックに応答し、POST イベントを受信して処理する方法を示す、単一の Python スクリプトです。
  * [Account Activity API sample dashboard](https://github.com/xdevplatform/account-activity-dashboard-enterprise/tree/master)
    * [bun.sh](http://bun.sh) で記述された Web アプリで、webhook とサブスクリプションを管理し、アプリ内でライブイベントを直接受信できます。
