View a markdown version of this page

GetEntitlementDecision - AWS App Monetization

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

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

The request uses the following URI parameters.

appId

The ID of the app.

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

Pattern: [A-Za-z0-9_-]+

Required: Yes

Request Body

The request accepts the following data in JSON format.

eventType

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

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

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

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

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

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

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

The decision indicating whether the user may perform the action.

Type: String

Valid Values: ALLOW | DENY

metrics

The per-metric quota status relevant to the decision.

Type: Array of EntitlementMetricStatus objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

planId

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

The reason behind the decision.

Type: EntitlementReason object

Errors

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

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

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