skip to Main Content

I trying to get an Ad Account’s balance (Bill amount due) using this API endpoint:
https://graph.facebook.com/v3.2/{ad_account_id}?fields=balance

Unfortunately this API method return old data. 4 hours and older… How to get a fresh data like we can get manually at facebook.com/ads/manager/account_settings/account_billing
screenshot

Any ideas?

3

Answers


  1. You maybe can estimate that from spend report for ad account from previous bill… but that can be even less accurate…

    act_{ad_account_id}/insights?fields=spend&time_range={'since':'2018-11-02','until':'2018-12-02'}
    
    Login or Signup to reply.
  2. You can read in AdAccount attribute. For me, has been updated.

    $accounts = $user->getAdAccounts(
            array(
                'balance',
                'amount_spent'
            )
        );
    
    Login or Signup to reply.
  3. Are you still having this doubt? It was quite difficult to find the answer to this solution.

    After many hours I understood how the remaining account balance is calculated. you can make a request.

    Send a request to https://graph.facebook.com/v15.0/act_xxxxxxx?fields=amount_spent,balance,spend_cap
    as an example I will show the return of my request

    {
    "amount_spent": "5120944",
    "balance": "986",
    "spend_cap": "5304148",
    "id": "act_xxxxxx"
    }

    Now I will show how the calculation is done. Remembering that my currency is BRL

    The amount_spent field represents the total amount of money that has been spent on advertising for the account, and the spend_cap field represents the maximum amount of money that can be spent on advertising for the account.

    To calculate the current balance, you can subtract the amount_spent value from the spend_cap value. This will give you the remaining amount of money that can be spent on advertising.

    For example, if the amount_spent value is "5120924" and the spend_cap value is "5304148", then the current balance is 5304148 – 5120924 = 183224 units of the account currency.

    Units of The currency? Yes, I realized that in my case it brings the number in units (cents) so I divided it by 100 and got R$ 1.832,24.

    But I looked in the ads manager and the balance there is R$ 1,842.10

    Now let’s understand the balance field: Bill amount due for this Ad Account.
    So, 986/100 = R$ 9,86 + R$ 1.832,24 = R$ 1.842,10. Yeeeeaahhhhhhhhh

    Here is an example image of the request and print of the ad account https://www.linkpicture.com/q/requet_example.png

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search