Skip to content
Engine has no release yet: these pages describe unreleased main.

AdSense

AdSense lets agents read and change your websites’ AdSense monetization through engine tools: accounts, sites, ad clients, ad units, custom and URL channels, alerts, policy issues, payments, ad code, saved and custom reports, and for AdSense for Platforms partners their sub-accounts, sites, events, platforms and revenue groups. Every method of the AdSense Management API (v2) and the AdSense Platform API (v1 and v1alpha) is reachable; see Every method, and its class.

  • No token reaches an agent’s box. Google refuses service accounts at AdSense, so a person who manages your AdSense account signs in with Google once, as your own OAuth client. Crewlet keeps that sign-in sealed, renews it, and makes every agent’s call through it (ADR-0170, ADR-0178).
  • Crewlet holds each agent to its level and accounts. One sign-in serves every agent, so nothing at Google tells two agents apart: an agent’s level and its publisher accounts are Crewlet’s to enforce, and a call outside them is refused before Google is asked.
  • What visitors see, and what cannot be undone, is asked first, one change at a time, of an administrator at a fresh sign-in, never a delegate (ADR-0171). Nothing in AdSense spends money: AdSense pays you.

Nothing here receives events from AdSense.

An agent is on at one level across every publisher account it is granted.

An agent atCan
read (the default)Accounts, child accounts, sites, ad clients, ad units, custom and URL channels, alerts, policy issues, payments, ad code and the ad blocking recovery tag, custom, saved and CSV reports, and the Platform API’s reads
operateEverything read can, plus changes made at once and recorded: new display ad units and custom channels, renaming them, archiving or reactivating a unit, turning a channel’s data collection on or off, and a platform group’s description. It also asks an administrator to approve each change visitors see: a live ad unit’s size or type, and asking Google to review a platform site
administerEverything operate can, plus asking an administrator to approve each change that cannot be undone or sets up accounts: deleting a custom channel, creating or closing a platform’s sub-account, adding or removing its sites, recording a sign-up or log-in event, and moving a site to another revenue group

Raising an agent to operate or administer asks for a fresh sign-in (step-up). An agent holds only its level’s tools, and each tool that takes a method’s ID says what lies above it. A method above the agent’s level, named on a tool it holds, is refused before AdSense is called, naming the method’s class, the tool and level that make it, whether an administrator approves each call, and that an administrator raises the level on the Agents tab, asked in words (request_access asks for no level). A method Crewlet does not offer is refused as one no level reaches.

AdSense reports no role through its API, and both of its roles reach every method; Crewlet turns a refusal into the scope, the enabling or the access to ask for.

RoleWhat it reaches through the API
AdministratorEvery method. The administrator tasks (users, terms, payment settings, closing the account) have no API method.
Standard userEvery method, payments among them.
AdMob Administrator, on a linked accountAdministrator on the linked AdSense account.
AdMob Manager, on a linked accountStandard user on the linked AdSense account.
AdMob custom roleNo AdSense access.

Google answers five Management API writes (creating and changing ad units, and creating, changing and deleting custom channels) and every Platform API method only for Google Cloud projects it enables, usually AdSense for Platforms partners’, which the account manager asks for. The Platform API also answers only a platform’s parent account, and Google turns it on for the project. Crewlet offers them all the same, marked in the table below, and its answer to Google’s 403 says so. The Platform API is called as the company’s sign-in, so the person who signs in manages the platform’s AdSense account.

  1. Set the company’s Google sign-in client once, under Google sign-in on the Google page (how): a Web application client whose one authorized redirect URI is <api.public.external_url>/webhooks/mcp-oauth, exactly as the page shows it, with no JavaScript origins, and an Internal audience or an External one published or listing whoever signs in as a test user. Turn on the AdSense Management API in that client’s Google Cloud project. The engine needs a public address a browser reaches, since Google sends the person back to it.
  2. Paste the client’s ID and secret on the AdSense page. The secret is sealed and shown back as __redacted__. AdMob may sign in as the same client and name the same secret.
  3. Sign in with Google there, as an Administrator or Standard user of the AdSense account. While every agent reads, the sign-in asks for adsense.readonly; once an agent is raised to operate, sign in again to add adsense, which every change needs.
  4. Turn agents on from the Agents tab, each with its publisher accounts: the picker lists the publisher accounts the sign-in reaches, and takes a typed publisher ID (pub- and 16 digits) for one it does not.

Not offered: every agent’s calls go as the company’s consent grant. AdSense refuses service accounts, so an identity per agent would be a Google Account per agent, which Google Workspace’s acceptable use policy forbids for accounts assigned to a function rather than a person. On the Agents tab the company’s identity is the normal state, In sync, with nothing to set up (ADR-0179); the access log names the agent for each call.

ToolClassWhat it does
adsense_accounts_listreadThe agent’s publisher accounts with each one’s name, state, time zone and sign-up tasks left, and any the sign-in cannot reach
adsense_ad_clients_listreadAn account’s ad clients: product and state
adsense_ad_units_listreadAn ad client’s ad units: name, state, size and type
adsense_custom_channels_listreadAn ad client’s custom channels
adsense_sites_listreadAn account’s sites: domain, state and auto ads
adsense_alerts_listreadAn account’s alerts with their severity
adsense_policy_issues_listreadPolicy issues with Google’s action and the date it escalates
adsense_payments_listreadUnpaid earnings and past payments
adsense_ad_codereadAn ad client’s Auto ads code, or one ad unit’s code
adsense_reportreadA report over your dimensions, metrics, filters and sorting
adsense_saved_reportreadThe saved reports, or one of them run over your dates
adsense_ad_unit_upsertoperateCreates a display ad unit, or renames, archives or reactivates one
adsense_custom_channel_upsertoperateCreates a custom channel, or renames one or turns its data collection on or off
adsense_readreadAny method that only reads, by its ID
adsense_operateoperateAny change made at once, by its method’s ID
adsense_publishpublicA live ad unit’s size or type, or a platform site’s review: asked first
adsense_adminadminDeleting a custom channel, a platform’s sub-accounts, their sites and events, and moving a site to another revenue group: asked first

A change is classed per call against its target, read first: an ad unit’s name and state are operate (an archived unit still serves; archiving only hides it in AdSense), and its size or type is public when it differs from the live unit’s, whether the update mask names contentAdsSettings whole or one of its fields. A change names its fields in updateMask, each a path Google documents for the method, in snake_case or camelCase: an ad unit’s display_name, state and content_ads_settings (or .size, .type), a custom channel’s display_name and active, a platform group’s description, and a platform child site’s platform_group. A change without one, any other path, a body field spelled as its proto name (content_ads_settings), a query parameter the method does not take (update_mask) or given twice (only a report’s dimensions, metrics, filters and orderBy repeat), a body naming another resource, and a site moved to another platform’s group are refused before Google is asked, since Google could read each of them where the engine’s class would not. A call on the wrong tool for what it changes is refused with the tool that may make it. A held change binds to what it acts on as a person saw it, and sends nothing once that moved: the resource it changes, the sub-account a platform site or event is made in, and for a site moved to another revenue group, both groups’ revenue shares, which the person is asked as the share before and after.

What a call may reach:

  • An account outside the agent’s list is refused before Google is asked. On the Platform API’s platforms/{platformsId} methods, the account is the platform’s own publisher ID, and the sub-account under it is the platform’s.
  • Every publisher ID a call names, in its path or body (an ad client, a resource name, a platform group), is its account’s or the sub-account its path names.
  • The account listing is cut to the agent’s accounts.

What an agent reads: every value Google answers with is fenced as somebody else’s words: account, ad unit, channel and saved report names are typed by your account’s users, site domains and policy texts name pages, alert messages may carry HTML, and ad code is HTML and JavaScript to place, never to run. A platform event’s email and billing address are a third party’s personal data: the question an administrator is asked and the access log keep their digest alone.

Reports: a report’s days are cut in the account’s time zone, or in America/Los_Angeles, Google’s, the one other zone AdSense reports in, and reach back at most three years. Its dimensions, metrics, filters (DIMENSION==value, !=, =@ contains, !@ lacks; values joined by a comma match any) and sorting are held to the API’s lists before Google is asked. Money is a decimal string of its column’s currency, never summed across currencies. An answer carries at most 2,000 rows and says it is cut when Google had more (the engine asks for one row past the limit), with Google’s total; earnings are marked estimated, since Google restates recent days; and Google’s warnings are passed through. A CSV report (generateCsv) is answered as its type and text, and one larger than a call reads (8 MiB) is refused, saying to narrow it.

integrations:
adsense:
enabled: true
oauth: # optional: a client for AdSense alone, in place of google_cloud.sign_in_client
client_id: "123456789012-abc.apps.googleusercontent.com"
client_secret: ${GOOGLE_OAUTH_CLIENT_SECRET} # sealed; AdMob may name the same variable
accounts: ["pub-1234567890123456"] # optional: the accounts agents may be given; absent is every one the sign-in reaches
approvers: [founder] # optional: who a public or admin act is routed to first; only an administrator answers
roles:
- handle: finance
integrations:
adsense: {enabled: true, level: read, accounts: ["pub-1234567890123456"]}

The block needs no Google Cloud connection: it signs in as the company’s Google sign-in client, or its own oauth. The refresh token is never in the document. adsense_accounts_list reads each of the agent’s accounts by its ID at the call, so an account the sign-in no longer reaches is named rather than left out, and a state is the one Google answers now.

Each row is one method the engine offers, with its call, its class and the scope it needs. The table is held to the engine’s catalog by a test, both ways. The Platform API’s eleven stable methods are called on v1, its eight others on v1alpha.

MethodCallClassScope and notes
adsense.accounts.listGET /v2/accountsreadadsense.readonly
adsense.accounts.getGET /v2/accounts/{accountsId}readadsense.readonly
adsense.accounts.listChildAccountsGET /v2/accounts/{accountsId}:listChildAccountsreadadsense.readonly
adsense.accounts.getAdBlockingRecoveryTagGET /v2/accounts/{accountsId}/adBlockingRecoveryTagreadadsense.readonly
adsense.accounts.adclients.listGET /v2/accounts/{accountsId}/adclientsreadadsense.readonly
adsense.accounts.adclients.getGET /v2/accounts/{accountsId}/adclients/{adclientsId}readadsense.readonly
adsense.accounts.adclients.getAdcodeGET /v2/accounts/{accountsId}/adclients/{adclientsId}/adcodereadadsense.readonly
adsense.accounts.adclients.adunits.listGET /v2/accounts/{accountsId}/adclients/{adclientsId}/adunitsreadadsense.readonly
adsense.accounts.adclients.adunits.getGET /v2/accounts/{accountsId}/adclients/{adclientsId}/adunits/{adunitsId}readadsense.readonly
adsense.accounts.adclients.adunits.getAdcodeGET /v2/accounts/{accountsId}/adclients/{adclientsId}/adunits/{adunitsId}/adcodereadadsense.readonly
adsense.accounts.adclients.adunits.listLinkedCustomChannelsGET /v2/accounts/{accountsId}/adclients/{adclientsId}/adunits/{adunitsId}:listLinkedCustomChannelsreadadsense.readonly
adsense.accounts.adclients.adunits.createPOST /v2/accounts/{accountsId}/adclients/{adclientsId}/adunitsoperateadsense; enabled projects only
adsense.accounts.adclients.adunits.patchPATCH /v2/accounts/{accountsId}/adclients/{adclientsId}/adunits/{adunitsId}operate, public by fieldadsense; enabled projects only
adsense.accounts.adclients.customchannels.listGET /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannelsreadadsense.readonly
adsense.accounts.adclients.customchannels.getGET /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannels/{customchannelsId}readadsense.readonly
adsense.accounts.adclients.customchannels.listLinkedAdUnitsGET /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannels/{customchannelsId}:listLinkedAdUnitsreadadsense.readonly
adsense.accounts.adclients.customchannels.createPOST /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannelsoperateadsense; enabled projects only
adsense.accounts.adclients.customchannels.patchPATCH /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannels/{customchannelsId}operateadsense; enabled projects only
adsense.accounts.adclients.customchannels.deleteDELETE /v2/accounts/{accountsId}/adclients/{adclientsId}/customchannels/{customchannelsId}adminadsense; enabled projects only; cannot be undone
adsense.accounts.adclients.urlchannels.listGET /v2/accounts/{accountsId}/adclients/{adclientsId}/urlchannelsreadadsense.readonly
adsense.accounts.adclients.urlchannels.getGET /v2/accounts/{accountsId}/adclients/{adclientsId}/urlchannels/{urlchannelsId}readadsense.readonly
adsense.accounts.alerts.listGET /v2/accounts/{accountsId}/alertsreadadsense.readonly
adsense.accounts.payments.listGET /v2/accounts/{accountsId}/paymentsreadadsense.readonly
adsense.accounts.policyIssues.listGET /v2/accounts/{accountsId}/policyIssuesreadadsense.readonly
adsense.accounts.policyIssues.getGET /v2/accounts/{accountsId}/policyIssues/{policyIssuesId}readadsense.readonly
adsense.accounts.reports.generateGET /v2/accounts/{accountsId}/reports:generatereadadsense.readonly
adsense.accounts.reports.generateCsvGET /v2/accounts/{accountsId}/reports:generateCsvreadadsense.readonly
adsense.accounts.reports.getSavedGET /v2/accounts/{accountsId}/reports/{reportsId}/savedreadadsense.readonly
adsense.accounts.reports.saved.listGET /v2/accounts/{accountsId}/reports/savedreadadsense.readonly
adsense.accounts.reports.saved.generateGET /v2/accounts/{accountsId}/reports/{reportsId}/saved:generatereadadsense.readonly
adsense.accounts.reports.saved.generateCsvGET /v2/accounts/{accountsId}/reports/{reportsId}/saved:generateCsvreadadsense.readonly
adsense.accounts.sites.listGET /v2/accounts/{accountsId}/sitesreadadsense.readonly
adsense.accounts.sites.getGET /v2/accounts/{accountsId}/sites/{sitesId}readadsense.readonly
adsenseplatform.platforms.accounts.listGET /v1/platforms/{platformsId}/accountsreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.getGET /v1/platforms/{platformsId}/accounts/{accountsId}readadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.lookupGET /v1/platforms/{platformsId}/accounts:lookupreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.createPOST /v1/platforms/{platformsId}/accountsadminadsense; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.closePOST /v1/platforms/{platformsId}/accounts/{accountsId}:closeadminadsense; AdSense for Platforms; enabled projects only; cannot be undone
adsenseplatform.platforms.accounts.events.createPOST /v1/platforms/{platformsId}/accounts/{accountsId}/eventsadminadsense; AdSense for Platforms; enabled projects only; cannot be undone
adsenseplatform.platforms.accounts.sites.listGET /v1/platforms/{platformsId}/accounts/{accountsId}/sitesreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.sites.getGET /v1/platforms/{platformsId}/accounts/{accountsId}/sites/{sitesId}readadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.sites.createPOST /v1/platforms/{platformsId}/accounts/{accountsId}/sitesadminadsense; AdSense for Platforms; enabled projects only
adsenseplatform.platforms.accounts.sites.deleteDELETE /v1/platforms/{platformsId}/accounts/{accountsId}/sites/{sitesId}adminadsense; AdSense for Platforms; enabled projects only; cannot be undone
adsenseplatform.platforms.accounts.sites.requestReviewPOST /v1/platforms/{platformsId}/accounts/{accountsId}/sites/{sitesId}:requestReviewpublicadsense; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.listGET /v1alpha/accounts/{accountsId}/platformsreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.getGET /v1alpha/accounts/{accountsId}/platforms/{platformsId}readadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.groups.listGET /v1alpha/accounts/{accountsId}/platforms/{platformsId}/groupsreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.groups.getGET /v1alpha/accounts/{accountsId}/platforms/{platformsId}/groups/{groupsId}readadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.groups.patchPATCH /v1alpha/accounts/{accountsId}/platforms/{platformsId}/groups/{groupsId}operateadsense; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.childAccounts.sites.listGET /v1alpha/accounts/{accountsId}/platforms/{platformsId}/childAccounts/{childAccountsId}/sitesreadadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.childAccounts.sites.getGET /v1alpha/accounts/{accountsId}/platforms/{platformsId}/childAccounts/{childAccountsId}/sites/{sitesId}readadsense.readonly; AdSense for Platforms; enabled projects only
adsenseplatform.accounts.platforms.childAccounts.sites.patchPATCH /v1alpha/accounts/{accountsId}/platforms/{platformsId}/childAccounts/{childAccountsId}/sites/{sitesId}adminadsense; AdSense for Platforms; enabled projects only

Notes on the classing:

  • No method spends money: AdSense pays the publisher.
  • A live ad unit’s size or type changes the ad slot every visitor of a page carrying its code sees, so it is public; a new unit shows nothing until a page carries its code, so creating one is operate.
  • Asking Google to review a platform site starts ads on it once approved, so it is public.
  • Deleting a custom channel cannot be undone (a channel made again gets a new reporting ID), and a closed sub-account, a removed site and a sent event cannot be taken back, so each is admin and asks to confirm. Creating a sub-account or its site, and moving a site to another revenue group (which changes the revenue share), set up accounts and money, so they are admin too.
  • A platform group’s description is a label, so changing it is operate.

What no tool reaches, because AdSense offers no API for it: users and access levels, terms, closing a non-platform account, payment settings, site and URL channel changes, and saved report definitions. A person does these in AdSense.

Each publisher account the company narrows agents to (integrations.adsense.accounts) is an account with the monetization capability, keyed by its ID; a company that names none shows AdSense as one account (the atlas).

  • Google allows 100 requests a minute per user, 500 a minute per project and 10,000 a day per project, resetting around midnight Pacific time, and a separate, unpublished quota of report rows. A read refused for quota is waited out briefly; a change never is. The answer says when quotas free up.
  • A report holds at most 100,000 rows at Google (a CSV report 1,000,000), and data three years back.
  • Recent earnings are estimates Google restates for a few days.

Part of Crewlet. Generated from crewlet/crewlet main at 3f5565e.