Guides
Getting started

Quickstart

Activate the sandbox, get a token, publish a search campaign, approve the ad, generate clicks and read the metrics.

This guide takes a few minutes: you activate the simulator, get a token without going through the consent screen, publish a campaign in a single mutate, approve the ad, generate a click and query the metrics.

Prerequisites

  • An organization in Mimicr and a write API key (mk_…), created in the organization settings, "Chaves de API" tab.
  • curl, or any HTTP client, and Node 18+ if you want to use the CLI.

1. Activate the Google Ads sandbox

In the console, open the organization at https://app.mimicr.dev, go to Google Ads and activate it. Or through the control API:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/google-ads/activate \
  --header 'Authorization: Bearer mk_...'

The sandbox starts with an OAuth client, a Google Cloud project at BASIC, a manager account (MCC) with "Conta 1" (ENABLED) and "Conta pendente" (CANCELED), a standalone account and three Google users. If it is already active, the call answers 409 google_ads_already_active.

2. Read the credentials and accounts

bash
curl --url https://api.mimicr.dev/v1/google-ads \
  --header 'Authorization: Bearer mk_...'
json
{
  "active": true,
  "host": "https://google-ads.mimicr.dev",
  "oauth": {
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "authorize_url": "https://google-ads.mimicr.dev/o/oauth2/v2/auth",
    "token_url": "https://google-ads.mimicr.dev/token",
    "redirect_uris": [],
    "any_redirect_uri": true
  },
  "ads_api": "https://google-ads.mimicr.dev/v26",
  "data_manager_api": "https://google-ads.mimicr.dev/v1",
  "users": [
    { "email": "gestor@minha-org.mimicr.dev", "customers": ["6446154552"] },
    { "email": "anunciante@minha-org.mimicr.dev", "customers": ["…"] },
    { "email": "sem-contas@minha-org.mimicr.dev", "customers": [] }
  ],
  "customers": [
    { "id": "6446154552", "name": "MCC minha-org", "manager": true, "status": "ENABLED" },
    { "id": "2220330728", "name": "Conta 1", "parent": "6446154552", "status": "ENABLED" }
  ]
}

The ids above are examples; use the ones of your sandbox. With the CLI: npx mimicr login mk_... once, then npx mimicr status google-ads.

3. Get a token

Your real application uses the consent screen. To get started quickly, Mimicr issues the tokens of a direct user:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/google-ads/token \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "user": "gestor@minha-org.mimicr.dev" }'
json
{
  "access_token": "ya29.a0…",
  "expires_in": 3599,
  "refresh_token": "1//0…",
  "scope": "openid email https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/datamanager",
  "token_type": "Bearer",
  "user": "gestor@minha-org.mimicr.dev"
}

4. List the accounts

bash
curl --url https://google-ads.mimicr.dev/v26/customers:listAccessibleCustomers \
  --header 'Authorization: Bearer <token>'
json
{ "resourceNames": ["customers/6446154552"] }

The manager user only has direct access to the MCC. Client accounts are reached through it, with login-customer-id: 6446154552. See Account hierarchy.

5. Publish a campaign

A single mutate creates the budget, campaign, targeting, ad group, keyword and ad, linked by negative temporary ids:

bash
curl --request POST \
  --url https://google-ads.mimicr.dev/v26/customers/2220330728/googleAds:mutate \
  --header 'Authorization: Bearer <token>' \
  --header 'login-customer-id: 6446154552' \
  --header 'Content-Type: application/json' \
  --data '{
    "mutateOperations": [
      { "campaignBudgetOperation": { "create": { "resourceName": "customers/2220330728/campaignBudgets/-1", "name": "Gás Goiânia · orçamento", "amountMicros": "50000000", "explicitlyShared": false } } },
      { "campaignOperation": { "create": { "resourceName": "customers/2220330728/campaigns/-2", "name": "Gás Goiânia", "status": "ENABLED", "advertisingChannelType": "SEARCH", "campaignBudget": "customers/2220330728/campaignBudgets/-1", "maximizeConversions": {}, "networkSettings": { "targetGoogleSearch": true } } } },
      { "campaignCriterionOperation": { "create": { "campaign": "customers/2220330728/campaigns/-2", "location": { "geoTargetConstant": "geoTargetConstants/1001552" } } } },
      { "adGroupOperation": { "create": { "resourceName": "customers/2220330728/adGroups/-3", "name": "Grupo 1", "campaign": "customers/2220330728/campaigns/-2", "type": "SEARCH_STANDARD" } } },
      { "adGroupCriterionOperation": { "create": { "adGroup": "customers/2220330728/adGroups/-3", "keyword": { "text": "gás de cozinha", "matchType": "PHRASE" } } } },
      { "adGroupAdOperation": { "create": { "adGroup": "customers/2220330728/adGroups/-3", "ad": { "finalUrls": ["https://revenda.example.com"], "responsiveSearchAd": { "headlines": [{ "text": "Gás rápido" }, { "text": "Botijão P13" }, { "text": "Peça já" }], "descriptions": [{ "text": "Entrega em 30 min." }, { "text": "Pague no Pix." }] } } } } }
    ]
  }'

The response has one result per operation, in the same order, with the real ids:

json
{
  "mutateOperationResponses": [
    { "campaignBudgetResult": { "resourceName": "customers/2220330728/campaignBudgets/54542599976" } },
    { "campaignResult": { "resourceName": "customers/2220330728/campaigns/54542599977" } },
    { "campaignCriterionResult": { "resourceName": "customers/2220330728/campaignCriteria/54542599977~1001552" } },
    { "adGroupResult": { "resourceName": "customers/2220330728/adGroups/54542599986" } },
    { "adGroupCriterionResult": { "resourceName": "customers/2220330728/adGroupCriteria/54542599986~54542599987" } },
    { "adGroupAdResult": { "resourceName": "customers/2220330728/adGroupAds/54542599986~54542599990" } }
  ]
}

Details in Create a campaign.

6. Approve the ad

The ad starts as REVIEW_IN_PROGRESS and Mimicr approves it on its own after 10 minutes of the sandbox clock. To skip the wait, play the reviewer:

bash
npx mimicr action google-ads ad.approve adGroupAd=customers/2220330728/adGroupAds/54542599986~54542599990

7. Generate a click and read the metrics

bash
npx mimicr action google-ads traffic.click adGroupAd=54542599990

The action returns the gclid and the landingUrl (the final URL with ?gclid=…), which you later use to send a conversion. To generate a full day of delivery without moving the clock: npx mimicr action google-ads traffic.deliver hours=24.

bash
curl --request POST \
  --url https://google-ads.mimicr.dev/v26/customers/2220330728/googleAds:search \
  --header 'Authorization: Bearer <token>' \
  --header 'login-customer-id: 6446154552' \
  --header 'Content-Type: application/json' \
  --data '{ "query": "SELECT campaign.id, campaign.primary_status, metrics.impressions, metrics.clicks, metrics.cost_micros FROM campaign WHERE campaign.id = 54542599977" }'

Next steps