GetAccountMonthlySpend Service Operation - Customer Billing

Gets the amount spent by the account in the specified month.

Request Elements

The GetAccountMonthlySpendRequest object defines the body and header elements of the service operation request. The elements must be in the same order as shown in the Request SOAP.

Note

Unless otherwise noted below, all request elements are required.

Request Body Elements

Element Description Data Type
AccountId The identifier of the account that contains the spend information to get.

The account must use the invoice payment method; credit card accounts are not supported.

If the account identifier belongs to an aggregator, the operation sums the account balances for all the accounts of all the customers that the aggregator manages. If the aggregator has ten customers and each customer has ten accounts, the operation returns the sum of the monthly spend of all 100 accounts. To get the monthly spend of a single account of a customer that the aggregator manages, set the AccountId element to the specified account identifier. To get the monthly spend of all the accounts of a customer that the aggregator manages, call this operation for each account, and then sum the monthly spend amounts.
long
MonthYear The month and year for which you want to get the monthly spend information (the operation ignores the day and time values).

The service uses the month and year components corresponding to the specified dateTime. For example 2020-05-15T00:00:00 and 2020-05 are both valid and will return the same results.

If you specify the current month, the operation returns the month-to-date spend amount. For example, if the current date is May 15, 2020 and you set MonthYear to May 2020, the operation returns the spend amount for May 1 to May 15, inclusively.

You cannot specify a future month and year. If you specify a prior month for which there is no data, the call returns 0 (zero).

The spend amount can span multiple insertion orders (IOs). If the credits are greater than the actual spend, the returned monthly spend amount is a negative value.
dateTime

Request Header Elements

Element Description Data Type
AuthenticationToken The OAuth access token that represents the credentials of a user who has permissions to Microsoft Advertising accounts.

For more information see Authentication with OAuth.
string
DeveloperToken The developer token used to access the Bing Ads API.

For more information see Get a Developer Token.
string
Password This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. string
UserName This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. string

Response Elements

The GetAccountMonthlySpendResponse object defines the body and header elements of the service operation response. The elements are returned in the same order as shown in the Response SOAP.

Response Body Elements

Element Description Data Type
Amount The amount spent by the account in the specified period.

The account must be Yahoo!-managed.

If the account is not Yahoo!-managed, the return value is 0.
double

Response Header Elements

Element Description Data Type
TrackingId The identifier of the log entry that contains the details of the API call. string

Request SOAP

This template was generated by a tool to show the order of the body and header elements for the SOAP request. For supported types that you can use with this service operation, see the Request Body Elements reference above.

<s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/Billing/v13">
    <Action mustUnderstand="1">GetAccountMonthlySpend</Action>
    <AuthenticationToken i:nil="false">ValueHere</AuthenticationToken>
    <DeveloperToken i:nil="false">ValueHere</DeveloperToken>
  </s:Header>
  <s:Body>
    <GetAccountMonthlySpendRequest xmlns="https://bingads.microsoft.com/Billing/v13">
      <AccountId>ValueHere</AccountId>
      <MonthYear>ValueHere</MonthYear>
    </GetAccountMonthlySpendRequest>
  </s:Body>
</s:Envelope>

Response SOAP

This template was generated by a tool to show the order of the body and header elements for the SOAP response.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/Billing/v13">
    <TrackingId d3p1:nil="false" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance">ValueHere</TrackingId>
  </s:Header>
  <s:Body>
    <GetAccountMonthlySpendResponse xmlns="https://bingads.microsoft.com/Billing/v13">
      <Amount>ValueHere</Amount>
    </GetAccountMonthlySpendResponse>
  </s:Body>
</s:Envelope>

Code Syntax

The example syntax can be used with Bing Ads SDKs. See Bing Ads API Code Examples for more examples.

public async Task<GetAccountMonthlySpendResponse> GetAccountMonthlySpendAsync(
	long accountId,
	DateTime monthYear)
{
	var request = new GetAccountMonthlySpendRequest
	{
		AccountId = accountId,
		MonthYear = monthYear
	};

	return (await CustomerBillingService.CallAsync((s, r) => s.GetAccountMonthlySpendAsync(r), request));
}
static GetAccountMonthlySpendResponse getAccountMonthlySpend(
	java.lang.Long accountId,
	Calendar monthYear) throws RemoteException, Exception
{
	GetAccountMonthlySpendRequest request = new GetAccountMonthlySpendRequest();

	request.setAccountId(accountId);
	request.setMonthYear(monthYear);

	return CustomerBillingService.getService().getAccountMonthlySpend(request);
}
static function GetAccountMonthlySpend(
	$accountId,
	$monthYear)
{

	$GLOBALS['Proxy'] = $GLOBALS['CustomerBillingProxy'];

	$request = new GetAccountMonthlySpendRequest();

	$request->AccountId = $accountId;
	$request->MonthYear = $monthYear;

	return $GLOBALS['CustomerBillingProxy']->GetService()->GetAccountMonthlySpend($request);
}
response=customerbilling_service.GetAccountMonthlySpend(
	AccountId=AccountId,
	MonthYear=MonthYear)

Requirements

Service: CustomerBillingService.svc v13
Namespace: https://bingads.microsoft.com/Billing/v13