BudgetOrderService INVALID_BUDGET_ALREADY_SPENT on BudgetOrders with large amounts of credit

48 views
Skip to first unread message

Evan Giesel

unread,
Oct 7, 2016, 3:09:28 PM10/7/16
to AdWords API Forum
Hi,
I'm using BudgetOrderService to increase the budget amount in a bunch of BudgetOrders, periodically. This is working fine for the most part. Every once in awhile, though, I run into this error: INVALID_BUDGET_ALREADY_SPENT

From what I read, this is caused when you try to set the spendingLimit of a BudgetOrder to a value lower than what is already spent. For example, If I have a $300 budget, and have spent $250, trying to set the budget to anything lower than $250 will result in an error. I did this a lot to early on, but have since fixed up my code to avoid this case.

My problem seems to crop up whenever a large credit is involved.

Let's say I have a $300 BudgetOrder, with $100 of credit, and the whole thing has been spent. This means spendingLimit = $400 = budget ($300) + totalAdjustments ($100), and amount spent is $400

Now what if I want to increase the spendingLimit by $50?

In the api the only way to do this is through the BudgetOrderService -> mutate -> SET -> spendingLimit and, from the docs:
Note, that for get requests the spending limit includes any adjustments that have been applied to the budget order. For mutate, the spending limit represents the maximum allowed spend prior to considering any adjustments.
So, the current budget amount before adjustments is $300 ( I can get that number by taking spendingLimit and subtracting totalAdjustments ). If I want to increase it by $50, I have to SET spendingLimit to $350. After adjustments, the spendingLimit should come back in the GET request as $450 ( $350 budget + $100 adjustment ). 

But it doesn't. It fails with INVALID_BUDGET_ALREADY_SPENT.

Herein lies the problem (as far as I can tell):
Using a mutate -> SET request, spendingLimit is only the budget amount, and does not include any adjustments.
I guessing at some point in the SET, the API checks to see if spendingLimit (only budget amount, no adjustments) < amount spent, which, in this case, is $350 < $400, causing the INVALID_BUDGET_ALREADY_SPENT error.
I would think the correct way to check for INVALID_BUDGET_ALREADY_SPENT would be spendingLimit (just budget amount) + totalAdjustments < amount spent, or $350 + $100 < $400  = no error

Interestingly, for this same case, I can go to the mcc, and set the budget amount to $350, and it correctly set the budget amount without bringing up an error. 

Am I looking at this wrong, or is it the intended behavior?

Thanks,
-Evan

Shwetha Vastrad (AdWords API Team)

unread,
Oct 7, 2016, 5:15:56 PM10/7/16
to AdWords API Forum
Hi Evan,

Do you happen to have the SOAP XML request and response logs when you encountered this error? Could you provide also provide your clientCustomerId so I can further investigate? Could you also use the v201609 version of BudgetOrderService to get the spendingLimit and totalAdjustments of your budget order? 

Please use Reply privately to author when responding. 

Thanks,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages