This tutorial presents a fictional scenario that guides you through configuring a rate table and setting up conditions and actions that determine whether a user is permitted to access a certain line item.
Your customer has purchased 200 tokens in a single line item with activation ID abc123. They want to allow access to the line item only if the requester is from the Engineering, Product Management, or Product Marketing departments. They also want to allocate 150 tokens to Engineering, and 50 tokens to Product Management and Product Marketing combined.
Nobody else should be able to consume tokens from this line item.
- Step 1: Check the line item
- Step 2: Set Up a Rate Table
- Step 3: Define Conditions
- Step 4: Create Actions Based on the Conditions
- Step 5: Verify the Setup
- Step 6: Check Enforcement of Allocations
- Optional: Retrieve Actions to Verify Token Consumption
- Optional: Further Exercise
- Optional: Clean Up
Call /v1.0/instances/{instanceId}/line-items
using GET to view the line item that your customer has purchased. Take a note of the activation ID and quantity in the response.
Further reading:
- Map a line item to an instance (API Reference).
- Get a list of line items (API Reference).
- Line Items (User Guide).
Authorization: administration token or client token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/provisioning/api/v1.0/instances/{instanceId}/line-items
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/provisioning/api/v1.0/instances/{instanceId}/line-items' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
Example Response
The response includes details about the line item. Note the activation ID abc123 and quantity of 200.
[
{
"activationId": "abc123",
"state": "DEPLOYED",
"start": 1695772800000,
"end": 1790467199999,
"quantity": 200,
"used": 0,
"attributes": {
"elastic": true,
"rateTableSeries": "1"
}
}
]
POST to /v1.0/rate-tables
to create a rate table. Ensure that the rate table has an item that can be requested by requesters.
Further reading:
- Creating a Rate Table (Tutorial).
- Create a rate table (API Reference).
- Rate Tables (User Guide).
Authorization: administration token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/provisioning/api/v1.0/rate-tables
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/provisioning/api/v1.0/rate-tables' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"effectiveFrom": 0,
"series": "string",
"version": "string",
"items": [
{
"name": "string",
"version": "string",
"rate": 0.1
}
]
}'
Create conditions that check:
- if the requester's
department
attribute is set toEngineering
. - if the requester's
department
attribute is set toProductManagement
orProductMarketing
.
The response will return two condition objects, each with a generated ID. Note the first ID associated with the Engineering
department, as it will be needed in the next step.
Further reading:
- Create conditions (API Reference).
- What Are Conditions (User Guide).
Authorization: administration token or client token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/api/v1.0/instances/{instanceId}/conditions
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/api/v1.0/instances/{instanceId}/conditions' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '[
{
"name": "compositeCondition",
"operator": "AND",
"conditions": [
{
"operator": "IN",
"property": "status",
"values": [
"active",
"pending"
]
},
{
"operator": "NOT",
"condition": {
"operator": "IN",
"property": "category",
"values": [
"restricted"
]
}
}
]
},
{
"name": "simpleCondition",
"operator": "IN",
"property": "category",
"values": [
"gold",
"silver"
]
}
]'
Request Body Example
[
{
"operator": "IN",
"property": "department",
"values": [
"Engineering"
]
},
{
"operator": "IN",
"property": "department",
"values": [
"ProductManagement",
"ProductMarketing"
]
}
]
Example Response
[
{
"operator": "IN",
"property": "department",
"values": [
"Engineering"
],
"id": "673cd8ee-d4d4-48ba-a4cc-235e61c96516"
},
{
"operator": "IN",
"property": "department",
"values": [
"ProductManagement",
"ProductMarketing"
],
"id": "8077bc18-c3f7-4d9d-a560-637d5b118d0b"
}
]
Now, define actions that use the conditions to allow access and allocate the tokens. Replace the conditionId
with the generated ID received in your conditions response.
Add a final condition that denies requests from anything not matching one of the conditions. This prevents tokens being consumed, which have been allocated to the two groups.
Further reading:
- Create conditions (API Reference).
- Create a list of actions and allocations for a line item (API Reference).
- What Are Conditions (User Guide).
Authorization: administration token or client token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '[
{
"name": "string",
"conditionId": "1e06e0eb-07f6-4fcd-8750-870cbafd1693",
"action": "ALLOW",
"allocation": 1000
}
]'
Request Body Example
[
{
"name": "Engineering allocation",
"conditionId": "673cd8ee-d4d4-48ba-a4cc-235e61c96516",
"action": "ALLOW",
"allocation": 100
},
{
"name": "PM & PMM allocation",
"conditionId": "8077bc18-c3f7-4d9d-a560-637d5b118d0b",
"action": "ALLOW",
"allocation": 150
},
{
"name": "default",
"conditionId": "",
"action":"DENY"
}
]
Response Example
[
{
"name": "Engineering allocation",
"conditionId": "673cd8ee-d4d4-48ba-a4cc-235e61c96516",
"action": "ALLOW",
"allocation": 100,
"id": "6e8d23b0-8e7c-4962-8963-74ef1de693e2"
},
{
"name": "PM & PMM allocation",
"conditionId": "8077bc18-c3f7-4d9d-a560-637d5b118d0b",
"action": "ALLOW",
"allocation": 150,
"id": "d8a9e55e-ad56-4b89-849f-c08eae92feb8"
},
{
"name": "default",
"conditionId": "",
"action":"DENY",
"id": "7fdf0258-3350-4d94-868f-f5c8e821a616"
}
]
Call /conditions and /actions to confirm everything is configured correctly.
Further reading:
- Create conditions (API Reference).
- Create a list of actions and allocations for a line item (API Reference).
- What Are Conditions (User Guide).
- What Are Actions (User Guide).
- How Actions and Conditions Work Together (User Guide).
Authorization: administration token or client token
API Call to Check Conditions
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/api/v1.0/instances/{instanceId}/conditions
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/api/v1.0/instances/{instanceId}/conditions' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
API Call to Check Actions
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
Verify that the item was successfully accessed. The response should indicate which action was used.
Further reading:
- Access request for elastic tokens (API Reference).
- Access Requests (User Guide).
Authorization: administration token or client token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/elastic/api/v1.0/instances/{instanceId}/access-request
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/elastic/api/v1.0/instances/{instanceId}/access-request' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"requester": {
"type": "string",
"value": "string"
},
"requestedItems": [
{
"item": "string",
"version": "string",
"count": 0.1,
"metaData": {}
}
]
}'
Request Body Example
{
"requester": {
"type": "user",
"value": "alice",
"dictionary": {"department":"engineering"}
},
"requestedItems": [
{
"item": "string",
"version": "string",
"count": 7,
"metaData": {}
}
]
}
Response Example
{
"correlationId": "f36d6ceb-7f83-4838-ae5a-933e6ced4e12",
"requester": {
"type": "user",
"value": "alice",",
"dictionary": {"department":"engineering"}
},
"requestedItems": [
{
"item": "string",
"version": "string",
"count": 7,
"status": {
"code": "101",
"description": "Successfully checked out"
},
"totalTokensCharged": 21,
"lineItems": [
{
"rate": 3.0,
"actionId": "6e8d23b0-8e7c-4962-8963-74ef1de693e2",
"activationId": "abc123",
"tokensCharged": 21
}
]
}
]
}
You can verify that the tokens were consumed from the line item by retrieving the actions again using /v1.0/instances/{instanceId}/line-items/{lineItemId}/actions
.
Further reading:
- Get actions and allocations for a line item (API Reference).
- Tokens (User Guide).
- What Are Actions (User Guide).
- How Actions and Conditions Work Together (User Guide).
Authorization: administration token or client token
API Call
- Dynamic Monetization API URL
https://siteID.flexnetoperations.com/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://{siteid}.flexnetoperations.{domainextension}/dynamicmonetization/api/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'
Response Example
[
{
"name": "Engineering allocation",
"conditionId": "673cd8ee-d4d4-48ba-a4cc-235e61c96516",
"action": "ALLOW",
"allocation": 100,
"id": "6e8d23b0-8e7c-4962-8963-74ef1de693e2",
"used": 21
},
{
"name": "PM & PMM allocation",
"conditionId": "8077bc18-c3f7-4d9d-a560-637d5b118d0b",
"action": "ALLOW",
"allocation": 150,
"id": "d8a9e55e-ad56-4b89-849f-c08eae92feb8"
},
{
"name": "default",
"conditionId": "",
"action":"DENY",
"id": "7fdf0258-3350-4d94-868f-f5c8e821a616"
}
]
As a further exercise, you could:
- Create a request that can access tokens by somebody from Product Management.
- Try a request by somebody from the Customer Success team, and check that it is denied.
To remove the configuration, use the following API calls:
Delete Actions:
DELETE/v1.0/instances/{instanceId}/line-items/{lineItemId}/actions
Delete Conditions:
DELETE/v1.0/instances/{instanceId}/conditions