Get expenses history
Overview
To retrieve the expenses history for the account, make the GET request to the /accounts/{accountSID}/balance/expenses resource.
Please note that the billing information will be received within 60 seconds after the completion of the action (call, sms and etc).
You can narrow the returned results by specifying filtering parameters.
Request example
The following example demonstrates getting the expense history.
curl –X GET https://api.apifonica.com/v2/accounts/{accountSID}/balance/expenses \
-u {accountSID}:{authToken}
Response example
{
"limit": 20,
"prev": null,
"next": "https://api.apifonica.com/v2/accounts/{accountSID}/balance/expenses?next=1802945440",
"account_sid": "{AccountSID}",
"expenses_history": [
{
"date": "Thu, 16 Mar 2017 17:54:53 +0000",
"amount": 0.678,
"currency": "EUR",
"status": "completed",
"expense_sid": "{expenseSID}",
"article": "phone_calls",
"instance_uri": "/v2/accounts/{AccountSID}/calls/calf6825cc9-5d94-46e5-99d3-d96db81b4af7"
},
...
]
}
Response parameters
Parameter | Description |
---|---|
limit | A parameter describing how many records are returned at once. The default and maximum value is 20. |
prev | URI to the previous page. |
next | URI to the next page. |
account_sid | Unique account identifier. |
expenses_history | List of expenses. |
expenses_history/date | Date and time of an expense. |
expenses_history/amount | Amount of the expense. |
expenses_history/currency | Currency of the expense. |
expenses_history/status | The expense status. |
expenses_history/expense_sid | Unique transaction identifier. |
expenses_history/article | The subject of the expense. |
expenses_history/instance_uri | Null, or, in case the article parameter has an URI, it is placed here. For example, calls and messages have URIs. |
Response filtering
To narrow the response results, specify filtering parameters in your request.
Parameter | Description |
---|---|
limit | A parameter describing how many records are returned at one page. The default and maximum value is 20. |
status | The expense status. |
expense_sid | Unique write-off action identifier. |
amount | Amount of the expense. |
article | The subject of the expense. One of the following: sms, phone_calls, rent_for_number |
date_from | A parameter that allows displaying payments made after a specific date. The date should be specified in the YYYY-MM-DD format. |
date_to | A parameter that allows displaying payments made before a specific date. The date should be specified in the YYYY-MM-DD format. |
amount_from | A parameter that allows displaying payments exceeding a specific amount. You can specify both integer and decimal numbers, for example, 20 or 20.34. |
amount_to | A parameter that allows displaying payments not exceeding a specific amount. You can specify both integer and decimal numbers, for example, 20 or 20.34. |
Request example (with filtering)
The following example demonstrates getting the expense history.
curl –X GET https://api.apifonica.com/v2/accounts/{accountSID}/balance/expenses?limit=15&page=2 \
-u {accountSID}:{authToken}