Product Rules
Product Rules define automated actions that occur when certain product events happen. For example, when a product is purchased, you can automatically add balance to the customer's wallet.
The Product Rule Object
id string
event enum
The event that triggers this rule. Currently supported events:
ProductPurchased- Triggered when a product is purchased
action enum
The action to perform when the event occurs. Currently supported actions:
AddBalance- Add balance to the customer's wallet
amount string
The amount of the balance to adjust based on the action
productId string
The ID of the product this rule is associated with
createdAt string
ISO 8601
Create a Product Rule
- TypeScript / JavaScript
let rule = await solidtx.productRules.create({
productId: 'product_01234567890abcdef',
event: 'ProductPurchased',
action: 'AddBalance',
amount: '1000',
balanceId: 'gems'
})
Parameters
productId stringRequired
The ID of the product to associate the rule with
event enumRequired
The event that triggers this rule
action enumRequired
The action to perform
amount decimalRequired
The amount for the action
balanceId stringRequired
The ID of the balance to affect
Returns
Returns the ProductRule object.
{
"id": "pr_01234567890abcdef",
"event": "ProductPurchased",
"action": "AddBalance",
"amount": "1000",
"balanceId": "gems",
"productId": "prod_01234567890abcdef",
"createdAt": "2025-05-21T14:00:00Z"
}
Delete a Product Rule
- TypeScript / JavaScript
let deletedRule = await solidtx.productRules.delete('product_rule_01234567890abcdef')
Parameters
productId stringRequired
The ID of the product to associate the rule with
Returns
Returns the ProductRule object you just deleted.
{
"id": "pr_01234567890abcdef"
}