Skip to content

Discount Management API

Manage custom brand discount configurations and override default discounts.

Overview

The Discount Management API allows you to manage custom brand discount configurations. These APIs enable you to override default brand discounts, retrieve current configurations, and reset customizations.

Base URLs

EnvironmentBase URL
Staginghttps://api.dev.myhubble.money
Productionhttps://api.myhubble.money

Authentication

All API requests require authentication using a Bearer token obtained from the login API.

Required Headers:

HeaderDescriptionRequired
AuthorizationBearer token obtained from login APIYes
Content-Typeapplication/json (for PUT requests)For PUT only
X-Request-idUnique request identifier for trackingRecommended

See the API Reference overview for details on obtaining your access token.

API Endpoints

1. Get Brand Discounts Configuration

Retrieves all brand discount configurations for the authenticated partner, including both default and overridden discounts.

HTTP Method: GET

Endpoint: /v1/partners/discount-override/config/brand-discounts

Request Example:

Terminal window
curl --location 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discounts' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: get-discounts-$(date +%s)'

Response Example:

Status Code: 200 OK

[
{
"brandId": "amazon-001",
"brandKey": "amazon",
"defaultDiscount": 5.00,
"overridenDiscount": 7.50,
"rewardType": "DISCOUNT"
},
{
"brandId": "flipkart-002",
"brandKey": "flipkart",
"defaultDiscount": 3.00,
"overridenDiscount": null,
"rewardType": "CASHBACK"
}
]

Response Fields:

FieldTypeDescription
brandIdstringUnique identifier for the brand
brandKeystringBrand key identifier
defaultDiscountnumberDefault discount percentage for the brand
overridenDiscountnumber | nullCustom override discount (null if no override exists)
rewardTypestringType of reward (e.g., “DISCOUNT”, “CASHBACK”)

2. Update Brand Discount Configuration

Updates or creates a custom discount override for a specific brand.

HTTP Method: PUT

Endpoint: /v1/partners/discount-override/config/brand-discount/{brandKey}

Path Parameters:

ParameterTypeDescriptionRequired
brandKeystringThe brand key to updateYes

Request Body:

{
"discountPercentage": 7.50,
"rewardType": "DISCOUNT"
}

Request Parameters:

FieldTypeRequiredDescription
discountPercentagenumberYesDiscount percentage (0-100)
rewardTypestringOptionalType of reward (“DISCOUNT”, “CASHBACK”, etc.)

Validation Rules:

  • discountPercentage must be between 0 and 100
  • rewardType is optional (valid values: “DISCOUNT”, “CASHBACK”, etc.)

Request Example:

Terminal window
curl --location --request PUT 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discount/amazon' \
--header 'Authorization: Bearer your-access-token' \
--header 'Content-Type: application/json' \
--header 'X-Request-id: update-discount-$(date +%s)' \
--data '{
"discountPercentage": 7.50,
"rewardType": "DISCOUNT"
}'

Response Example:

Status Code: 200 OK

{
"brandKey": "amazon",
"discountPercentage": 7.50
}

3. Reset Brand Discount Configuration

Resets a brand’s discount configuration to its default value by removing any custom overrides.

HTTP Method: POST

Endpoint: /v1/partners/discount-override/config/brand-discount/{brandKey}/reset

Path Parameters:

ParameterTypeDescriptionRequired
brandKeystringThe brand key to resetYes

Request Example:

Terminal window
curl --location --request POST 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discount/amazon/reset' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: reset-discount-$(date +%s)'

Response:

Status Code: 204 No Content

Body: Empty


4. Reset All Brand Discount Configurations

Resets all brand discount configurations to their default values by removing all custom overrides for the partner.

HTTP Method: POST

Endpoint: /v1/partners/discount-override/config/brand-discounts/reset

Request Example:

Terminal window
curl --location --request POST 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discounts/reset' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: reset-all-discounts-$(date +%s)'

Response:

Status Code: 204 No Content

Body: Empty


Error Responses

All APIs may return the following error responses:

400 Bad Request

{
"error": "INVALID_INPUT",
"message": "Discount percentage must be between 0 and 100",
"requestId": "your-request-id"
}

401 Unauthorized

{
"error": "UNAUTHORIZED",
"message": "Invalid client credentials",
"requestId": "your-request-id"
}

404 Not Found

{
"error": "BRAND_NOT_FOUND",
"message": "Brand with key 'invalid-brand' not found",
"requestId": "your-request-id"
}

500 Internal Server Error

{
"error": "INTERNAL_ERROR",
"message": "An internal server error occurred",
"requestId": "your-request-id"
}

Usage Examples

Complete Workflow Example

Terminal window
# 1. Get current configurations
curl --location 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discounts' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: workflow-step1-$(date +%s)'
# 2. Update a brand discount
curl --location --request PUT 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discount/amazon' \
--header 'Authorization: Bearer your-access-token' \
--header 'Content-Type: application/json' \
--header 'X-Request-id: workflow-step2-$(date +%s)' \
--data '{
"discountPercentage": 8.00,
"rewardType": "DISCOUNT"
}'
# 3. Verify the update
curl --location 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discounts' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: workflow-step3-$(date +%s)'
# 4. Reset if needed
curl --location --request POST 'https://api.dev.myhubble.money/v1/partners/discount-override/config/brand-discount/amazon/reset' \
--header 'Authorization: Bearer your-access-token' \
--header 'X-Request-id: workflow-step4-$(date +%s)'

Common Use Cases

Use Case 1: Setting Promotional Discounts

Override the default discount for specific brands during a promotional campaign:

Terminal window
# Increase Amazon discount from 5% to 10% for a promotion
curl --location --request PUT 'https://api.myhubble.money/v1/partners/discount-override/config/brand-discount/amazon' \
--header 'Authorization: Bearer your-access-token' \
--header 'Content-Type: application/json' \
--data '{
"discountPercentage": 10.00,
"rewardType": "DISCOUNT"
}'

Use Case 2: Auditing Current Discounts

Retrieve all brand discount configurations to audit your current setup:

Terminal window
curl --location 'https://api.myhubble.money/v1/partners/discount-override/config/brand-discounts' \
--header 'Authorization: Bearer your-access-token'

Use Case 3: Resetting After a Campaign

Reset all brand discounts to default values after a promotional period ends:

Terminal window
curl --location --request POST 'https://api.myhubble.money/v1/partners/discount-override/config/brand-discounts/reset' \
--header 'Authorization: Bearer your-access-token'

Important Notes

Request ID Tracking

  • Use unique X-Request-id values for tracking and debugging
  • The $(date +%s) generates a Unix timestamp for unique request IDs
  • Request IDs are returned in error responses for troubleshooting

Discount Values

  • All discount percentages are decimal values (e.g., 7.50 for 7.5%)
  • Changes take effect immediately after successful API calls
  • Overridden discounts persist until explicitly reset

Authentication

  • Replace your-access-token with your actual Bearer token obtained from the login API
  • See the API Reference overview for details on authentication

Override vs Default

  • overridenDiscount being null indicates no custom override exists
  • When overridenDiscount is null, the defaultDiscount is used
  • Resetting removes the override and reverts to defaultDiscount

Troubleshooting

Error: “Discount percentage must be between 0 and 100”

Problem: The discount percentage in your request is out of valid range.

Solution: Ensure the discountPercentage value is between 0 and 100.

Error: “Invalid authentication credentials”

Problem: The Bearer token is incorrect, expired, or missing.

Solution: Verify your access token is valid and not expired. Obtain a new token using the login API if needed.

Error: “Brand with key ‘X’ not found”

Problem: The specified brand key doesn’t exist or isn’t available to your account.

Solution: Use the GET endpoint to retrieve available brands and verify the brand key is correct.

Changes Not Reflected Immediately

Problem: Updates to discounts don’t appear to take effect.

Solution: While changes are applied immediately, cached data in the SDK may take a few minutes to refresh. Try clearing the app cache or waiting a few minutes before testing.