

# DescribeBudgetSpendForPrincipal

Describes one principal's spend in each user-based budget in the account, for each budget's current period. A user-based budget uses the `PublicOnDemandCost` or `EstimatedContractedCost` metric.

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

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

```
{
   "AccountId": "{{string}}",
   "MaxResults": {{number}},
   "NextToken": "{{string}}",
   "Principal": { 
      "Id": "{{string}}",
      "Type": "{{string}}"
   }
}
```

## Request Parameters
<a name="API_budgets_DescribeBudgetSpendForPrincipal_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_DescribeBudgetSpendForPrincipal_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-request-AccountId"></a>
The `accountId` that is associated with the budgets.  
Type: String  
Length Constraints: Fixed length of 12.  
Pattern: `\d{12}`   
Required: Yes

 ** [MaxResults](#API_budgets_DescribeBudgetSpendForPrincipal_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-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_DescribeBudgetSpendForPrincipal_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-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

 ** [Principal](#API_budgets_DescribeBudgetSpendForPrincipal_RequestSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-request-Principal"></a>
The principal whose spend you want to describe.  
Type: [SpendPrincipal](API_budgets_SpendPrincipal.md) object  
Required: Yes

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

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

## Response Elements
<a name="API_budgets_DescribeBudgetSpendForPrincipal_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.

 ** [NextToken](#API_budgets_DescribeBudgetSpendForPrincipal_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-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+/=_-]+$` 

 ** [SpendByBudget](#API_budgets_DescribeBudgetSpendForPrincipal_ResponseSyntax) **   <a name="awscostmanagement-budgets_DescribeBudgetSpendForPrincipal-response-SpendByBudget"></a>
The principal's spend in each budget. Each item has the budget's own current period.  
Type: Array of [PerBudgetSpendItem](API_budgets_PerBudgetSpendItem.md) objects

## Errors
<a name="API_budgets_DescribeBudgetSpendForPrincipal_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

 ** 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_DescribeBudgetSpendForPrincipal_Examples"></a>

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

The following is a sample request and response of the `DescribeBudgetSpendForPrincipal` operation for an AWS Identity and Access Management (IAM) role. The response has one item for each budget that the role's spend counts toward:

#### Sample Request
<a name="API_budgets_DescribeBudgetSpendForPrincipal_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.DescribeBudgetSpendForPrincipal

{
   "AccountId": "111122223333",
   "Principal": {
      "Type": "IAM_PRINCIPAL",
      "Id": "arn:aws:iam::111122223333:role/ExampleRole"
   }
}
```

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

```
{
   "SpendByBudget": [
      {
         "BudgetName": "Example Role Budget",
         "BudgetLimit": {
            "Amount": "500",
            "Unit": "USD"
         },
         "TimePeriod": {
            "Start": 1793491200,
            "End": 1796083199
         },
         "Spend": {
            "Amount": "212.40",
            "Unit": "USD"
         },
         "LimitStatus": "WITHIN_LIMIT",
         "LastUsageTime": 1795651200,
         "BudgetLimitDimensions": [
            {
               "Type": "DIMENSION",
               "Key": "IAM_PRINCIPAL"
            }
         ],
         "Keys": ["arn:aws:iam::111122223333:role/ExampleRole"],
         "LastUpdatedTime": 1795654800
      }
   ]
}
```

## See Also
<a name="API_budgets_DescribeBudgetSpendForPrincipal_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/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/budgets-2016-10-20/DescribeBudgetSpendForPrincipal) 