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" : "just-console", "label" : "Game Pass 1", "description" : "", "features" : [ { "id" : "feature-1", "label" : "Feature 1 Play", "description" : "A library of top titles, exclusive rewards, and member-only content", "type" : "HTML" }, { "id" : "perks", "label" : "Perks", "description" : "Free Perks including in-game content and partner offers", "type" : "SDK" }, { "id" : "feature-3", "label" : "Plus", "description" : "A library of top titles, exclusive rewards, and member-only content", "type" : "HTML" } ], "sharingLimit" : 0, "metadata" : { "order" : 1, "recommended" : false }, "prices" : [ { "ratePlanId" : "8ad0938487b72f350187b913e4c76748", "charges" : [ { "productChargeId" : "8ad0938487b72f350187b914e440732b", "priceBookItems" : [ { "id" : "8ad09b2187c356740187dd00b6666553", "number" : "PBI-00001125", "productChargeId" : "8ad0938487b72f350187b914e440732b", "productRatePlanId" : "8ad0938487b72f350187b913e4c76748", "offerId" : null, "offerNumber" : null, "effectiveStartDate" : "2023-05-02", "effectiveEndDate" : "2027-04-19", "currency" : "USD", "defaultQuantity" : null, "listPriceBase" : "Per_Billing_Period", "includedUnits" : null, "price" : 5.0, "overagePrice" : null, "tiers" : null, "intervalPrices" : null, "BillingPeriod__c" : "Monthly", "Domain__c" : null, "StandalonePBI2__c" : null, "SalesOrg__c" : "B2B", "Vendor__c" : null, "CustomerSegment__c" : null, "SubscriptionTerm__c" : "12Month", "IsReseller__c" : null, "Region__c" : null } ], "discounts" : [ ] } ] } ] }, { "id" : "dynamic---2", "label" : "Game Pass 2", "description" : "", "features" : [ { "id" : "feature-1", "label" : "Feature 1 Play", "description" : "A library of top titles, exclusive rewards, and member-only content", "type" : "HTML" }, { "id" : "perks", "label" : "Perks", "description" : "Free Perks including in-game content and partner offers", "type" : "SDK" } ], "sharingLimit" : 0, "metadata" : { "order" : 2, "recommended" : false }, "prices" : [ { "ratePlanId" : "8ad096ca87b72f360187b91544bd4fca", "charges" : [ ] }, { "ratePlanId" : "8ad0938487b72f350187b913e4c76748", "charges" : [ { "productChargeId" : "8ad0938487b72f350187b914e440732b", "priceBookItems" : [ { "id" : "8ad09b2187c356740187dd00b6666553", "number" : "PBI-00001125", "productChargeId" : "8ad0938487b72f350187b914e440732b", "productRatePlanId" : "8ad0938487b72f350187b913e4c76748", "offerId" : null, "offerNumber" : null, "effectiveStartDate" : "2023-05-02", "effectiveEndDate" : "2027-04-19", "currency" : "USD", "defaultQuantity" : null, "listPriceBase" : "Per_Billing_Period", "includedUnits" : null, "price" : 5.0, "overagePrice" : null, "tiers" : null, "intervalPrices" : null, "BillingPeriod__c" : "Monthly", "Domain__c" : null, "StandalonePBI2__c" : null, "SalesOrg__c" : "B2B", "Vendor__c" : null, "CustomerSegment__c" : null, "SubscriptionTerm__c" : "12Month", "IsReseller__c" : null, "Region__c" : null } ], "discounts" : [ { "items" : [ { "order" : 1, "type" : "FIXED", "value" : 2, "occurrence" : "ONE_OFF", "startPolicy" : { "type" : "ON_CHARGE_START", "offset" : null }, "endPolicy" : { "type" : "BEFORE_CHARGE_END", "offset" : { "value" : 3, "unit" : "MONTH" } }, "frequency" : { "value" : 1, "unit" : "CHARGE_BILLING_PERIOD" } }, { "order" : 2, "type" : "PERCENTAGE", "value" : 20, "occurrence" : "RECURRING", "startPolicy" : { "type" : "ON_CHARGE_START", "offset" : null }, "endPolicy" : { "type" : "AFTER_CHARGE_START", "offset" : { "value" : 3, "unit" : "MONTH" } }, "frequency" : { "value" : 1, "unit" : "CHARGE_BILLING_PERIOD" } } ], "orderType" : "SEQUENTIAL" } ] } ] } ] } ], "tagline" : "Be in the game! Join now!", "custom" : { "background-image" : "bg-plus" } }
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" } } }