

# GetEntitlementDecision

Returns an entitlement decision for a user action, indicating whether the action is allowed and why. It takes the pending event's quantity and properties so the check sizes the decision per metric the way PutEvent counts the event: it applies each metric's filter to the properties, counts 1 for a COUNT metric, and reads the summed or maxed field value for a SUM or MAX metric. The decision is DENY when usage already reached the limit, or when folding this event in would push it past (a SUM or COUNT metric adds the increment to current usage, a MAX metric takes the larger of the two). Send the same eventType, quantity and properties you will send on the event: the check applies the rules PutEvent applies to that event. A SUM or MAX metric that reads a property rejects the check with a ValidationException when the property is missing or not a plain decimal, including when properties are omitted or sent as {}; a metric filter matches only properties that are present, so a filtered metric is skipped for an event with no properties, as PutEvent skips it. It is idempotent, and it may create the user's default-plan subscription on first use.

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

```
POST /apps/{{appId}}/entitlements/check HTTP/1.1
Content-type: application/json

{
   "eventType": "{{string}}",
   "properties": { 
      "{{string}}" : "{{string}}" 
   },
   "quantity": "{{string}}",
   "scope": "{{string}}",
   "userId": "{{string}}"
}
```

## URI Request Parameters
<a name="API_GetEntitlementDecision_RequestParameters"></a>

The request uses the following URI parameters.

 ** [appId](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-uri-appId"></a>
The ID of the app.  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[A-Za-z0-9_-]+`   
Required: Yes

## Request Body
<a name="API_GetEntitlementDecision_RequestBody"></a>

The request accepts the following data in JSON format.

 ** [eventType](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-eventType"></a>
The type of action the user is attempting, used to determine the applicable plan capability and quota. Use the same event type you will send on the event.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[a-z][a-z0-9_.]{0,63}`   
Required: Yes

 ** [properties](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-properties"></a>
The same event properties you will send on the event. Each metric's filter is applied to them, and a summed or maxed field value is read from them. Omit them or send {} when the event has none; a metric that sums or maxes a property then rejects the check, as PutEvent rejects the event. Do not include personally identifiable or otherwise sensitive data in these values.  
Type: String to string map  
Map Entries: Minimum number of 0 items. Maximum number of 50 items.  
Key Length Constraints: Minimum length of 1. Maximum length of 64.  
Key Pattern: `[a-z][a-z0-9_.]*`   
Value Length Constraints: Minimum length of 0. Maximum length of 256.  
Required: No

 ** [quantity](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-quantity"></a>
The number of units the pending action will consume, as a non-negative decimal string (the same Quantity shape PutEvent uses). Send the real amount if known, otherwise your best upper estimate (for example a request's max tokens). Used when a metric counts events or sums or maxes the event quantity itself. The decision is DENY when usage already reached the limit, or when folding this event in would push it past (SUM and COUNT add the increment; MAX takes the larger of current usage and the increment).  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 22.  
Pattern: `(0|[1-9][0-9]{0,14})(\.[0-9]{1,6})?`   
Required: Yes

 ** [scope](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-scope"></a>
The environment of the app that this operation applies to. Specify live to use the live app, or sandbox to use the app's isolated test environment.  
Type: String  
Valid Values: `sandbox | live`   
Required: Yes

 ** [userId](#API_GetEntitlementDecision_RequestSyntax) **   <a name="appmonetization-GetEntitlementDecision-request-userId"></a>
An opaque identifier that you assign to an end user. Do not include personally identifiable or otherwise sensitive data in this value.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `[A-Za-z0-9_.~-]+`   
Required: Yes

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

```
HTTP/1.1 200
Content-type: application/json

{
   "decision": "string",
   "metrics": [ 
      { 
         "includedQuantity": number,
         "metricId": "string",
         "remainingQuantity": number,
         "usedQuantity": number
      }
   ],
   "planId": "string",
   "reason": { 
      "category": "string",
      "code": "string"
   }
}
```

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

 ** [decision](#API_GetEntitlementDecision_ResponseSyntax) **   <a name="appmonetization-GetEntitlementDecision-response-decision"></a>
The decision indicating whether the user may perform the action.  
Type: String  
Valid Values: `ALLOW | DENY` 

 ** [metrics](#API_GetEntitlementDecision_ResponseSyntax) **   <a name="appmonetization-GetEntitlementDecision-response-metrics"></a>
The per-metric quota status relevant to the decision.  
Type: Array of [EntitlementMetricStatus](API_EntitlementMetricStatus.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 50 items.

 ** [planId](#API_GetEntitlementDecision_ResponseSyntax) **   <a name="appmonetization-GetEntitlementDecision-response-planId"></a>
The ID of the plan the decision was evaluated against, when the user has a subscription.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[a-z0-9-]+` 

 ** [reason](#API_GetEntitlementDecision_ResponseSyntax) **   <a name="appmonetization-GetEntitlementDecision-response-reason"></a>
The reason behind the decision.  
Type: [EntitlementReason](API_EntitlementReason.md) object

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

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

 ** AccessDeniedException **   
The caller does not have sufficient permission to perform this action.    
 ** message **   
Human-readable description of the access-denied condition.
HTTP Status Code: 403

 ** InternalServerException **   
An unexpected error occurred while processing the request.    
 ** message **   
Human-readable description of the server error.  
 ** retryAfterSeconds **   
Advice to clients on when the call can be safely retried.
HTTP Status Code: 500

 ** ResourceNotFoundException **   
The referenced resource does not exist.    
 ** message **   
Human-readable description of the missing resource.  
 ** resourceId **   
Identifier of the resource that was not found.  
 ** resourceType **   
Type of the resource that was not found (for example, "App" or "Plan").
HTTP Status Code: 404

 ** ThrottlingException **   
The request was denied due to request throttling.    
 ** message **   
Human-readable description of the throttling condition.  
 ** quotaCode **   
Service Quotas identifier for the throttled quota.  
 ** retryAfterSeconds **   
Advice to clients on when the call can be safely retried.  
 ** serviceCode **   
Service Quotas identifier for the originating service.
HTTP Status Code: 429

 ** ValidationException **   
The request failed input validation.    
 ** fieldList **   
The specific input fields that failed validation, when applicable.  
 ** message **   
Human-readable description of what failed validation.  
 ** reason **   
Machine-readable reason the request failed validation, so callers act without parsing the message.
HTTP Status Code: 400

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