API: Creating accounts

Shadow accounts are created with the purpose of being mapped to the users on your platform and this will depend on the URL structure of your platform. Please review that documentation to better understand how shadow accounts work, and what to include in the account creation API call.

HTTP request

POST https://adsenseplatform.googleapis.com/v1alpha/{name=platforms/*}/accounts

The URL uses gRPC Transcoding syntax.

Path parameters

Parameter Description
name string

Required. You can find your platform publisher ID by visiting AdSense: Account > Settings > Account information.

Format:
platforms/{platform_publisher_id}/accounts

Query parameters

Parameter Description
site_uri string

Required. Depending on the URL structure of your platform, this is either the subdomain, subfolder or profile page URL belonging to your user. Examples:
  • site.example.com
  • example.com/site
  • example.com/profiles/user_id
  • Or a combination of the above, review the account structures page for more details


Important: the API will return errors if the structure of the site_uri field doesn't match the domain structure that you communicate with your account manager, as part of the initial tasks.
request_id string

Required. The value of this field will depend on the structure of your platform. Review the account structures page for more information and examples.
region_code string

Required. Lowercase case country code following the Territory Containment (UN M.49) standard. Examples:
  • us
  • gb
  • br
time_zone object

Required. This is the timezone used for reporting. The value of this parameter should look like this:
{'id': 'America/Los_Angeles'}

Request body

The request body must be empty.

Python example

import requests as rqst

# This is the ID of your AdSense account (refer to "Path parameters" section)
platform = "pub-9952238966586479"

# Refer to the "Query parameters" section for information on the following
payload = {
    'site_uri': 'platform.com/profiles/user_id',
    'region_code': 'us',
    'time_zone': {'id': 'America/Los_Angeles'}
}
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'OAuth ' + get_service_account_token()
}

r = rqst.post(
    "https://adsenseplatform.googleapis.com/v1alpha/platforms/" + platform + "/accounts",
    json=payload,
    headers=headers
)

Successful response

{
  "name": "platforms/pub-9952238966586479/accounts/pub-9549090072938056",
  "displayName": "pub-9549090072938056",
  "state": "UNCHECKED",
  "timeZone": {
    "id": "America/Los_Angeles"
  },
  "createTime": "2021-06-22T17:40:23.976Z"
}