In Merchant API, advanced accounts can have a sub-account relationship to another account. Sub-accounts help businesses that manage multiple sellers and large-scale domains, such as retailers that operate in multiple countries. For the types of businesses that are eligible for an advanced account, see Companies that qualify for access to advanced account settings.
You can use the Merchant Accounts API to create new sub-accounts under your advanced account. You must have an existing advanced account to make this call. You can't use the Merchant API to move existing standalone merchant accounts under your account.
To convert your Merchant Center account to an advanced account, you must be an account administrator. You must also make sure that your account doesn't have any pending issues. For information about how to get an advanced account, see Request an advanced account setup.
Third-party providers can use the Merchant Accounts API to develop an interface that lets merchants create and manage their account details.
Create a sub-account
To create a new sub-account under your advanced account, call
accounts.createAndConfigure
:
- Provide the details of the sub-account in the
account
field. - Specify any new authorized users in the
users
field. User access is also inherited from the parent account. Specify
accountAggregation
in theservice
field.Here's an example to create a sub-account under account
account/123
, which is an aggregator for the sub-account:POST https://merchantapi.googleapis.com/accounts/v1beta/accounts:createAndConfigure { "account": { "accountName": "merchantStore", "adultContent": false, "timeZone": { "id": "America/New_York", } "languageCode": "en-US", }, "service": [ { "accountAggregation": {}, "provider": "providers/123" } ] }
The following sample demonstrates how you can use the
CreateAndConfigureAccountRequest
package to
create a new sub-account.
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.Account;
import com.google.shopping.merchant.accounts.v1beta.AccountAggregation;
import com.google.shopping.merchant.accounts.v1beta.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest;
import com.google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest.AddAccountService;
import com.google.type.TimeZone;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to create a sub-account under an MCA account. */
public class CreateSubAccountSample {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
public static void createSubAccount(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
AccountsServiceSettings accountsServiceSettings =
AccountsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates parent/provider to identify the MCA account into which to insert the subaccount.
String parent = getParent(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (AccountsServiceClient accountsServiceClient =
AccountsServiceClient.create(accountsServiceSettings)) {
CreateAndConfigureAccountRequest request =
CreateAndConfigureAccountRequest.newBuilder()
.setAccount(
Account.newBuilder()
.setAccountName("Demo Business")
.setAdultContent(false)
.setTimeZone(TimeZone.newBuilder().setId("America/New_York").build())
.setLanguageCode("en-US")
.build())
.addService(
AddAccountService.newBuilder()
.setProvider(parent)
.setAccountAggregation(AccountAggregation.getDefaultInstance())
.build())
.build();
System.out.println("Sending Create SubAccount request");
Account response = accountsServiceClient.createAndConfigureAccount(request);
System.out.println("Inserted Account Name below");
// Format: `accounts/{account}
System.out.println(response.getName());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
createSubAccount(config);
}
}
Retrieve sub-accounts
To list all sub-accounts for a given multi client account, use the
accounts.listSubaccounts
method.
Here's a sample request:
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}:listSubaccounts
Here's a sample response from a successful call:
{
"accounts": [
{
"name": "accounts/{ACCOUNT_ID}",
"accountId": "{ACCOUNT_ID}",
"accountName": "{ACCOUNT_NAME}",
"timeZone": {
"id": "America/Los_Angeles"
},
"languageCode": "en-US"
},
{
"name": "accounts/{ACCOUNT_ID}",
"accountId": "{ACCOUNT_ID}",
"accountName": "{ACCOUNT_NAME}",
"timeZone": {
"id": "America/Los_Angeles"
},
"languageCode": "en-US"
}
]
}
Delete a sub-account
To delete a sub-account, use the accounts.delete
method. Executing this method requires administrator access.
Here's a sample request:
DELETE https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}
If successful, the response body is an empty JSON object.
Accept the Terms of Service
Sub-accounts inherit the Merchant Center Terms of Service (TOS) that the parent account signed.
Update your business information
You can use the Merchant Accounts API to edit your business information.
- To view your business information, call
accounts.getBusinessInfo
. - To edit your business information, call
accounts.updateBusinessInfo
.