View a markdown version of this page

GetAccountBalance - AWS Billing and Cost Management

GetAccountBalance

Retrieves one balance of your account, selected by balance type, as one amount for each merchant of record and currency. Each amount is the sum of the outstanding balances of your invoices or credit memos that have the status OUTSTANDING. Amounts are never added together across merchants of record or currencies. This operation is eventually consistent. Results are paginated. Use nextToken to retrieve more results.

To use this operation, you must have AWS Identity and Access Management (IAM) permission for both payments:GetAccountBalance and payments:GetPaymentStatus.

Request Syntax

{ "balanceType": "string", "maxResults": number, "nextToken": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

balanceType

The balance to retrieve. You can specify only one balance type in a single request. Each balance adds up the outstanding balance of the records that have the status OUTSTANDING. A record that is PROCESSING, SETTLED, or CANCELED isn't included, even when part of its amount is outstanding. The following values are valid:

  • INVOICES_DUE – The outstanding balance of your OUTSTANDING invoices that aren't past their due date, where dueStatus is DUE.

  • INVOICES_PAST_DUE – The outstanding balance of your OUTSTANDING invoices that are past their due date, where dueStatus is PAST_DUE.

  • OUTSTANDING_CREDIT_MEMOS – The outstanding balance of your OUTSTANDING credit memos: the credit that isn't yet applied to an invoice.

Type: String

Valid Values: INVOICES_DUE | INVOICES_PAST_DUE | OUTSTANDING_CREDIT_MEMOS

Required: Yes

maxResults

The maximum number of results to return in one page. The default is 100. A page can contain fewer results even when more remain. Use nextToken to find out whether more results are available.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: No

nextToken

The pagination token from the nextToken of the previous response. Omit it to get the first page. Tokens expire. If the token is malformed or expired, or doesn't match the original request, the request fails with ValidationException and the reason INVALID_PAGINATION_TOKEN. In that case, start again from the first page.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: No

Response Syntax

{ "accountBalances": [ { "amount": { "currency": "string", "value": "string" }, "merchantOfRecord": "string" } ], "nextToken": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

accountBalances

The balance, as one amount for each merchant of record and currency. This list is empty when your account has nothing in the requested balance.

Type: Array of AccountBalance objects

nextToken

The pagination token that indicates the next set of results to retrieve. This value is absent when there are no more results.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

The request is denied because you don't have sufficient access to perform this operation. Verify that you have the required permissions and try again. This error is also returned, instead of ResourceNotFoundException, when you aren't authorized for the resource, so the response doesn't reveal whether the resource exists.

reason

The reason that access was denied. The following values are valid:

  • NOT_AUTHORIZED – Your IAM policies don't allow this action.

  • INVALID_ACCOUNT_STATE – Your AWS account isn't in a state that allows this action, for example because registration isn't complete or the account is suspended.

  • OTHER – Access was denied for another reason.

HTTP Status Code: 400

InternalServerException

The request processing failed because of an unknown error, exception, or failure. Retry your request.

retryAfterSeconds

The suggested number of seconds to wait before retrying the request.

HTTP Status Code: 500

ThrottlingException

The request was denied due to request throttling. Reduce the frequency of your requests and try again.

retryAfterSeconds

The suggested number of seconds to wait before retrying the request.

HTTP Status Code: 400

ValidationException

The request isn't valid. Check reason and fieldList for the cause, correct the request, and try again.

fieldList

The request members that failed validation. This member is populated when reason is FIELD_VALIDATION_FAILED.

reason

The reason that validation failed. The following values are valid:

  • CANNOT_PARSE – The request body couldn't be parsed, or a value isn't of the expected type.

  • FIELD_VALIDATION_FAILED – One or more members failed validation. fieldList names them.

  • INVALID_PAGINATION_TOKEN – The nextToken is malformed or expired, or doesn't match the original request. Start again from the first page.

  • UNSUPPORTED_ACTION – The request is well formed, but the action isn't supported for your account, Region, or resource.

  • OTHER – The request isn't valid for another reason.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: