アカウントのデータを管理する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このチュートリアルでは、アカウントのデータを管理する方法について説明します。My Business Account Management API では、次のような処理が可能です。
- すべてのアカウントの一覧を取得する。
- 特定のアカウントを取得する。
- アカウントを更新する。
始める前に
My Business Account Management API を使用するには、組み込み先のアプリケーションを事前に登録し、OAuth 2.0 の認証情報を取得する必要があります。
Business Profile API の使用方法について詳しくは、基本設定をご覧ください。
すべてのアカウントの一覧を取得する
認証されたユーザーに関連付けられているアカウントを確認するには、すべてのアカウントの一覧を取得すると簡単です。accounts.list
APIを使用すると、ユーザーに関連付けられているすべてのアカウントの一覧を取得できます。
認証されたユーザーのすべてのアカウントの一覧を取得するには、次のように記述します。
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts
特定のアカウントを返す
場合によっては、認証されたユーザーについて特定のアカウントに関する情報だけを確認したいことがあります。accounts.get
API を使用すると、特定のアカウントを取得して、アカウントの追加情報を確認できます。
名前を指定して特定のアカウントを取得するには、次のように記述します。
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
アカウントを更新する
アカウント名の変更は、基本的な管理作業の 1 つです。アカウント名を変更するには accounts.update
API を使用します。
名前を指定して特定のアカウントを更新するには、次のように記述します。
$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
{
"account": {
"accountName": "Anne Droyd"
},
"languageCode": "en",
"validateOnly": "true"
}
制限事項
- アカウントで編集可能なフィールドは
accountName
のみです。これ以外のフィールドを渡した場合は、すべて無視されます。
- この方法で更新できるのは、
BUSINESS
タイプのアカウントのみです。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[[["\u003cp\u003eThe My Business Account Management API allows you to manage business accounts, including listing all accounts, retrieving specific account details, and updating account names.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you must register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a list of all accounts associated with an authenticated user or fetch details for a specific account using dedicated API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eUpdating an account is restricted to changing the account name for business type accounts only, with other fields being ignored.\u003c/p\u003e\n"]]],[],null,["# Work with account data\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to work with account data. The My Business Account Management API\nprovides you with the ability to do the following:\n\n- List all accounts.\n- Return a specific account.\n- Update an account.\n\nBefore you begin\n----------------\n\nBefore you use the My Business Account Management API, you need to register your application\nand obtain OAuth 2.0 credentials.\n\nFor details on how to get started with the Business Profile APIs, see\n[Basic setup](/my-business/content/basic-setup).\n\nList all accounts\n-----------------\n\nA great way to validate the accounts associated with an authenticated user is to\nlist all their accounts. Use the [`accounts.list`](/my-business/reference/accountmanagement/rest/v1/accounts/list)\nAPI to list all accounts associated with a user.\n\nTo list all the accounts for an authenticated user, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts\n```\n\nReturn a specific account\n-------------------------\n\nSometimes, you only want to see information about a specific account for an\nauthenticated user. Use the [`accounts.get`](/my-business/reference/accountmanagement/rest/v1/accounts/get)\nAPI to return a specific account and review additional account details.\n\nTo return a specific account by name, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n```\n\nUpdate an account\n-----------------\n\nChanging an account name is a fundamental administrative task. Use the\n[`accounts.update`](/my-business/reference/accountmanagement/rest/v1/accounts/patch) API to alter\nthe account name.\n\nTo update a specific account by name, use the following:\nHTTP \n\n```bash\n$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n\n{\n \"account\": {\n \"accountName\": \"Anne Droyd\"\n },\n \"languageCode\": \"en\",\n \"validateOnly\": \"true\"\n}\n```\n\n### Restrictions\n\n- The only editable field for an account is `accountName`. Any other fields passed are ignored.\n- Only accounts of `BUSINESS` type can be updated in this manner."]]