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
| Environment | Base URL |
|---|---|
| Staging | https://api.dev.myhubble.money |
| Production | https://api.myhubble.money |
Authentication
All API requests require authentication using a Bearer token obtained from the login API.
Required Headers:
| Header | Description | Required |
|---|---|---|
Authorization | Bearer token obtained from login API | Yes |
Content-Type | application/json (for PUT requests) | For PUT only |
X-Request-id | Unique request identifier for tracking | Recommended |
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:
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:
| Field | Type | Description |
|---|---|---|
brandId | string | Unique identifier for the brand |
brandKey | string | Brand key identifier |
defaultDiscount | number | Default discount percentage for the brand |
overridenDiscount | number | null | Custom override discount (null if no override exists) |
rewardType | string | Type 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:
| Parameter | Type | Description | Required |
|---|---|---|---|
brandKey | string | The brand key to update | Yes |
Request Body:
{ "discountPercentage": 7.50, "rewardType": "DISCOUNT"}Request Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
discountPercentage | number | Yes | Discount percentage (0-100) |
rewardType | string | Optional | Type of reward (“DISCOUNT”, “CASHBACK”, etc.) |
Validation Rules:
discountPercentagemust be between 0 and 100rewardTypeis optional (valid values: “DISCOUNT”, “CASHBACK”, etc.)
Request Example:
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:
| Parameter | Type | Description | Required |
|---|---|---|---|
brandKey | string | The brand key to reset | Yes |
Request Example:
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:
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
# 1. Get current configurationscurl --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 discountcurl --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 updatecurl --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 neededcurl --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:
# Increase Amazon discount from 5% to 10% for a promotioncurl --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:
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:
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-idvalues 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-tokenwith your actual Bearer token obtained from the login API - See the API Reference overview for details on authentication
Override vs Default
overridenDiscountbeingnullindicates no custom override exists- When
overridenDiscountisnull, thedefaultDiscountis 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.