Budgets API




Create a Budget

Required parameters: budget_metric, budget_value, budget_period
Optional parameter: budget_pacing (if you leave blank it defaults to ASAP)
Budget pacing values: "front_loaded" or "even"

Please note that if you want to add a budget on top of a preexisting one, it cannot have the same budget period.

SDK

Use tab completion with SDK to auto-complete function names or show field options!

In [1]: import springserve
 
In [2]: tag = springserve.demand_tags.get(30424)


In [3]: new_budget = {
						"budget_metric": "requests", #mandatory
						"budget_period": "day", #mandatory
						"budget_pacing": "even", #optional
						"budget_value": 300 #mandatory
   						"vast_caching_adjustment": True, #optional
   						"vast_caching_lookback_seconds": None, #optional
   						"vast_caching_multiplier": None, #optional
   						"ignore_supply_allocations": False, #optional
   						"budget_value_currency": "USD" #optional
					}


In [4]: tag.budgets.append(new_budget)
 
In [5]: tag.save()	
 
In [6]: tag.ok

Out [5]: True

REST API

PUT /api/v0/demand_tags/<id>

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{ 
    "budgets":[{ 
       "budget_metric":"requests", 
       "budget_value":300, 
       "budget_period":"day" 
       }] 
 }


Response

Status code 200

{
  "id": 316932,
  "account_id": 391,
  "name": "test_tag",
  "active": true,
  "rate": "0.01",
  …
 
  "budgets": [
        {
            "id": 139151,
            "budget_metric": "requests",
            "budget_period": "day",
            "budget_pacing": null,
            "budget_value": 300,
			"vast_caching_adjustment": True,
   			"vast_caching_lookback_seconds": None,
   			"vast_caching_multiplier": None,
   			"ignore_supply_allocations": False,
   			"budget_value_currency": "USD"
        }
    ],
    "frequency_caps": []
}


Edit a Budget

SDK

In [1]: tag = springserve.demand_tags.get(30424)
 
In [2]: tag.budgets = {"id":"139151", "budget_value":200}
 
In [3]: changed = tag.save()
 
In [4]: changed.ok
Out [4]: True
 
In [5]: print tag.budgets
Out [5]:[{u'budget_metric': u'requests',  u'budget_pacing': None,  u'budget_period': u'week',  u'budget_value': 200,  u'id': 139151}]

REST API

PUT /api/v0/demand_tags/<id>

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{
    "budgets":[{
      "budget_pacing":"front_loaded",
      "budget_value": 1300,
      "id":139151
      }]
}

Required parameters: id

Response

Status code 200

{
  "id": 316932,
  "account_id": 391,
  "name": "test_tag",
  "active": true,
  "rate": "0.01",
  …
 
"budgets": [
        {
            "id": 139151,
            "budget_metric": "requests",
            "budget_period": "day",
            "budget_pacing": "front_loaded",
            "budget_value": 1300
        }
    ],
    "frequency_caps": []
}