Mediation groups
Stay organized with collections
Save and categorize content based on your preferences.
The AdMob API lets you create, list, and update mediation groups, including:
- Specifying mediation group targeting
including regions, format, platform, and IDFA targeting
- Adding new mediation group lines
to an existing mediation group
- Viewing which mediation groups are part of a mediation A/B experiment and what
mediation group lines belong to each variant: A or B
Examples
With OAuth 2.0 credentials created,
you're ready to start using the AdMob API. To request access using OAuth 2.0,
your application will also need the scope information.
Here's the OAuth 2.0 scope information:
Scope |
Meaning |
https://www.googleapis.com/auth/admob.monetization |
See, create, and edit your AdMob monetization settings.
|
https://www.googleapis.com/auth/admob.readonly |
See all AdMob data. This may include account
information, inventory and mediation settings, reports, and other data.
This doesn't include sensitive data, such as payments or campaign details.
|
Create
To create a mediation group, you must specify the mediation group targeting
information, including the relevant ad units. The following example creates a new
mediation group for Android interstitial ads for 2 ad units. One mediation group
line is added at creation for the InMobi ad source. You don't need to include
the AdMob network as it will be added at creation time by default.
In the code snippet below, replace pub-XXXXXXXXXXXXXXXX
with your publisher
ID.
Then, replace YYYYYYYYYY
with the last 10 digits of your ad unit
ID, complying
to the format:
ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY
As there are two ad units in this example, YYYYY11111
refers to the first ad
unit and WWWWW11111
to the first ad unit's mapping. YYYYY22222
and
WWWWW22222
refer to the second ad unit and ad unit mapping.
curl (command line)
Replace WWWWWWWWWW
with your ad unit mapping ID. The ad unit mapping ID
can be found using the
accounts.adUnits.adUnitMappings.list
method.
curl --http1.0 -X POST https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups
-H "Content-Type:application/json"
-H "$(oauth2l header --json path_to_credentials_json --scope admob.monetization)"
--data @- << EOF
{
"displayName": "Test Mediation Group"
"targeting": {
"platform": "ANDROID",
"format": "INTERSTITIAL"
"adUnitIds":["ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111", "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222"}
}
"mediationGroupLines": {
"-1": {
"displayName": "test line",
"adSourceId": "7681903010231960328",
"cpmMode": "MANUAL",
"cpmMicros": "150000",
"state": "ENABLED",
"adUnitMappings": {
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY11111/adUnitMappings/WWWWW11111",
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY22222/adUnitMappings/WWWWW22222"
}
}
}
List
Replace pub-XXXXXXXXXXXXXXXX
with your publisher
ID to view your mediation groups.
curl (command line)
Sample request:
curl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups \
-H "$(oauth2l header --json path_to_credentials_json --scope admob.monetization)"
Sample response:
{
"mediationGroups": [
{
"name": "accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ",
"mediationGroupId": "ZZZZZZZZZZ",
"displayName": "Test Mediation Group",
"state": "ENABLED",
"state": "NOT_RUNNING",
"targeting": {
"platform": "iOS",
"format": "BANNER",
"targetedRegionCodes": "[CA]",
"adUnits": ["YYYYY11111", "YYYYY22222"]
},
"mediationGroupLines": {
"11111111111111111": {
"id": "11111111111111111",
"displayName": "AdMob Network",
"adSourceId": "5450213213286189855",
"cpmMode": "LIVE",
"state": "ENABLED",
"experimentVariant": "ORIGINAL"
},
"22222222222222222": {
"id": "22222222222222222",
"displayName": "test line",
"adSourceId": "7681903010231960328",
"cpmMode": "MANUAL",
"cpmMicros": "150000",
"adUnitMappings": {
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY11111/adUnitMappings/WWWWW11111",
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY22222/adUnitMappings/WWWWW22222"
},
"state": "ENABLED",
"experimentVariant": "ORIGINAL"
}
},
}]
}
Patch
Here is the list of field
masks
to update a mediation group. Updates to repeated fields, such as items in a
list, fully replace existing values with new values. Updates to individual
values in a map can be done through indexing by the key.
The following field masks are supported for mediation group updates:
targeting.adUnitIds
mediationGroupLines[mediationGroupLineId]
mediationGroupLines[mediationGroupLineId].state
mediationGroupLines[mediationGroupLineId].adUnitMappings[adUnitId]
To update a mediation group with a new mediation group line, use a distinct
negative number for the mediationGroupLineId
. To update existing mediation
group lines, reference the mediation group line ID in both the update_mask
and
the payload as seen below.
"updateMask" {
paths: "mediation_group_lines["123"].ad_unit_mappings["456"]"
}
"mediationGroup" {
"mediationGroupLines": {
"123": {
"id": "123"
"adUnitMappings": {
"456": "newAdUnitMappingId"
}
}
}
}
curl (command line)
The example below adds 3 new mediation lines to an existing mediation group.
The updateMask
includes the 3 mediation group lines with distinct negative
values as the placeholder:
updateMask=mediationGroupLines["-1"],mediationGroupLines["-2"],mediationGroupLines["-3"]
You need to translate special characters because all URLs need to conform to
the syntax specified by the Uniform Resource Identifier (URI) specification,
so the updateMask
becomes:
updateMask=mediationGroupLines%5B%22-1%22%5D,mediationGroupLines%5B%22-2%22%5D,mediationGroupLines%5B%22-3%22%5D
To run the following example, replace pub-XXXXXXXXXXXXXXXX
with your
publisher ID and ZZZZZZZZZZ
with your mediation group ID. The mediation
group ID can be found in the AdMob UI or by using the accounts.mediationGroups:list
method.
Replace YYYYYYYYYY
with the last 10 digits of your ad unit
ID, following the format:
ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY`
Replace WWWWWWWWWW
with your ad unit mapping ID. The ad unit mapping ID
can be found using the
accounts.adUnits.adUnitMappings.list
method.
curl --http1.0 -X PATCH https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ?
updateMask=mediationGroupLines%5B%22-1%22%5D,mediationGroupLines%5B%22-2%22%5D,mediationGroupLines%5B%22-3%22%5D
-H "Content-Type:application/json"
-H "$(oauth2l header --json path_to_credentials_json --scope admob.monetization)"
--data @- << EOF
{
"mediationGroupLines": {
"-1": {
"displayName": "test line 2",
"adSourceId": "7681903010231960458",
"cpmMode": "MANUAL",
"cpmMicros": "150000",
"state": "ENABLED",
"adUnitMappings": {
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW"
}
},
"-2": {
"displayName": "test line 3",
"adSourceId": "7681903010231960328",
"cpmMode": "MANUAL",
"cpmMicros": "120000",
"state": "ENABLED",
"adUnitMappings": {
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW"
}
},
"-3": {
"displayName": "test line 4",
"adSourceId": "7681903010231960328",
"cpmMode": "MANUAL",
"cpmMicros": "130000",
"state": "ENABLED",
"adUnitMappings": {
"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY": "accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW"
}
}
}
}
EOF
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe AdMob API allows you to manage mediation groups, enabling you to create, update, and list them to optimize ad performance.\u003c/p\u003e\n"],["\u003cp\u003eDefine targeting criteria for mediation groups, including platform, format, regions, and IDFA, to control ad delivery to specific audiences.\u003c/p\u003e\n"],["\u003cp\u003eModify existing mediation groups by adding new mediation group lines, allowing you to introduce or adjust ad sources within a group.\u003c/p\u003e\n"],["\u003cp\u003eAccess information about mediation groups participating in A/B experiments and their respective variants, facilitating performance comparisons and optimization.\u003c/p\u003e\n"]]],[],null,["# Mediation groups\n\nThe AdMob API lets you create, list, and update mediation groups, including:\n\n- Specifying [mediation group targeting](/admob/api/reference/rest/v1beta/accounts.mediationGroups#MediationGroupTargeting) including regions, format, platform, and IDFA targeting\n- Adding new [mediation group lines](/admob/api/reference/rest/v1beta/MediationGroupLine) to an existing mediation group\n- Viewing which mediation groups are part of a mediation A/B experiment and what mediation group lines belong to each variant: A or B\n\nExamples\n--------\n\nWith [OAuth 2.0 credentials created](/admob/api/v1/getting-started#credentials),\nyou're ready to start using the AdMob API. To request access using OAuth 2.0,\nyour application will also need the scope information.\n\nHere's the OAuth 2.0 scope information:\n\n\u003cbr /\u003e\n\n| Scope | Meaning |\n|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/admob.monetization` | See, create, and edit your AdMob monetization settings. |\n| `https://www.googleapis.com/auth/admob.readonly` | See all AdMob data. This may include account information, inventory and mediation settings, reports, and other data. This doesn't include sensitive data, such as payments or campaign details. |\n\n\u003cbr /\u003e\n\n### Create\n\nTo create a mediation group, you must specify the [mediation group targeting](/admob/api/reference/rest/v1beta/accounts.mediationGroups#MediationGroupTargeting)\ninformation, including the relevant ad units. The following example creates a new\nmediation group for Android interstitial ads for 2 ad units. One mediation group\nline is added at creation for the InMobi ad source. You don't need to include\nthe AdMob network as it will be added at creation time by default.\n\nIn the code snippet below, replace `pub-XXXXXXXXXXXXXXXX` with your [publisher\nID](//support.google.com/admob/answer/2784578).\n\nThen, replace `YYYYYYYYYY` with the last 10 digits of your [ad unit\nID](//support.google.com/admob/answer/7356431), complying\nto the format: \n\n ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\n\nAs there are two ad units in this example, `YYYYY11111` refers to the first ad\nunit and `WWWWW11111` to the first ad unit's mapping. `YYYYY22222` and\n`WWWWW22222` refer to the second ad unit and ad unit mapping. \n\n### curl (command line)\n\nReplace `WWWWWWWWWW` with your ad unit mapping ID. The ad unit mapping ID\ncan be found using the\n[`accounts.adUnits.adUnitMappings.list`](/admob/api/reference/rest/v1beta/accounts.adUnits.adUnitMappings/list)\nmethod. \n\n```\n curl --http1.0 -X POST https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups\n-H \"Content-Type:application/json\"\n-H \"$(oauth2l header --json path_to_credentials_json --scope admob.monetization)\"\n--data @- \u003c\u003c EOF\n{\n \"displayName\": \"Test Mediation Group\"\n \"targeting\": {\n \"platform\": \"ANDROID\",\n \"format\": \"INTERSTITIAL\"\n \"adUnitIds\":[\"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111\", \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222\"}\n }\n \"mediationGroupLines\": {\n \"-1\": {\n \"displayName\": \"test line\",\n \"adSourceId\": \"7681903010231960328\",\n \"cpmMode\": \"MANUAL\",\n \"cpmMicros\": \"150000\",\n \"state\": \"ENABLED\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY11111/adUnitMappings/WWWWW11111\",\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY22222/adUnitMappings/WWWWW22222\"\n }\n }\n}\n```\n\n### List\n\nReplace `pub-XXXXXXXXXXXXXXXX` with your [publisher\nID](//support.google.com/admob/answer/2784578) to view your mediation groups. \n\n### curl (command line)\n\nSample request: \n\n```\ncurl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups \\\n-H \"$(oauth2l header --json path_to_credentials_json --scope admob.monetization)\"\n```\n\nSample response: \n\n```transact-sql\n{\n\"/admob/api/reference/rest/v1beta/accounts.mediationGroups\": [\n {\n \"name\": \"accounts/\u003cvar translate=\"no\"\u003epub-XXXXXXXXXXXXXXXX\u003c/var\u003e/mediationGroups/\u003cvar translate=\"no\"\u003eZZZZZZZZZZ\u003c/var\u003e\",\n \"mediationGroupId\": \"\u003cvar translate=\"no\"\u003eZZZZZZZZZZ\u003c/var\u003e\",\n \"displayName\": \"Test Mediation Group\",\n \"state\": \"ENABLED\",\n \"state\": \"NOT_RUNNING\",\n \"targeting\": {\n \"platform\": \"iOS\",\n \"format\": \"BANNER\",\n \"targetedRegionCodes\": \"[CA]\",\n \"adUnits\": [\"YYYYY11111\", \"YYYYY22222\"]\n },\n \"mediationGroupLines\": {\n \"11111111111111111\": {\n \"id\": \"11111111111111111\",\n \"displayName\": \"AdMob Network\",\n \"adSourceId\": \"5450213213286189855\",\n \"cpmMode\": \"LIVE\",\n \"state\": \"ENABLED\",\n \"experimentVariant\": \"ORIGINAL\"\n },\n \"22222222222222222\": {\n \"id\": \"22222222222222222\",\n \"displayName\": \"test line\",\n \"adSourceId\": \"7681903010231960328\",\n \"cpmMode\": \"MANUAL\",\n \"cpmMicros\": \"150000\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY11111\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY11111/adUnitMappings/WWWWW11111\",\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYY22222\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYY22222/adUnitMappings/WWWWW22222\"\n },\n \"state\": \"ENABLED\",\n \"experimentVariant\": \"ORIGINAL\"\n }\n },\n }]\n}\n```\n\n### Patch\n\nHere is the list of [field\nmasks](/protocol-buffers/docs/reference/java/com/google/protobuf/FieldMask)\nto update a mediation group. Updates to repeated fields, such as items in a\nlist, fully replace existing values with new values. Updates to individual\nvalues in a map can be done through indexing by the key.\n\nThe following field masks are supported for mediation group updates:\n\n- `targeting.adUnitIds`\n- `mediationGroupLines[mediationGroupLineId]`\n- `mediationGroupLines[mediationGroupLineId].state`\n- `mediationGroupLines[mediationGroupLineId].adUnitMappings[adUnitId]`\n\nTo update a mediation group with a new mediation group line, use a distinct\nnegative number for the `mediationGroupLineId`. To update existing mediation\ngroup lines, reference the mediation group line ID in both the `update_mask` and\nthe payload as seen below. \n\n \"updateMask\" {\n paths: \"mediation_group_lines[\"123\"].ad_unit_mappings[\"456\"]\"\n }\n\n \"mediationGroup\" {\n \"mediationGroupLines\": {\n \"123\": {\n \"id\": \"123\"\n \"adUnitMappings\": {\n \"456\": \"newAdUnitMappingId\"\n }\n }\n }\n }\n\n### curl (command line)\n\nThe example below adds 3 new mediation lines to an existing mediation group.\nThe `updateMask` includes the 3 mediation group lines with distinct negative\nvalues as the placeholder:\n\n`updateMask=mediationGroupLines[\"-1\"],mediationGroupLines[\"-2\"],mediationGroupLines[\"-3\"]`\n\nYou need to translate special characters because all URLs need to conform to\nthe syntax specified by the Uniform Resource Identifier (URI) specification,\nso the `updateMask` becomes:\n\n`updateMask=mediationGroupLines%5B%22-1%22%5D,mediationGroupLines%5B%22-2%22%5D,mediationGroupLines%5B%22-3%22%5D`\n\nTo run the following example, replace `pub-XXXXXXXXXXXXXXXX` with your\npublisher ID and `ZZZZZZZZZZ` with your mediation group ID. The mediation\ngroup ID can be found in the AdMob UI or by using the [`accounts.mediationGroups:list`](/admob/api/reference/rest/v1beta/accounts.mediationGroups/list)\nmethod.\n\nReplace `YYYYYYYYYY` with the last 10 digits of your [ad unit\nID](//support.google.com/admob/answer/7356431), following the format: \n\n ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY`\n\nReplace `WWWWWWWWWW` with your ad unit mapping ID. The ad unit mapping ID\ncan be found using the\n[`accounts.adUnits.adUnitMappings.list`](/admob/api/reference/rest/v1beta/accounts.adUnits.adUnitMappings/list)\nmethod. \n\n```\ncurl --http1.0 -X PATCH https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ?\nupdateMask=mediationGroupLines%5B%22-1%22%5D,mediationGroupLines%5B%22-2%22%5D,mediationGroupLines%5B%22-3%22%5D\n-H \"Content-Type:application/json\"\n-H \"$(oauth2l header --json path_to_credentials_json --scope admob.monetization)\"\n--data @- \u003c\u003c EOF\n{\n\"mediationGroupLines\": {\n \"-1\": {\n \"displayName\": \"test line 2\",\n \"adSourceId\": \"7681903010231960458\",\n \"cpmMode\": \"MANUAL\",\n \"cpmMicros\": \"150000\",\n \"state\": \"ENABLED\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW\"\n }\n},\n\"-2\": {\n \"displayName\": \"test line 3\",\n \"adSourceId\": \"7681903010231960328\",\n \"cpmMode\": \"MANUAL\",\n \"cpmMicros\": \"120000\",\n \"state\": \"ENABLED\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW\"\n }\n},\n\"-3\": {\n \"displayName\": \"test line 4\",\n \"adSourceId\": \"7681903010231960328\",\n \"cpmMode\": \"MANUAL\",\n \"cpmMicros\": \"130000\",\n \"state\": \"ENABLED\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/WWWWWWWWWW\"\n }\n }\n}\n}\nEOF\n```"]]