Documentation Index Fetch the complete documentation index at: https://docs.ollie.shop/llms.txt
Use this file to discover all available pages before exploring further.
Response functions modify the output after Request functions complete. They run automatically and can enhance responses with analytics, security, personalization, and business logic.
When to Use
Add analytics tracking to all responses
Apply security headers and CORS policies
Insert personalized content and recommendations
Apply dynamic pricing and discounts
What They Do
Receive both request and response data
Modify response headers, body, and status
Add computed fields and enrichments
Transform data before sending to users
How Response Functions Work
Request function completes and generates initial response
Response function automatically triggered with request and response data
Function modifies response headers, body, or status as needed
Enhanced response sent to user with improvements
Response Function Examples
Analytics Tracking
Dynamic Discounts
Personalization
Add tracking pixels and analytics data to responses: Sample URL: https://hub.ollie.app/https://api.mystore.com/products/search?search=laptop
Original Response
Function Implementation
Standard Response
{
"products" : [
{
"id" : "prod_123" ,
"name" : "MacBook Pro" ,
"price" : 1899.99
}
]
}
π See Hub Enhancements
{
"products" : [
{
"id" : "prod_123" ,
"name" : "MacBook Pro" ,
"price" : 1899.99
}
],
"analytics" : {
"trackingId" : "sess_abc123def456" ,
"correlationId" : "corr_789xyz012" ,
"userSegment" : "premium" ,
"conversionFunnel" : "product_view" ,
"sessionStart" : "2024-01-12T10:25:30.456Z"
}
}
Enhanced Headers: Content-Type: application/json
X-Tracking-Id: sess_abc123def456 // [!code ++]
X-Request-Time: 2024-01-12T10:30:45.123Z // [!code ++]
X-User-Segment: premium // [!code ++]
X-Session-Duration: 315 // [!code ++]
What Ollie Hub adds:
β
Comprehensive user behavior tracking
β
Analytics data injection for BI tools
β
Request correlation for debugging
β
User segmentation for personalization
β
Conversion funnel tracking
β
Session analytics
Apply dynamic discounts based on user data: Sample URL: https://hub.ollie.app/https://api.mystore.com/cart
Original Response
Function Implementation
Standard Response
{
"cart" : {
"items" : [
{ "productId" : "prod_123" , "quantity" : 2 , "price" : 50.00 }
],
"total" : 100.00
}
}
π See Hub Enhancements
{
"cart" : {
"items" : [
{ "productId" : "prod_123" , "quantity" : 2 , "price" : 50.00 }
],
"total" : 85.00
},
"originalTotal" : 100.00 ,
"discountApplied" : {
"code" : "VIP15" ,
"description" : "VIP Customer 15% Discount" ,
"amount" : 15.00 ,
"type" : "percentage" ,
"reason" : "Customer tier: VIP (lifetime value: $2,150)" ,
"validUntil" : "2024-01-19T23:59:59Z"
},
"availableDiscounts" : [
{
"code" : "SAVE10" ,
"description" : "10% off your order" ,
"amount" : 10.00 ,
"type" : "percentage"
}
],
"savings" : {
"total" : 15.00 ,
"percentage" : 15
}
}
Enhanced Headers: Content-Type: application/json
X-Discount-Applied: true // [!code ++]
X-Customer-Tier: VIP // [!code ++]
X-Savings-Amount: 15.00 // [!code ++]
What Ollie Hub adds:
β
Intelligent discount detection based on customer data
β
Automatic application of best available discount
β
Customer tier recognition (VIP status)
β
Alternative discount options shown
β
Savings summary and expiration dates
β
Transparent pricing with original total
Add personalized recommendations and user-specific content: Sample URL: https://hub.ollie.app/https://api.mystore.com/dashboard
Original Response
Function Implementation
Standard Response
{
"products" : [
{
"id" : "prod_123" ,
"name" : "MacBook Pro" ,
"price" : 1899.99
}
]
}
π See Hub Enhancements
{
"products" : [
{
"id" : "prod_123" ,
"name" : "MacBook Pro" ,
"price" : 1899.99
}
],
"recommendations" : [
{
"id" : "prod_456" ,
"name" : "MacBook Air" ,
"price" : 1299.99 ,
"reason" : "Similar to your recent purchases"
}
],
"user" : {
"recentOrders" : [
{ "id" : "ord_789" , "total" : 299.99 , "date" : "2024-01-10" }
],
"wishlistCount" : 3 ,
"preferredCategories" : [ "electronics" , "accessories" ]
},
"userProfile" : {
"name" : "John" ,
"memberSince" : "2023-06-15T00:00:00Z" ,
"loyaltyPoints" : 1250
}
}
Enhanced Headers: Content-Type: application/json
X-Personalized: true // [!code ++]
X-User-Segment: premium // [!code ++]
Content-Language: en // [!code ++]
What Ollie Hub adds:
β
Product recommendations based on browsing history
β
User-specific dashboard content
β
Localization based on preferences
β
Loyalty program integration
β
Recent order history
β
Wishlist and preference tracking
Best Practices
Fail Gracefully Always return the original response if your enhancement fails. Donβt break the user experience.
Keep It Fast Response functions should be lightweight. Heavy processing can slow down responses.
Be Selective Not every response needs enhancement. Use conditional logic to enhance only when needed.
Log Errors Log enhancement errors for debugging, but donβt let them affect the userβs response.
Next Steps
Best Practices Implementation patterns for response enhancement
Request Functions Learn to handle incoming requests that trigger responses
Task Functions Automate workflows with scheduled functions
Pro Tip: Response functions are perfect for adding cross-cutting concerns like analytics, security, and personalization without modifying your core business logic. Check out our Best Practices guide for implementation patterns.