Skip to main content

API Examples

Zuora

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/v2/dynamic-offers' \
    --header 'Content-Type: application/json' \
    --data '{
    "dynamic_offer": {
        "slug": "test",
        "inputs": {}
    },
    "session": "2c51efe1-4b20-4f27-80aa-07fd8059581c",
    "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"
    "tracking_id": "7c32904d-459f-4e1c-9966-d8be1746acc8"
}'

Example response


{
  "products": [
    {
      "id": "digital",
      "label": "Digital",
      "description": "",
      "features": [
      ],
      "sharingLimit": 0,
      "metadata": {
        "order": 1
      },
      "paymentPlans": [
        {
          "planId": "ee61dac068f94b67d424d5db0af800db",
          "planData": {
            "description": "",
            "effectiveEndDate": "2026-02-05",
            "effectiveStartDate": "2025-02-05",
            "id": "ee61dac068f94b67d424d5db0af800db",
            "name": "Monthly with Discount",
            "productId": "8acce2719444cf0e01944692e4400e02",
            "productRatePlanNumber": "PRP-00000008"
          },
          "charges": [
            {
              "chargeId": "ee61dac067f94b67d424d5dbc9c000a2",
              "prices": [
                {
                  "active": true,
                  "currency": "USD",
                  "discountAmount": null,
                  "discountPercentage": null,
                  "endingUnit": null,
                  "includedUnits": 0.0,
                  "overagePrice": null,
                  "price": 5.0,
                  "priceFormat": null,
                  "startingUnit": null,
                  "tier": 1,
                  "isDefault": true
                }
              ],
              "chargeData": {
                "accountReceivableAccountingCodeId": "8a28a13d93d3cbd00193d40be7b806b3",
                "accountingCode": "Subscription Revenue",
                "applyToBillingPeriodPartially": false,
                "billCycleType": "DefaultFromCustomer",
                "billingPeriod": "Month",
                "billingPeriodAlignment": "AlignToCharge",
                "billingTiming": "In Advance",
                "chargeModel": "Flat Fee Pricing",
                "chargeType": "Recurring",
                "defaultQuantity": 1.0,
                "deferredRevenueAccount": "Subscription Revenue",
                "deferredRevenueAccountingCodeId": "8a28a13d93d3cbd00193d40be7f306b9",
                "description": "",
                "endDateCondition": "SubscriptionEnd",
                "excludeItemBillingFromRevenueAccounting": false,
                "excludeItemBookingFromRevenueAccounting": false,
                "id": "ee61dac067f94b67d424d5dbc9c000a2",
                "includedUnits": 0.0,
                "isAllocationEligible": false,
                "isCommitted": false,
                "isPrepaid": false,
                "isRollover": false,
                "isStackedDiscount": false,
                "isUnbilled": false,
                "legacyRevenueReporting": false,
                "listPriceBase": "Per Billing Period",
                "name": "Recurring Fee",
                "numberOfPeriod": 1,
                "overageCalculationOption": "EndOfSmoothingPeriod",
                "overageUnusedUnitsCreditOption": "NoCredit",
                "priceChangeOption": "NoChange",
                "priceIncreasePercentage": 0.0,
                "priceUpsellQuantityStacked": false,
                "productRatePlanChargeNumber": "PRPC-00000010",
                "productRatePlanId": "ee61dac068f94b67d424d5db0af800db",
                "recognizedRevenueAccount": "Subscription Revenue",
                "recognizedRevenueAccountingCodeId": "8a28a13d93d3cbd00193d40be7f306b9",
                "revenueRecognitionRuleName": "Recognize upon invoicing",
                "rolloverApply": "ApplyLast",
                "rolloverPeriodLength": 0,
                "rolloverPeriods": 0,
                "taxCode": "",
                "taxable": false,
                "triggerEvent": "ContractEffective",
                "upToPeriodsType": "Billing Periods",
                "useTenantDefaultForPriceChange": true
              },
              "chargeDefinitionData": {
                "effectiveEndDate": "2026-02-05T00:00:00Z",
                "overageUnusedUnitsCreditOption": "NoCredit",
                "productRatePlanChargeId": "ee61dac067f94b67d424d5dbc9c000a2",
                "excludeItemBillingFromRevenueAccounting": false,
                "productChargeDefinitionId": "ee61dac067f94b67d424d5dbc9c000a2",
                "legacyRevenueReporting": false,
                "overageCalculationOption": "EndOfSmoothingPeriod",
                "description": "",
                "isUnbilled": false,
                "isPrepaid": false,
                "rolloverPeriodLength": 0,
                "priceChangeOption": "NoChange",
                "effectiveStartDate": "2025-02-05T00:00:00Z",
                "isRollover": false,
                "upToPeriodsType": "Billing Periods",
                "revenueRecognitionRuleName": "Recognize upon invoicing",
                "listPriceBase": "Per Billing Period",
                "isStackedDiscount": false,
                "accountingCode": "Subscription Revenue",
                "productChargeDefinitionNumber": "CD-00000020",
                "rolloverPeriods": 0,
                "taxable": false,
                "billingPeriod": "Month",
                "excludeItemBookingFromRevenueAccounting": false,
                "billCycleType": "DefaultFromCustomer",
                "applyToBillingPeriodPartially": false,
                "billingTiming": "In Advance",
                "productChargeId": "ee61dac067f94b67d424d5dbc9c000a2",
                "priceIncreasePercentage": 0.0,
                "billingPeriodAlignment": "AlignToCharge",
                "productRatePlanChargeNumber": "PRPC-00000010",
                "defaultQuantity": 1.0,
                "taxCode": "",
                "isCommitted": false,
                "rolloverApply": "ApplyLast",
                "useTenantDefaultForPriceChange": true,
                "chargeModel": "Flat Fee Pricing",
                "numberOfPeriod": 1,
                "endDateCondition": "SubscriptionEnd",
                "priceUpsellQuantityStacked": false,
                "triggerEvent": "ContractEffective",
                "isAllocationEligible": false
              },
              "discounts": [
              ]
            },
            {
              "chargeId": "ee61dac069a94b67d424d5dcca080009",
              "prices": [
                {
                  "active": true,
                  "currency": "USD",
                  "discountAmount": null,
                  "discountPercentage": 50.0,
                  "endingUnit": null,
                  "includedUnits": 0.0,
                  "overagePrice": null,
                  "price": null,
                  "priceFormat": null,
                  "startingUnit": null,
                  "tier": 1,
                  "isDefault": true
                }
              ],
              "chargeData": {
                "applyDiscountTo": "RECURRING",
                "applyToBillingPeriodPartially": false,
                "billCycleType": "DefaultFromCustomer",
                "billingPeriod": "Month",
                "billingPeriodAlignment": "AlignToCharge",
                "chargeModel": "Discount-Percentage",
                "chargeType": "Recurring",
                "defaultQuantity": 0.0,
                "description": "",
                "discountLevel": "rateplan",
                "endDateCondition": "FixedPeriod",
                "excludeItemBillingFromRevenueAccounting": false,
                "excludeItemBookingFromRevenueAccounting": false,
                "id": "ee61dac069a94b67d424d5dcca080009",
                "includedUnits": 0.0,
                "isAllocationEligible": false,
                "isCommitted": false,
                "isPrepaid": false,
                "isRollover": false,
                "isStackedDiscount": false,
                "isUnbilled": false,
                "legacyRevenueReporting": false,
                "listPriceBase": "Per Billing Period",
                "name": "discount",
                "numberOfPeriod": 1,
                "overageCalculationOption": "EndOfSmoothingPeriod",
                "overageUnusedUnitsCreditOption": "NoCredit",
                "priceChangeOption": "NoChange",
                "priceIncreasePercentage": 0.0,
                "priceUpsellQuantityStacked": false,
                "productRatePlanChargeNumber": "PRPC-00000011",
                "productRatePlanId": "ee61dac068f94b67d424d5db0af800db",
                "rolloverApply": "ApplyLast",
                "rolloverPeriodLength": 0,
                "rolloverPeriods": 0,
                "taxable": false,
                "triggerEvent": "ContractEffective",
                "upToPeriods": 1,
                "upToPeriodsType": "Billing Periods",
                "useDiscountSpecificAccountingCode": false,
                "useTenantDefaultForPriceChange": false
              },
              "chargeDefinitionData": {
                "effectiveEndDate": "2026-02-05T00:00:00Z",
                "overageUnusedUnitsCreditOption": "NoCredit",
                "productRatePlanChargeId": "ee61dac069a94b67d424d5dcca080009",
                "discountLevel": "rateplan",
                "excludeItemBillingFromRevenueAccounting": false,
                "productChargeDefinitionId": "ee61dac069a94b67d424d5dcca080009",
                "legacyRevenueReporting": false,
                "overageCalculationOption": "EndOfSmoothingPeriod",
                "description": "",
                "isUnbilled": false,
                "useDiscountSpecificAccountingCode": false,
                "isPrepaid": false,
                "rolloverPeriodLength": 0,
                "priceChangeOption": "NoChange",
                "effectiveStartDate": "2025-02-05T00:00:00Z",
                "isRollover": false,
                "upToPeriodsType": "Billing Periods",
                "listPriceBase": "Per Billing Period",
                "isStackedDiscount": false,
                "productChargeDefinitionNumber": "CD-00000021",
                "rolloverPeriods": 0,
                "taxable": false,
                "billingPeriod": "Month",
                "excludeItemBookingFromRevenueAccounting": false,
                "billCycleType": "DefaultFromCustomer",
                "applyToBillingPeriodPartially": false,
                "productChargeId": "ee61dac069a94b67d424d5dcca080009",
                "priceIncreasePercentage": 0.0,
                "billingPeriodAlignment": "AlignToCharge",
                "productRatePlanChargeNumber": "PRPC-00000011",
                "defaultQuantity": 0.0,
                "isCommitted": false,
                "rolloverApply": "ApplyLast",
                "useTenantDefaultForPriceChange": false,
                "applyDiscountTo": "RECURRING",
                "chargeModel": "Discount-Percentage",
                "numberOfPeriod": 1,
                "endDateCondition": "FixedPeriod",
                "priceUpsellQuantityStacked": false,
                "triggerEvent": "ContractEffective",
                "isAllocationEligible": false,
                "upToPeriods": 1
              },
              "discounts": [
              ]
            }
          ]
        }
      ]
    }
  ]
}

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"
      }
    }
  }