AdSense Management API organizes publishers' resources under an account hierarchy. Most operations operate on named resources that follow a path format (for example accounts/{account}, accounts/{account}/adclients/{adclient}, accounts/{account}/adclients/{adclient}/adunits/{adunit}). Understanding that hierarchy and which resource name each operation expects is the key to progressing from discovery to action.
Key entities and how they relate
Accountis the top-level owner. Many collections are scoped to an account (alerts, reports, payments, sites, policy issues, child accounts). Account resource names look likeaccounts/{account}.AdClientis scoped under an account:accounts/{account}/adclients/{adclient}. Ad clients own ad units, custom channels, and URL channels.AdUnitlives under an ad client:accounts/{account}/adclients/{adclient}/adunits/{adunit}. Ad units are the actual ad placements for which you can retrieve ad code (getAdcode) and list linked custom channels.CustomChannellives under an ad client:accounts/{account}/adclients/{adclient}/customchannels/{customchannel}. Custom channels can be linked to ad units; the API exposes listing of those links but not a separate “link” create endpoint in this surface.UrlChannellives under an ad client and is used for URL-level reporting:accounts/{account}/adclients/{adclient}/urlchannels.SavedReportis a named saved report under an account:accounts/{account}/reports/{report}. Saved reports can be retrieved and executed.ReportandCsvReportare generated from an account; both require reporting parameters (metrics required). Generated CSV responses arrive as rawHttpBody.- Other account-scoped resources:
alerts,payments,sites,policyIssues,adBlockingRecoveryTag.
Remember: most path parameters are full resource names (the slash-separated strings above), not plain numeric IDs. Passing just the numeric ID where the API expects the full resource name is the most common source of confusion.
Entry points — what to call first
- To discover what account to operate on, call the account listing endpoint. The API exposes a top-level accounts listing that returns account resource names (use that to pick
accounts/{account}). - Once an
accountresource name is available, list ad clients for that account to getadclientresource names: call the ad clients list underaccounts/{account}. Many ad-client-scoped operations require the ad client resource name asparent. - To enumerate actual inventory, list ad units under an ad client (
adunits.list) and list custom channels under the same ad client (customchannels.list). Use the returned resource names for subsequent calls (for exampleadunits.getAdcodeorcustomchannels.patch). - Saved reports live under an account: call saved reports list to discover
reports/{report}names to run withreports.saved.generate.
Common tasks and the operation sequences to perform them
These are the sequences that map directly to typical user requests.
- Find which accounts and ad clients a publisher has
- Call the accounts list to retrieve
accounts/{account}names. - For a chosen account, call ad clients list with
parent=accounts/{account}to retrieve ad client resource names.
- Inspect inventory for a specific ad client (ad units, custom channels, URL channels)
- With
parent=accounts/{account}/adclients/{adclient}, calladunits.list,customchannels.list, andurlchannels.listto enumerate inventory. Each list may returnnextPageToken; if present, request the next page with the same parameters and that token.
- Create an ad unit under an ad client
- Call the ad unit create operation with
parent=accounts/{account}/adclients/{adclient}and the ad unit body. The response body is the created ad unit resource (includes its full resource name to use in later calls). - To retrieve the rendering code for an ad unit, call the ad unit adcode getter with
name= the ad unit resource name (format:accounts/{account}/adclients/{adclient}/adunits/{adunit}).
- Manage custom channels
- Create a custom channel by calling custom channels create with
parent=accounts/{account}/adclients/{adclient}and the custom channel body. - Update a custom channel by calling the patch operation with
name= the full custom channel resource name and setupdateMaskto the comma-separated fields to change. IfupdateMaskis empty, the patch behaves like a full update. - Delete a custom channel by calling delete with
name= the full custom channel resource name. - To see what ad units are linked to a custom channel, call the custom channel’s
listLinkedAdUnitswithparent=accounts/{account}/adclients/{adclient}/customchannels/{customchannel}. To see what custom channels an ad unit belongs to, call the ad unit’slistLinkedCustomChannelswithparent=accounts/{account}/adclients/{adclient}/adunits/{adunit}.- Note: the API surface provided here exposes listing of links. There is no separate link-creation operation in this set—links are managed either when creating/updating channels in the hosting product or via a different endpoint not shown here.
- Run an ad performance/earnings report
- For ad-hoc reports, call
reports.generatewithaccount= the account resource name and requiredmetrics. Provide date range via the split query fieldsstartDate.year/month/dayandendDate.year/month/dayor use the nameddateRangeshortcuts. Providedimensionsandfiltersas needed. - For CSV output, call
reports.generateCsvwith the same parameters; the response body is a rawHttpBody(CSV). The CSV endpoint supports a larger maximum number of rows. - To run a saved report by name, call
reports.saved.generatewithname=accounts/{account}/reports/{report}. You can also retrieve a saved report definition withreports.getSavedbefore executing it.
- Check account-level state
- Alerts: call
alerts.listwithparent= account resource name. You can supplylanguageCodeto localize messages. - Payments: call
payments.listwithparent= account resource name to retrieve payments history. - Sites: call
sites.listwithparent= account resource name to enumerate registered sites. - Policy issues: call
policyIssues.listwithparent= account resource name to see flagged items; callpolicyIssues.getwith anameof the formaccounts/{account}/policyIssues/{policy_issue}to inspect a single issue. - Ad Blocking Recovery Tag: call the ad blocking recovery tag getter with
name=accounts/{account}to retrieve the tag.
Reporting specifics and practical constraints
metricsis required forreports.generate/reports.generateCsv. The call will fail (or be meaningless) without specifying at least one metric.- Date parameters are provided as separate
startDate.year,startDate.month,startDate.day(and the same forendDate). The API also supports nameddateRangeenumerations for common spans such asLAST_7_DAYS. filtersare strings following the reporting filtering syntax and are combined as logical AND: every provided filter must match for a row to be included.- The default and maximum row limits differ between endpoints: the standard report generation has a default limit (and a documented max for that endpoint), while the CSV report endpoint supports a larger maximum (notably up to 1,000,000 rows). Truncation for the structured
reports.generateresponse is detectable by comparing the number of returned rows tototal_matched_rowsin the response; the CSV endpoint returns raw data and will simply be truncated if over the CSV limit. - Use
orderBywith a+or-prefix to control column sort direction. If no prefix is provided, ascending is assumed. reportingTimeZonecan be set when generating reports; if omitted the account time zone applies.
Non-obvious parameter/name patterns and pitfalls
- Many operations use
parent, some useaccountorname. The string expected is almost always the full resource name (for exampleaccounts/12345oraccounts/12345/adclients/pub-67890), not a bare numeric ID. Verify the returned resource'snamefield and pass that exact value when a later call asks for the resource name. customchannels.patchrequires the resource name in thenamepath—and the operation's path comment may read "Output only" for thenamefield in resource definitions. Treat it as the identifier: supply the full resource name and useupdateMaskto perform partial updates; ifupdateMaskis omitted the patch acts as a full replacement.- List endpoints accept
pageSizeup to 10000 and returnnextPageTokenwhen results span pages. IfpageTokenis required to fetch further pages, the list response contains it. - Several list endpoints will silently coerce
pageSizevalues above the maximum to the maximum. Assume a 10000 ceiling for ad clients, ad units, custom channels, url channels, policy issues, and similar lists. getAdcoderequires the exact ad unit resource name. Passing onlyadunitoradclientwithout the full path will not work.- The CSV endpoints return
HttpBody; treat the body as raw CSV content rather than structured JSON.
Typical responses that indicate success or next steps
- Creation calls return the created resource in the response body with its
namefield populated. Use thatnamefor subsequent operations that require that resource. - Ad unit ad code retrieval returns an ad code resource containing the markup/snippet to place on pages. That is the canonical source for the ad HTML/JS for an ad unit.
- Report generation returns either a structured
ReportResult(for JSON) withheaders,rows, andtotal_matched_rows, or a rawHttpBody(for CSV). Iftotal_matched_rowsis larger than the number of rows returned, the report is truncated; adjustlimitor reduce the query scope.
Short checklist before calling any operation
- Confirm which full resource name string the operation requires (
accounts/{account}vsaccounts/{account}/adclients/{adclient}vsaccounts/{account}/adclients/{adclient}/adunits/{adunit}) and pass that exact string. - For reports, ensure
metricsis provided and dates are set via the split date fields ordateRangeshortcuts. - For patch/update, set
updateMaskto limit changes; otherwise expect a full update behavior. - For list endpoints expect
nextPageTokenwhen results exceed a single page and use the returned token with the same query parameters to request the next page.
These patterns cover the common, high-value tasks publishers ask for: enumerating accounts and inventory, creating ad units, fetching ad code, managing custom channels, and producing reports. When an operation expects a resource name, prefer the name values returned by prior list or create calls rather than constructing paths manually from numeric IDs.