API Examples
This section provides an example API request and response body of the Dynamic Offer Decision Engine API. See the Dynamic Offer Decision Engine section in Zephr Public API Specification for more information.
Example request body
curl --request POST \ --url 'https://my-domain.com/zephr/public/decisions/v1/dynamic-packages' \ --header 'Content-Type: application/json' \ --data '{ "dynamic_package": { "slug": "test", "inputs": {} }, "session": "9ba3a157-75f7-4cc1-a624-bf37c493725d", "ip": "192.56.134.20", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11)...", "path": "/article/123", "content_id": "cc06be74-88de-460f-9b46-535165c7d526" }'
Example response
{ "products": [ { "id": "zuora-product", "label": "Zuora Product", "description": "", "features": [], "sharingLimit": 0, "metadata": { "order": 1, "recommended": false }, "prices": [ { "ratePlanId": "8ad081c68a1ba509018a1d155ac057f1", "charges": [ { "discounts": [ { "items": [ { "order": 1, "type": "PERCENTAGE", "value": 10, "occurrence": "RECURRING", "startPolicy": { "type": "ON_CHARGE_START", "offset": null }, "endPolicy": { "type": "ON_CHARGE_START", "offset": null } } ], "orderType": "SEQUENTIAL" } ], "id": "8ad094088a1bce0b018a1d1719f63af8", "name": "Monthly Membership", "DemoPOB__c": null, "RighttoBill__c": null, "SalesOrg__c": null, "UnityTest__c": null, "AllocationEligible__c": null, "pricing": [ { "currency": "GBP", "price": 0.0, "productChargeDefinitionId": "8ad094088a1bce0b018a1d1719f63af8", "productChargeDefinitionNumber": "CD-00000387", "isDefault": true, "productRatePlanChargeId": "8ad094088a1bce0b018a1d1719f63af8", "productRatePlanChargeNumber": null, "productRatePlanId": null, "effectiveStartDate": "2023-08-22 00:00:00", "effectiveEndDate": "2027-08-22 00:00:00", "listPriceBase": "Per_Billing_Period", "specificListPriceBase": null, "billingPeriod": "Month", "billingPeriodAlignment": "AlignToCharge", "specificBillingPeriod": null, "billingTiming": "IN_ADVANCE", "ratingGroup": null, "taxable": false, "taxCode": "", "termPeriodType": null, "termType": null, "term": null, "chargeModel": "FlatFee", "defaultQuantity": 1.0, "applyDiscountTo": null, "discountLevel": null, "smoothingModel": null, "overageCalculationOption": null, "overageUnusedUnitsCreditOption": null, "usageRecordRatingOption": null, "endDateCondition": "Subscription_End", "upToPeriods": null, "upToPeriodsType": null, "triggerEvent": "ContractEffective", "revRecTriggerCondition": null, "revenueRecognitionRuleName": "Recognize upon invoicing", "useDiscountSpecificAccountingCode": null, "excludeItemBookingFromRevenueAccounting": false, "excludeItemBillingFromRevenueAccounting": false, "isStackedDiscount": false }, { "currency": "USD", "price": 0.0, "productChargeDefinitionId": "8ad094088a1bce0b018a1d1719f63af8", "productChargeDefinitionNumber": "CD-00000387", "isDefault": true, "productRatePlanChargeId": "8ad094088a1bce0b018a1d1719f63af8", "productRatePlanChargeNumber": null, "productRatePlanId": null, "effectiveStartDate": "2023-08-22 00:00:00", "effectiveEndDate": "2027-08-22 00:00:00", "listPriceBase": "Per_Billing_Period", "specificListPriceBase": null, "billingPeriod": "Month", "billingPeriodAlignment": "AlignToCharge", "specificBillingPeriod": null, "billingTiming": "IN_ADVANCE", "ratingGroup": null, "taxable": false, "taxCode": "", "termPeriodType": null, "termType": null, "term": null, "chargeModel": "FlatFee", "defaultQuantity": 1.0, "applyDiscountTo": null, "discountLevel": null, "smoothingModel": null, "overageCalculationOption": null, "overageUnusedUnitsCreditOption": null, "usageRecordRatingOption": null, "endDateCondition": "Subscription_End", "upToPeriods": null, "upToPeriodsType": null, "triggerEvent": "ContractEffective", "revRecTriggerCondition": null, "revenueRecognitionRuleName": "Recognize upon invoicing", "useDiscountSpecificAccountingCode": null, "excludeItemBookingFromRevenueAccounting": false, "excludeItemBillingFromRevenueAccounting": false, "isStackedDiscount": false } ] } ] } ], "properties": null } ] }
Example errors
The dynamic offer API will return an error for each errored property in the offer. For example, if a product couldn't be retrieved, an error will be returned inside the errors field in the response body. The properties without error will still be returned under the errors field.
{ "errors": [ { "property": "product", "error": "404: NOT_FOUND Product 'xbox-diamond' does not exist" }, { "property": "price", "error": "500: UNEXPECTED_UPSTREAM Failed to get OAuth token" } ], "products": [ { "id": "xbox-starter", "label": "Xbox Starter", "features": [ { "id": "streaming", "label": "streaming", "description": "" }, { "id": "riot", "label": "Riot Games", "description": "" } ] } ], "discounts": [ { "type": "PERCENTAGE", "value": 10 } ], "tagline": "Buy this cool subscription", "custom": { "image": "img-123", "some-json": { "key1": "value1" } } }