{"openapi":"3.0.0","info":{"title":"mazeed+ Placements API","description":"Request personalized content and offers for your users based on context and behavior","version":"1.0.0","contact":{"name":"mazeed+ Support","email":"support@mazeedplus.com"}},"servers":[{"url":"https://api.mazeedplus.com","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"tags":[{"name":"Placements","description":"Personalized content and offers API"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-publishable-api-key","description":"API key for authentication. Get your API key from the mazeed+ dashboard."}},"schemas":{"ProductEntity":{"type":"object","properties":{"object":{"type":"string","enum":["product"]},"id":{"type":"string","description":"Unique identifier for the entity","example":"ent_abc123"},"title":{"type":"string","description":"Product title","example":"Wireless Headphones"},"description":{"type":"string","description":"Product description","example":"High-quality wireless headphones with noise cancellation"},"price":{"type":"object","properties":{"amount":{"type":"number","description":"Price amount in the smallest currency unit (e.g., cents)","example":9999},"currency":{"type":"string","description":"ISO 4217 currency code","example":"SAR"}},"required":["amount","currency"]},"comparePrice":{"type":"object","properties":{"amount":{"type":"number","description":"Price amount in the smallest currency unit (e.g., cents)","example":9999},"currency":{"type":"string","description":"ISO 4217 currency code","example":"SAR"}},"required":["amount","currency"],"description":"Original price before discount (for strike-through display)"},"media":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["primary","secondary"],"description":"Role of the media item","example":"primary"},"uri":{"type":"string","format":"uri","description":"URL of the media asset","example":"https://cdn.example.com/image.jpg"},"content_type":{"type":"string","description":"MIME type of the media","example":"image/jpeg"}},"required":["role","uri","content_type"]},"description":"Product images and videos"},"click_url":{"type":"string","format":"uri","description":"URL to the product page","example":"https://shop.example.com/products/wireless-headphones"},"tracking":{"type":"object","properties":{"impid":{"type":"string","description":"Impression ID for tracking","example":"imp_abc123"},"click_url":{"type":"string","format":"uri","description":"URL to track clicks","example":"https://tracking.example.com/click/abc123"}},"required":["impid","click_url"],"description":"Tracking information for analytics"},"loyalty":{"type":"object","properties":{"points":{"type":"number","description":"Publisher-specific loyalty points value","example":120},"points_per_sar":{"type":"number","description":"Configured conversion rate from SAR to points","example":1}},"required":["points","points_per_sar"],"description":"Loyalty metadata (only present for configured publishers)"}},"required":["object","id","title","price"]},"CollectionEntity":{"type":"object","properties":{"object":{"type":"string","enum":["collection"]},"id":{"type":"string","description":"Unique identifier for the entity","example":"ent_abc123"},"name":{"type":"string","description":"Collection name","example":"Summer Sale"},"description":{"type":"string","description":"Collection description","example":"Hot deals for the summer season"},"items":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","description":"Reference to another entity ID","example":"ent_prod123"}},"required":["ref"]},"description":"Items in the collection"},"media":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["primary","secondary"],"description":"Role of the media item","example":"primary"},"uri":{"type":"string","format":"uri","description":"URL of the media asset","example":"https://cdn.example.com/image.jpg"},"content_type":{"type":"string","description":"MIME type of the media","example":"image/jpeg"}},"required":["role","uri","content_type"]},"description":"Collection images"}},"required":["object","id","name","items"]},"OfferEntity":{"type":"object","properties":{"object":{"type":"string","enum":["offer"]},"id":{"type":"string","description":"Unique identifier for the entity","example":"ent_abc123"},"title":{"type":"string","description":"Offer title","example":"Buy 2 Get 20% Off"},"description":{"type":"string","description":"Offer description","example":"Purchase any 2 items from our summer collection and save 20%"},"payload":{"type":"object","properties":{"kind":{"type":"string","enum":["collection_with_incentive","product_bundle","standalone_incentive"],"description":"Type of offer payload","example":"collection_with_incentive"},"collection":{"type":"object","properties":{"ref":{"type":"string","description":"Reference to collection entity","example":"ent_col123"}},"required":["ref"]},"incentive":{"type":"object","properties":{"ref":{"type":"string","description":"Reference to incentive entity","example":"ent_inc123"}},"required":["ref"]},"products":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","description":"Reference to product entity","example":"ent_prod123"}},"required":["ref"]}}},"required":["kind"],"description":"Offer payload details"},"actions":{"type":"array","items":{"type":"object","properties":{"intent":{"type":"string","enum":["VIEW_COLLECTION","VIEW_PRODUCT","APPLY_INCENTIVE","ADD_TO_CART"],"description":"Action intent","example":"VIEW_COLLECTION"},"target":{"type":"object","properties":{"collection_id":{"type":"string"},"product_id":{"type":"string"},"incentive_id":{"type":"string"},"url":{"type":"string","format":"uri"}},"description":"Action target details"}},"required":["intent","target"]},"description":"Available actions for this offer"},"media":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["primary","secondary"],"description":"Role of the media item","example":"primary"},"uri":{"type":"string","format":"uri","description":"URL of the media asset","example":"https://cdn.example.com/image.jpg"},"content_type":{"type":"string","description":"MIME type of the media","example":"image/jpeg"}},"required":["role","uri","content_type"]},"description":"Offer images"}},"required":["object","id","title","payload","actions"]},"CreativeEntity":{"type":"object","properties":{"object":{"type":"string","enum":["creative"]},"id":{"type":"string","description":"Unique identifier for the entity","example":"ent_abc123"},"title":{"type":"string","description":"Creative title","example":"Shop Now Banner"},"copy":{"type":"string","description":"Creative copy text","example":"Limited time offer - Don't miss out!"},"cta":{"type":"string","description":"Call-to-action text","example":"Shop Now"},"image_url":{"type":"string","format":"uri","description":"URL of the creative image","example":"https://cdn.example.com/banner.jpg"},"video_url":{"type":"string","format":"uri","description":"URL of the creative video","example":"https://cdn.example.com/video.mp4"},"click_url":{"type":"string","format":"uri","description":"Destination URL when clicked","example":"https://shop.example.com/sale"},"tracking":{"type":"object","properties":{"impid":{"type":"string","description":"Impression ID for tracking","example":"imp_abc123"},"click_url":{"type":"string","format":"uri","description":"URL to track clicks","example":"https://tracking.example.com/click/abc123"}},"required":["impid","click_url"],"description":"Tracking information for analytics"}},"required":["object","id","title","cta","click_url"]},"Entity":{"oneOf":[{"$ref":"#/components/schemas/ProductEntity"},{"$ref":"#/components/schemas/CollectionEntity"},{"$ref":"#/components/schemas/OfferEntity"},{"$ref":"#/components/schemas/CreativeEntity"}],"discriminator":{"propertyName":"object","mapping":{"product":"#/components/schemas/ProductEntity","collection":"#/components/schemas/CollectionEntity","offer":"#/components/schemas/OfferEntity","creative":"#/components/schemas/CreativeEntity"}}},"TemplateData":{"type":"object","properties":{"version":{"type":"string","description":"Template data version","example":"1.0"},"entities":{"type":"array","items":{"$ref":"#/components/schemas/Entity"},"description":"Array of content entities (products, collections, offers, creatives)"}},"required":["version","entities"]},"PlacementResponse":{"type":"object","properties":{"identifier":{"type":"string","description":"Unique identifier for this placement","example":"checkout_success"},"templateName":{"type":"string","description":"Name of the template used for rendering","example":"Product Listing"},"html":{"type":"string","description":"Rendered HTML content for iframe embedding (optional, excluded when not requested)","example":"<div class=\"placement\">...</div>"},"css":{"type":"string","description":"Stylesheet for the content (optional, excluded when not requested)","example":".placement { background: #fff; }"},"template_data":{"allOf":[{"$ref":"#/components/schemas/TemplateData"},{"description":"Structured data for native rendering"}]},"rendered_at":{"type":"string","format":"date-time","description":"ISO timestamp of when the placement was rendered","example":"2024-01-15T10:30:00.000Z"}},"required":["identifier","templateName","template_data","rendered_at"]},"ValidationError":{"type":"object","properties":{"error":{"type":"string","example":"Validation failed"},"error_code":{"type":"string","example":"VALIDATION_ERROR"},"message":{"type":"string","example":"Invalid request data"},"details":{"nullable":true,"description":"Detailed validation errors from Zod"}},"required":["error","error_code","message"]},"NotFoundError":{"type":"object","properties":{"error":{"type":"string","example":"Placement not found"},"error_code":{"type":"string","example":"PLACEMENT_NOT_FOUND"},"message":{"type":"string","example":"No placement found with identifier: non-existent-placement"}},"required":["error","error_code","message"]},"ProcessingError":{"type":"object","properties":{"error":{"type":"string","example":"Processing failed"},"message":{"type":"string","example":"Failed to process placement: Internal server error"},"identifier":{"type":"string","example":"checkout_success"}},"required":["error","message"]},"SelectPlacementRequest":{"type":"object","properties":{"attributes":{"type":"object","properties":{"userId":{"type":"string","minLength":1},"mobile":{"type":"string","pattern":"^\\+[1-9]\\d{7,14}$"},"email":{"type":"string","format":"email"},"firstname":{"type":"string"},"lastname":{"type":"string"},"confirmationref":{"type":"string"},"billingzipcode":{"type":"string"},"amount":{"type":"string"},"paymenttype":{"type":"string"},"ccbin":{"type":"string"},"country":{"type":"string"},"language":{"type":"string"},"currency":{"type":"string"},"billingaddress1":{"type":"string"},"billingaddress2":{"type":"string"},"age":{"type":"number"},"gender":{"type":"string","enum":["male","female"]},"interests":{"type":"array","items":{"type":"string"}},"cartItems":{"type":"string"},"shippingtype":{"type":"string"},"productIds":{"type":"string"},"q":{"type":"string"}},"required":["userId"],"additionalProperties":{"nullable":true}},"identifier":{"type":"string","minLength":1},"enableWebview":{"type":"boolean","default":true},"filters":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"string"}}}}},"required":["attributes","identifier"]}},"parameters":{}},"paths":{"/select-placement":{"post":{"summary":"Create a personalized placement","description":"Returns personalized content and offers based on user context and behavior. Use this API to display targeted promotions, product recommendations, and custom offers at key moments in your user journey.","operationId":"selectPlacement","tags":["Placements"],"security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SelectPlacementRequest"},"examples":{"home_page":{"summary":"Home page placement","value":{"identifier":"home-page","attributes":{"userId":"user_987654321","mobile":"+971501234567","currency":"aed","country":"ae","language":"en"}}}}}}},"responses":{"200":{"description":"Successful placement response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlacementResponse"},"example":{"identifier":"checkout_success","templateName":"Product Listing","html":"<div class=\"placement\"><div class=\"product-grid\">...</div></div>","css":".placement { background: #fff; padding: 20px; } .product-grid { display: grid; }","template_data":{"version":"1.0","entities":[{"object":"collection","id":"col_featured","name":"Featured Products","items":[{"ref":"prod_1234"},{"ref":"prod_5678"},{"ref":"prod_9012"}]},{"object":"product","id":"prod_1234","title":"Wireless Headphones","description":"High-quality wireless headphones with noise cancellation","price":{"amount":8999,"currency":"usd"},"compare_price":{"amount":12999,"currency":"usd"},"media":[{"role":"primary","uri":"https://example.com/headphones.jpg","content_type":"image/jpeg"}],"brand":"Sony","category":"Electronics","click_url":"https://checkout.mazeedplus.com/p/prod_1234","rating":{"average":4.5,"count":128}},{"object":"incentive","id":"inc_abc123","kind":"free_shipping","value":{"amount":0,"currency":"usd"},"title":"Free Shipping","description":"Free shipping on orders over $50"},{"object":"creative","id":"cre_xyz789","title":"Special Offer","content":"Get 20% off your next purchase!","media":[{"role":"primary","uri":"https://example.com/banner.jpg","content_type":"image/jpeg"}],"cta":{"text":"Shop Now","click_url":"https://checkout.mazeedplus.com"}}]},"rendered_at":"2024-01-15T10:30:00.000Z"}}}},"400":{"description":"Validation error or invalid configuration","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"},"examples":{"missing_identifier":{"summary":"Missing required identifier field","value":{"error":"Validation failed","error_code":"VALIDATION_ERROR","message":"Invalid request data","details":{"_errors":[],"identifier":{"_errors":["Required"]}}}},"missing_userId":{"summary":"Missing required userId in attributes","value":{"error":"Validation failed","error_code":"VALIDATION_ERROR","message":"Invalid request data","details":{"_errors":[],"attributes":{"_errors":[],"userId":{"_errors":["User ID is required"]}}}}},"invalid_mobile":{"summary":"Invalid mobile number format","value":{"error":"Validation failed","error_code":"VALIDATION_ERROR","message":"Invalid request data","details":{"_errors":[],"attributes":{"_errors":[],"mobile":{"_errors":["Mobile number must include country code with + prefix (e.g., +966501234567)"]}}}}},"invalid_configuration":{"summary":"Placement has invalid configuration","value":{"error":"Invalid placement configuration","message":"Placement checkout_success has no template assignment policy configured"}}}}}},"404":{"description":"Placement not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundError"},"example":{"error":"Placement not found","error_code":"PLACEMENT_NOT_FOUND","message":"No placement found with identifier: non-existent-placement"}}}},"500":{"description":"Processing error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessingError"},"example":{"error":"Processing failed","message":"Failed to process placement: Internal server error","identifier":"checkout_success"}}}}}}}}}