Update/Mutate campaign budget using REST API

656 views
Skip to first unread message

Eylon Raymond Harari

unread,
Jan 26, 2021, 11:43:19 PM1/26/21
to AdWords API and Google Ads API Forum
Im trying to update campaign budgets using the rest api. 

This has been working successfully for other operations, such as updating the campaign status, name, etc.. 

I'll provide a few examples here of the types of "payloads" I have been using. 

1. Updating campaign status (that one works fine):

{
    operations: [{
        updateMask: 'status',
        update: {
            resourceName: `customers/${user.customer_id}/campaigns/${campaignId}`,
            status,
        },
    }, ],
};

2. Updating campaign budget (that one does not work)

{
    operations: [{
        updateMask: 'amountMicros',
        update: {
            resourceName: `customers/${customer_id}/campaignBudgets/${budget_id}`,
            amountMicros: '700000000',
        },
    }, ],
};


3. For more context, I will share a sample response when fetching this data:

[{
    results: [{
        campaign: {
            resourceName: 'customers/XXXXX-XXXXXX/campaigns/XXXXX-XXXXXX',
            status: 'ENABLED',
            name: 'XXXXX-XXXXXX',
            id: 'XXXXX-XXXXXX',
        },
        metrics: {
            clicks: '0',
            conversions: 0,
            costMicros: '0',
            impressions: '0',
        },
        campaignBudget: {
            resourceName: 'customers/XXXXX-XXXXXX/campaignBudgets/XXXXX-XXXXXX',
            amountMicros: '700000000',
        },
    }, ],
    fieldMask: 'campaign.id,campaign.name,campaign.status,campaignBudget.amountMicros,metrics.impressions,metrics.clicks,metrics.ctr,metrics.averageCpc,metrics.conversions,metrics.costMicros,metrics.averageCpc',
}, ];

As you can see I have been trying to make the update/mutate requests while following the data shape seen in figure 3 - but with no success. 

Would appreciate if someone can share a solution or a code sample for this one, 

Cheers

Google Ads API Forum Advisor Prod

unread,
Jan 27, 2021, 3:48:13 PM1/27/21
to eyl...@gmail.com, adwor...@googlegroups.com

Hi Eylon,

Thank you for reaching out. Please give it a try to the following code:
 

curl --request POST \

     --header "Content-Type: application/json" \

     --header "Authorization: Bearer ACCESS TOKEN" \

     --header "developer-token: DEVELOPER TOKEN" \

     --data @update_budget.json \

     https://googleads.googleapis.com/v6/customers/1234567890/campaignBudgets:mutate

 

{

  "operations": [

    {

      "updateMask": "amount_micros",

      "update": {

        "resourceName": "customers/1234567890/campaignBudgets/1xxxxxxxx1",

        “amount_micros”: "60000000"

      }

    }

  ]

}

 

Thanks and regards,
Xiaoming, Google Ads API Team
 

Google Logo
Xiaoming
Google Ads API Team
 


ref:_00D1U1174p._5004Q2B3hNK:ref

Eylon Raymond Harari

unread,
Jan 28, 2021, 8:03:09 PM1/28/21
to AdWords API and Google Ads API Forum
Works great, thanks for the help!
Reply all
Reply to author
Forward
0 new messages