

# DescribeBudgetSpend

Describes the spend of a budget for the budget's current period. Use this operation with a budget that uses the `PublicOnDemandCost` or `EstimatedContractedCost` metric.

By default, the response has one row for each budget limit. If the budget has `BudgetLimitDimensions`, set `GroupBy` to the budget's `SpendAttributions` key to get one row for each principal instead. Use `FilterExpression` to return only some principals. Rows are sorted by spend, from highest to lowest.

Results are paginated. Use the `NextToken` parameter to retrieve additional results.

## Request Syntax
<a name="API_budgets_DescribeBudgetSpend_RequestSyntax"></a>

```
{
   "AccountId": "{{string}}",
   "BudgetName": "{{string}}",
   "FilterExpression": { 
      "And": [ 
         "Expression"
      ],
      "CostCategories": { 
         "Key": "{{string}}",
         "MatchOptions": [ "{{string}}" ],
         "Values": [ "{{string}}" ]
      },
      "Dimensions": { 
         "Key": "{{string}}",
         "MatchOptions": [ "{{string}}" ],
         "Values": [ "{{string}}" ]
      },
      "IdentityCenterAttributes": { 
         "Key": "{{string}}",
         "MatchOptions": [ "{{string}}" ],
         "Values": [ "{{string}}" ]
      },
      "Not": "Expression",
      "Or": [ 
         "Expression"
      ],
      "ProductAttributes": { 
         "Key": "{{string}}",
         "MatchOptions": [ "{{string}}" ],
         "Values": [ "{{string}}" ]
      },
      "Tags": { 
         "Key": "{{string}}",
         "MatchOptions": [ "{{string}}" ],
         "Values": [ "{{string}}" ]
      }
   },
   "GroupBy": [ 
      { 
         "Key": "{{string}}",
         "Type": "{{string}}"
      }
   ],
   "MaxResults": {{number}},
   "NextToken": "{{string}}"
}
```

## Request Parameters
<a name="API_budgets_DescribeBudgetSpend_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [AccountId](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-AccountId"></a>
The `accountId` that is associated with the budget.  
Type: String  
Length Constraints: Fixed length of 12.  
Pattern: `\d{12}`   
Required: Yes

 ** [BudgetName](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-BudgetName"></a>
The name of the budget whose spend you want to describe.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 100.  
Pattern: `^(?![^:\\]*/action/|(?i).*<script>.*</script>.*)[^:\\]+$`   
Required: Yes

 ** [FilterExpression](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-FilterExpression"></a>
The principals to return spend for. Specify one `Dimensions` clause whose key is the budget's `SpendAttributions` value, with the `EQUALS` match option and 1 to 20 principal IDs. If you don't specify `FilterExpression`, AWS Budgets returns spend for every principal that has spend in the budget.  
Type: [Expression](API_budgets_Expression.md) object  
Required: No

 ** [GroupBy](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-GroupBy"></a>
How to group the spend. You can specify no entry or one entry. To get one row for each principal, specify one `DIMENSION` entry whose key is the budget's `SpendAttributions` value. If you don't specify `GroupBy`, the response uses the budget's `BudgetLimitDimensions`.  
Type: Array of [GroupDefinition](API_budgets_GroupDefinition.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 2 items.  
Required: No

 ** [MaxResults](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-MaxResults"></a>
The maximum number of results to return in one page. Valid range is 1 to 1000. If you don't specify `MaxResults`, the default is 100.  
Type: Integer  
Valid Range: Minimum value of 1. Maximum value of 1000.  
Required: No

 ** [NextToken](#API_budgets_DescribeBudgetSpend_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-request-NextToken"></a>
The pagination token that you include in your request to indicate the next set of results that you want to retrieve.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 4096.  
Pattern: `^[A-Za-z0-9+/=_-]+$`   
Required: No

## Response Syntax
<a name="API_budgets_DescribeBudgetSpend_ResponseSyntax"></a>

```
{
   "BudgetLimit": { 
      "Amount": "string",
      "Unit": "string"
   },
   "BudgetLimitDimensions": [ 
      { 
         "Key": "string",
         "Type": "string"
      }
   ],
   "GroupDefinitions": [ 
      { 
         "Key": "string",
         "Type": "string"
      }
   ],
   "LastUpdatedTime": number,
   "NextToken": "string",
   "SpendByGroup": [ 
      { 
         "Keys": [ "string" ],
         "LastUsageTime": number,
         "LimitStatus": "string",
         "Spend": { 
            "Amount": "string",
            "Unit": "string"
         }
      }
   ],
   "TimePeriod": { 
      "End": number,
      "Start": number
   }
}
```

## Response Elements
<a name="API_budgets_DescribeBudgetSpend_ResponseElements"></a>

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

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

 ** [BudgetLimit](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-BudgetLimit"></a>
The budget limit of the budget.  
Type: [Spend](API_budgets_Spend.md) object

 ** [BudgetLimitDimensions](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-BudgetLimitDimensions"></a>
The dimension that the budget limit applies to. With this value and `BudgetLimit`, you can tell whether a row is a principal's own limit or a share of a limit for all principals.  
Type: Array of [BudgetLimitDimension](API_budgets_BudgetLimitDimension.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 1 item.

 ** [GroupDefinitions](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-GroupDefinitions"></a>
The grouping that the response uses. The `Keys` of each row in `SpendByGroup` follow this order.  
Type: Array of [GroupDefinition](API_budgets_GroupDefinition.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 2 items.

 ** [LastUpdatedTime](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-LastUpdatedTime"></a>
The time when AWS Budgets last updated the spend for the current period.  
Type: Timestamp

 ** [NextToken](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-NextToken"></a>
The pagination token in the service response that indicates the next set of results that you can retrieve.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 4096.  
Pattern: `^[A-Za-z0-9+/=_-]+$` 

 ** [SpendByGroup](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-SpendByGroup"></a>
The rows of spend for the current period.  
Type: Array of [SpendGroup](API_budgets_SpendGroup.md) objects

 ** [TimePeriod](#API_budgets_DescribeBudgetSpend_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpend-response-TimePeriod"></a>
The current period of the budget.  
Type: [TimePeriod](API_budgets_TimePeriod.md) object

## Errors
<a name="API_budgets_DescribeBudgetSpend_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AccessDeniedException **   
You are not authorized to use this operation with the given parameters.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** ExpiredNextTokenException **   
The pagination token expired.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** InternalErrorException **   
An error on the server occurred during the processing of your request. Try again later.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** InvalidNextTokenException **   
The pagination token is invalid.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** InvalidParameterException **   
An error on the client occurred. Typically, the cause is an invalid input value.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** NotFoundException **   
We can’t locate the resource that you specified.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

 ** ThrottlingException **   
The number of API requests has exceeded the maximum allowed API request throttling limit for the account.    
 ** Message **   
The error message the exception carries.
HTTP Status Code: 400

## Examples
<a name="API_budgets_DescribeBudgetSpend_Examples"></a>

### Example
<a name="API_budgets_DescribeBudgetSpend_Example_1"></a>

The following is a sample request and response of the `DescribeBudgetSpend` operation for a budget that gives each Identity Center user their own limit. The response has one row for each user:

#### Sample Request
<a name="API_budgets_DescribeBudgetSpend_Example_1_Request"></a>

```
POST / HTTP/1.1
Host: awsbudgets.<region>.<domain>
x-amz-Date: <Date>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=contenttype;date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid,Signature=<Signature>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive
X-Amz-Target: AWSBudgetServiceGateway.DescribeBudgetSpend

{
   "AccountId": "111122223333",
   "BudgetName": "Example User Budget",
   "GroupBy": [
      {
         "Type": "DIMENSION",
         "Key": "IDENTITY_CENTER_USER"
      }
   ],
   "MaxResults": 2
}
```

#### Sample Response
<a name="API_budgets_DescribeBudgetSpend_Example_1_Response"></a>

```
{
   "BudgetLimit": {
      "Amount": "100",
      "Unit": "USD"
   },
   "BudgetLimitDimensions": [
      {
         "Type": "DIMENSION",
         "Key": "IDENTITY_CENTER_USER"
      }
   ],
   "GroupDefinitions": [
      {
         "Type": "DIMENSION",
         "Key": "IDENTITY_CENTER_USER"
      }
   ],
   "SpendByGroup": [
      {
         "Keys": ["a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"],
         "Spend": {
            "Amount": "104.25",
            "Unit": "USD"
         },
         "LimitStatus": "LIMIT_REACHED",
         "LastUsageTime": 1795651200
      },
      {
         "Keys": ["a1b2c3d4-5678-90ab-cdef-EXAMPLE22222"],
         "Spend": {
            "Amount": "42.10",
            "Unit": "USD"
         },
         "LimitStatus": "WITHIN_LIMIT",
         "LastUsageTime": 1795647600
      }
   ],
   "TimePeriod": {
      "Start": 1793491200,
      "End": 1796083199
   },
   "LastUpdatedTime": 1795654800,
   "NextToken": "eyJvZmZzZXQiOjJ9"
}
```

## See Also
<a name="API_budgets_DescribeBudgetSpend_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/budgets-2016-10-20/DescribeBudgetSpend) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/budgets-2016-10-20/DescribeBudgetSpend) 