Behavior When Tokens are Charged to Multiple Line Items
In some scenarios, a line item might not have enough tokens to cover the charges for the requested items. If other line items are available, the charges will be split across multiple line items. This behavior is the same for one-off access requests and session-based access requests. The order in which line items are charged depends on the line items’ expiration and start dates. Tokens are first charged to the line item with the earliest expiration date. If line items have identical expiration dates, the line item with the earliest start date is charged first.
If charges are split across multiple line items for a session-based access request and a refund needs to be made, charges are refunded to the same line items they were charged from.
Important:If multiple items are requested in a session, Elastic Access fulfills all the items, or none of the items. If it is only possible to fulfill some of the items then the entire request fails, and an error response is returned.
Splitting Charges for a One-Off Request Across Multiple Line Items
The following example illustrates how Elastic Access could charge tokens to multiple line items.
Assume that line items with the following activation IDs have been defined in the Producer Portal:
• | ACT01-Elastic, quantity: 10, expiration: April 17, 2034 |
• | ACT02-Elastic, quantity: 100, expiration: August 28, 2035 |
Example request for a GET call to the /line-items endpoint
[
{
"activationId": "ACT01-Elastic",
"instanceId": "fb1aba68-6af0-43df-a1a3-55f452cb86f0",
"start": 1694437412000,
"end": 1713355200000,
"quantity": 10,
"used": 0,
"attributes": {
"elastic": true,
"rateTableSeries": "PublicationApps"
}
},
{
"activationId": "ACT02-Elastic",
"instanceId": "fb1aba68-6af0-43df-a1a3-55f452cb86f0",
"start": 1694437412000,
"end": 1756382400000,
"quantity": 100,
"used": 0,
"attributes": {
"elastic": true,
"rateTableSeries": "PublicationApps"
}
}
]
The rate table specifies the following items:
• | PhotoPrint; rate: 3 |
• | CADPrint; rate: 7 |
Example request for a GET call to the /rate-tables endpoint to retrieve the active rate table:
[
{
"effectiveFrom": 1698849852000,
"created": 1699621714826,
"series": "PublicationApps",
"version": "1",
"items": [
{
"name": "PhotoPrint",
"rate": 3,
"version": "1.0"
},
{
"name": "CADPrint",
"rate": 7,
"version": "2.0"
}
]
}
]
The user LisaBarry requests two items:
• | 1 count of PhotoPrint, at a rate of 3 tokens per item (3 tokens in total) |
• | 8 counts of CADPrint, at a rate of 7 tokens per item (56 tokens in total) |
Example request for a POST call to the /access-request endpoint to request items:
{
"requester": {
"type": "user",
"value": "LisaBarry"
},
"requestedItems": [
{
"item": "PhotoPrint",
"requestedVersion": "1.0",
"count": 1
},
{
"item": "CADPrint",
"requestedVersion": "2.0",
"count": 8
}
]
}
Sample Response For Items Charged Across Multiple Line Items
The tokens for PhotoPrint (1 x 3 tokens = 3 tokens) are charged to the line item with activation ID ACT01-Elastic, because this line items has an earlier expiration date than ACT02-Elastic. The number of available tokens for ACT01-Elastic is reduced to 7 (10 - 3 = 7).
The number of tokens for CADPrint (8 x 7 tokens = 56 tokens) exceed the quantity that is now available in ACT01-Elastic (7 tokens). Therefore, 7 tokens are charged to ACT01-Elastic, and the remaining number of tokens is charged to activation ID ACT02-Elastic (49 tokens).
Example response to a POST call to the /access-request endpoint to request items:
{
"correlationId": "5c8ec4fd-f17f-4657-bf09-74a97ddc9f8b",
"requester": {
"type": "user",
"value": "LisaBarry"
},
"requestedItems": [
{
"item": "PhotoPrint",
"requestedVersion": "1.0",
"count": 1,
"status": {
"code": "101",
"description": "Successfully checked out"
},
"totalTokensCharged": 3,
"lineItems": [
{
"rate": 3,
"activationId": "ACT01-Elastic",
"tokensCharged": 3
}
]
},
{
"item": "CADPrint",
"requestedVersion": "2.0",
"count": 8,
"status": {
"code": "101",
"description": "Successfully checked out"
},
"totalTokensCharged": 56, #Total quantity charged for CADPrint across line items
"lineItems": [
{
"rate": 7,
"activationId": "ACT01-Elastic",
"tokensCharged": 7 #Quantity of ACT01-Elastic (10 counts) now used up
},
{
"rate": 7,
"activationId": "ACT02-Elastic",
"tokensCharged": 49 #Remaining tokens are charged to ACT02-Elastic
}
]
}
]
}
See also
Elastic Access Workflow When Using One-Off Requests