Try Live
Add Docs
Rankings
Pricing
Docs
Install
Theme
Install
Docs
Pricing
More...
More...
Try Live
Rankings
Enterprise
Create API Key
Add Docs
Braze Docs
https://github.com/braze-inc/braze-docs
Admin
Braze Docs hosts all user, developer, partner, and API documentation for the Braze customer
...
Tokens:
1,834,782
Snippets:
15,325
Trust Score:
9.7
Update:
5 days ago
Context
Skills
Chat
Benchmark
83.4
Suggestions
Latest
Show doc for...
Code
Info
Show Results
Context Summary (auto-generated)
Raw
Copy
Link
# Braze Documentation Braze is a comprehensive customer engagement platform that enables businesses to build meaningful relationships with their customers through personalized, cross-channel messaging. The platform provides REST APIs for user data management, messaging, campaign orchestration, and analytics, along with native SDKs for iOS (Swift), Android, Web, React Native, Flutter, Unity, Cordova, Roku, and .NET MAUI (Xamarin). Braze supports multiple messaging channels including push notifications, email, SMS/MMS/RCS, WhatsApp, in-app messages, content cards, and webhooks. The Braze documentation covers four primary domains: API documentation for server-side integrations, SDK integration guides for mobile and web applications, user guides for dashboard operations, and partner integrations. All API requests are authenticated using Bearer tokens with scoped permissions, and the platform enforces rate limits that vary by endpoint (default: 250,000 requests per hour). The documentation is organized as a Jekyll-based site with content in multiple languages (English, German, Spanish, French, Japanese, Korean, Portuguese). ## User Tracking API - Track User Data The `/users/track` endpoint records custom events, purchases, and updates user profile attributes. This is the primary endpoint for ingesting user data into Braze and requires the `users.track` permission. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/users/track' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "attributes": [ { "external_id": "user_12345", "email": "customer@example.com", "first_name": "Jane", "last_name": "Doe", "country": "US", "home_city": "Chicago", "loyalty_points": 2500, "favorite_categories": ["electronics", "books", "outdoor"] } ], "events": [ { "external_id": "user_12345", "app_id": "your_app_identifier", "name": "product_viewed", "time": "2025-01-15T14:30:00+00:00", "properties": { "product_id": "SKU-789", "category": "electronics", "price": 299.99, "currency": "USD" } } ], "purchases": [ { "external_id": "user_12345", "app_id": "your_app_identifier", "product_id": "SKU-456", "currency": "USD", "price": 49.99, "quantity": 2, "time": "2025-01-15T15:00:00Z", "properties": { "color": "blue", "size": "medium", "discount_code": "WINTER25" } } ] }' # Response (200 OK): # { # "message": "success", # "attributes_processed": 1, # "events_processed": 1, # "purchases_processed": 1 # } ``` ## Send Messages API - Immediate Message Delivery The `/messages/send` endpoint sends immediate messages to designated users across multiple channels including push, email, SMS, and webhooks. Requires the `messages.send` permission and users must already exist in Braze. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/messages/send' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "external_user_ids": ["user_12345", "user_67890"], "campaign_id": "campaign_abc123", "recipient_subscription_state": "subscribed", "messages": { "email": { "app_id": "your_app_identifier", "subject": "Your order has shipped!", "from": "orders@yourcompany.com", "body": "<html><body><h1>Great news!</h1><p>Your order #{{${order_id}}} has shipped and is on its way.</p><p>Track your package: {{${tracking_url}}}</p></body></html>", "plaintext_body": "Great news! Your order has shipped. Track your package at: {{${tracking_url}}}" }, "apple_push": { "alert": "Your order has shipped! Track it now.", "badge": 1, "sound": "default", "extra": { "order_id": "12345", "deep_link": "myapp://orders/12345" } }, "android_push": { "alert": "Your order has shipped! Track it now.", "title": "Order Update", "extra": { "order_id": "12345", "deep_link": "myapp://orders/12345" } } } }' # Response (201 Created): # { # "dispatch_id": "abcdef123456789", # "message": "success" # } ``` ## Schedule Messages API - Scheduled Message Delivery The `/messages/schedule/create` endpoint schedules messages to be sent at a designated time with support for local time delivery and optimal send time. Returns a `schedule_id` for managing the scheduled message. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/messages/schedule/create' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "segment_id": "segment_xyz789", "campaign_id": "campaign_abc123", "broadcast": true, "recipient_subscription_state": "opted_in", "schedule": { "time": "2025-02-14T09:00:00Z", "in_local_time": true, "at_optimal_time": false }, "messages": { "email": { "app_id": "your_app_identifier", "subject": "Valentine Day Special - 20% Off!", "from": "marketing@yourcompany.com", "body": "<html><body><h1>Love is in the air!</h1><p>Enjoy 20% off your entire purchase with code LOVE20.</p></body></html>" }, "web_push": { "alert": "Valentine Day Special - 20% Off with code LOVE20!", "title": "Limited Time Offer", "custom_uri": "https://yourcompany.com/valentines-sale" } } }' # Response (201 Created): # { # "dispatch_id": "dispatch_12345", # "schedule_id": "schedule_67890", # "message": "success" # } ``` ## Export User Data API - User Profile Export The `/users/export/ids` endpoint exports complete user profiles by identifier including custom attributes, events, purchases, devices, and campaign engagement data. Supports up to 50 users per request. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/users/export/ids' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "external_ids": ["user_12345", "user_67890"], "fields_to_export": [ "external_id", "email", "first_name", "last_name", "custom_attributes", "custom_events", "purchases", "devices", "push_tokens", "total_revenue", "country", "language" ] }' # Response (200 OK): # { # "message": "success", # "users": [ # { # "created_at": "2024-06-15T10:30:00.000Z", # "external_id": "user_12345", # "email": "customer@example.com", # "first_name": "Jane", # "last_name": "Doe", # "country": "US", # "language": "en", # "total_revenue": 1250.50, # "custom_attributes": { # "loyalty_points": 2500, # "membership_tier": "gold" # }, # "custom_events": [ # {"name": "product_viewed", "count": 45, "first": "2024-06-20T...", "last": "2025-01-15T..."}, # {"name": "cart_added", "count": 12, "first": "2024-07-01T...", "last": "2025-01-14T..."} # ], # "purchases": [ # {"name": "SKU-456", "count": 3, "first": "2024-08-10T...", "last": "2025-01-15T..."} # ], # "devices": [ # {"model": "iPhone 15", "os": "iOS 17.2", "ad_tracking_enabled": true} # ] # } # ] # } ``` ## Subscription Groups API - Manage User Subscriptions The `/subscription/status/set` endpoint batch updates subscription group status for email, SMS, and RCS channels. Supports up to 50 users per request and can trigger double opt-in workflows for SMS. ```bash # Email subscription group update curl --location --request POST 'https://rest.iad-01.braze.com/subscription/status/set' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "subscription_group_id": "sg_newsletter_weekly", "subscription_state": "subscribed", "external_id": ["user_12345", "user_67890"], "email": ["customer1@example.com", "customer2@example.com"] }' # SMS subscription with double opt-in curl --location --request POST 'https://rest.iad-01.braze.com/subscription/status/set' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "subscription_group_id": "sg_sms_promotions", "subscription_state": "subscribed", "external_id": ["user_12345"], "phone": ["+12025551234", "+12025555678"], "use_double_opt_in_logic": true }' # Response (201 Created): # { # "message": "success" # } ``` ## Catalogs API - Product Catalog Management The Catalogs API enables management of product data that can be referenced in personalized messaging. Get catalog item details with the `/catalogs/{catalog_name}/items/{item_id}` endpoint. ```bash # Get a single catalog item curl --location --request GET 'https://rest.iad-01.braze.com/catalogs/products/items/SKU-12345' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' # Response (200 OK): # { # "items": [ # { # "id": "SKU-12345", # "name": "Wireless Bluetooth Headphones", # "category": "Electronics", # "price": 149.99, # "in_stock": true, # "image_url": "https://cdn.example.com/products/headphones.jpg", # "rating": 4.5 # } # ], # "message": "success" # } # Create catalog items in bulk curl --location --request POST 'https://rest.iad-01.braze.com/catalogs/products/items' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "items": [ { "id": "SKU-67890", "name": "Smart Watch Pro", "category": "Electronics", "price": 299.99, "in_stock": true, "description": "Advanced fitness tracking with GPS" }, { "id": "SKU-11111", "name": "Running Shoes Ultra", "category": "Sports", "price": 129.99, "in_stock": true, "description": "Lightweight performance running shoes" } ] }' ``` ## Email Templates API - Template Management The `/templates/email/create` endpoint creates reusable email templates that are available in the Braze dashboard. Templates support HTML content, Liquid personalization, and Content Blocks. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/templates/email/create' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "template_name": "order_confirmation_v2", "subject": "Order Confirmed - #{{${order_id}}}", "body": "<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;}.header{background:#1a73e8;color:white;padding:20px;}.content{padding:20px;}.order-details{background:#f5f5f5;padding:15px;border-radius:5px;}</style></head><body><div class=\"header\"><h1>Thank you for your order, {{${first_name}}}!</h1></div><div class=\"content\"><div class=\"order-details\"><h2>Order #{{${order_id}}}</h2><p><strong>Items:</strong> {{${item_count}}}</p><p><strong>Total:</strong> ${{${order_total}}}</p><p><strong>Shipping:</strong> {{${shipping_address}}}</p></div><p>We will send you a shipping confirmation once your order is on its way.</p></div></body></html>", "plaintext_body": "Thank you for your order, {{${first_name}}}! Order #{{${order_id}}} - Total: ${{${order_total}}}. We will send shipping confirmation when your order ships.", "preheader": "Your order #{{${order_id}}} is confirmed!", "tags": ["transactional", "orders", "confirmation"], "should_inline_css": true }' # Response (200 OK): # { # "email_template_id": "template_abc123xyz", # "message": "success" # } ``` ## Campaign Trigger API - Trigger API Campaigns The `/campaigns/trigger/send` endpoint triggers API-based campaigns with personalized trigger properties. Useful for transactional messaging and event-driven campaigns. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/campaigns/trigger/send' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "campaign_id": "campaign_password_reset", "recipients": [ { "external_user_id": "user_12345", "trigger_properties": { "reset_link": "https://yourapp.com/reset?token=abc123xyz", "expiration_time": "24 hours", "request_ip": "192.168.1.100", "request_location": "Chicago, IL" } } ] }' # Canvas trigger with entry properties curl --location --request POST 'https://rest.iad-01.braze.com/canvas/trigger/send' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "canvas_id": "canvas_onboarding_flow", "recipients": [ { "external_user_id": "user_new_signup", "canvas_entry_properties": { "signup_source": "mobile_app", "referral_code": "FRIEND20", "plan_type": "premium_trial" } } ] }' # Response (201 Created): # { # "dispatch_id": "dispatch_xyz789", # "message": "success" # } ``` ## Segments Export API - User Segment Analytics The `/segments/data_series` endpoint retrieves analytics data for a segment over time, including segment size trends. ```bash curl --location --request GET 'https://rest.iad-01.braze.com/segments/data_series?segment_id=segment_active_users&length=30&ending_at=2025-01-15T00:00:00Z' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' # Response (200 OK): # { # "message": "success", # "data": [ # {"time": "2024-12-17", "size": 125000}, # {"time": "2024-12-18", "size": 126500}, # {"time": "2024-12-19", "size": 128200}, # ... # {"time": "2025-01-15", "size": 145000} # ] # } # Get segment details curl --location --request GET 'https://rest.iad-01.braze.com/segments/details?segment_id=segment_active_users' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' # Response (200 OK): # { # "message": "success", # "created_at": "2024-01-15T10:00:00.000Z", # "updated_at": "2025-01-10T15:30:00.000Z", # "name": "Active Users - Last 30 Days", # "description": "Users who have opened the app in the last 30 days", # "tags": ["engagement", "active"] # } ``` ## KPI Analytics API - Daily Active Users The `/kpi/dau/data_series` endpoint retrieves daily active user counts over a specified time range for measuring user engagement. ```bash curl --location --request GET 'https://rest.iad-01.braze.com/kpi/dau/data_series?length=14&ending_at=2025-01-15T00:00:00Z&app_id=your_app_identifier' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' # Response (200 OK): # { # "message": "success", # "data": [ # {"time": "2025-01-02", "dau": 45230}, # {"time": "2025-01-03", "dau": 47150}, # {"time": "2025-01-04", "dau": 52340}, # {"time": "2025-01-05", "dau": 51890}, # ... # {"time": "2025-01-15", "dau": 48750} # ] # } # Monthly active users curl --location --request GET 'https://rest.iad-01.braze.com/kpi/mau/data_series?length=6&ending_at=2025-01-15T00:00:00Z&app_id=your_app_identifier' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' # Response (200 OK): # { # "message": "success", # "data": [ # {"time": "2024-08-15", "mau": 892000}, # {"time": "2024-09-15", "mau": 915000}, # {"time": "2024-10-15", "mau": 945000}, # {"time": "2024-11-15", "mau": 978000}, # {"time": "2024-12-15", "mau": 1025000}, # {"time": "2025-01-15", "mau": 1052000} # ] # } ``` ## User Merge API - Merge Duplicate Profiles The `/users/merge` endpoint merges two user profiles, combining attributes, events, and purchase history. Useful for deduplicating users when they sign up through different channels. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/users/merge' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "merge_updates": [ { "identifier_to_merge": { "external_id": "anonymous_user_abc" }, "identifier_to_keep": { "external_id": "registered_user_12345" } }, { "identifier_to_merge": { "user_alias": { "alias_name": "guest_session_xyz", "alias_label": "guest_id" } }, "identifier_to_keep": { "external_id": "registered_user_67890" } } ] }' # Response (200 OK): # { # "message": "success" # } ``` ## Live Activity API - iOS Live Activities The `/messages/live_activity/update` endpoint updates iOS Live Activities for real-time content like sports scores, delivery tracking, or ride sharing status. ```bash curl --location --request POST 'https://rest.iad-01.braze.com/messages/live_activity/update' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_REST_API_KEY' \ --data-raw '{ "app_id": "your_app_identifier", "activity_id": "delivery_tracking_12345", "content_state": { "driver_name": "Mike", "eta_minutes": 8, "current_status": "arriving", "stops_remaining": 1 }, "end_activity": false, "dismissal_date": "2025-01-15T16:00:00Z", "stale_date": "2025-01-15T15:45:00Z", "alert": { "title": "Driver Nearby", "body": "Mike is 8 minutes away with your order!" } }' # Response (200 OK): # { # "message": "success" # } ``` ## SDK Integration - Web SDK Initialization The Braze Web SDK enables browser-based user tracking, push notifications, in-app messages, and content cards. Install via npm or CDN and initialize with your API key. ```html <!-- CDN Installation --> <script type="text/javascript"> +function(a,p,P,b,y){a.braze={};a.brazeQueue=[];for(var s="BrazeSdkMetadata DeviceProperties Card Card.prototype.subscribeToClickedEvent Card.prototype.subscribeToDismissedEvent Card.prototype.removeAllSubscriptions Card.prototype.removeSubscription Banner Banner.prototype.subscribeToClickedEvent Banner.prototype.subscribeToDismissedEvent Banner.prototype.subscribeToViewedEvent Banner.prototype.removeAllSubscriptions Banner.prototype.removeSubscription ClassicCard ControlCard CaptionedImage ContentCard TextAnnouncement automaticallyShowInAppMessages destroyFeed hideContentCards showContentCards showInAppMessage subscribeToContentCardsUpdates toggleContentCards getCachedContentCards requestContentCardsRefresh logContentCardImpressions logContentCardClick logContentCardsDisplayed changeUser getUser logCustomEvent logPurchase openSession requestImmediateDataFlush wipeData disableSDK enableSDK subscribeToInAppMessage getDeviceId requestPushPermission subscribeToSdkAuthenticationFailures subscribeToPushNotificationsEnabled initializeFeatureFlags subscribeToFeatureFlagsUpdates getFeatureFlags getFeatureFlag logFeatureFlagImpression getAllFeatureFlags refreshFeatureFlags subscribeToSessionUpdates deferInAppMessages".split(" "),i=0;i<s.length;i++){for(var m=s[i],k=a.braze,l=m.split("."),j=0;j<l.length-1;j++)k=k[l[j]];k[l[j]]=(new Function("return function "+m.replace(/\./g,"_")+"(){window.brazeQueue.push(arguments); return true}"))()}window.braze.getCachedContentCards=function(){return new window.braze.ContentCards};window.braze.getFeatureFlag=function(n){return new window.braze.FeatureFlag(n)};window.braze.User=function(){};window.braze.getUser=function(){return new window.braze.User};(y=p.createElement(P)).async=1;y.src="https://js.appboycdn.com/web-sdk/6.4/braze.min.js";(b=p.getElementsByTagName(P)[0]).parentNode.insertBefore(y,b)}(window,document,"script"); // Initialize the SDK braze.initialize('YOUR-API-KEY', { baseUrl: 'sdk.iad-01.braze.com', enableLogging: true, allowUserSuppliedJavascript: true, sessionTimeoutInSeconds: 1800 }); // Identify user braze.changeUser('user_12345'); // Set user attributes braze.getUser().setFirstName('Jane'); braze.getUser().setEmail('jane@example.com'); braze.getUser().setCustomUserAttribute('loyalty_tier', 'gold'); braze.getUser().setCustomUserAttribute('favorite_categories', ['electronics', 'books']); // Log custom event braze.logCustomEvent('product_viewed', { product_id: 'SKU-12345', product_name: 'Wireless Headphones', category: 'Electronics', price: 149.99 }); // Log purchase braze.logPurchase('SKU-12345', 149.99, 'USD', 1, { discount_applied: true, discount_code: 'SAVE20' }); // Request push notification permission braze.requestPushPermission(); // Enable in-app messages braze.automaticallyShowInAppMessages(); // Open session to start tracking braze.openSession(); </script> ``` ```javascript // NPM Installation import * as braze from "@braze/web-sdk"; // Initialize braze.initialize('YOUR-API-KEY', { baseUrl: 'sdk.iad-01.braze.com', enableLogging: process.env.NODE_ENV === 'development', allowUserSuppliedJavascript: true }); // Subscribe to content cards updates braze.subscribeToContentCardsUpdates((cards) => { console.log('Content cards received:', cards.cards.length); cards.cards.forEach(card => { console.log('Card:', card.title, card.description); }); }); // Subscribe to in-app messages braze.subscribeToInAppMessage((message) => { // Custom handling before displaying if (message.extras && message.extras.custom_action) { handleCustomAction(message.extras.custom_action); } // Show the message braze.showInAppMessage(message); }); // Request and refresh content cards braze.requestContentCardsRefresh(); braze.openSession(); ``` ## SDK Integration - Swift iOS SDK The Braze Swift SDK provides native iOS integration for push notifications, in-app messages, content cards, and analytics with support for Swift Package Manager, CocoaPods, and Carthage. ```swift // AppDelegate.swift import BrazeKit import BrazeUI import UserNotifications @main class AppDelegate: UIResponder, UIApplicationDelegate { static var braze: Braze? func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { // Configure Braze let configuration = Braze.Configuration( apiKey: "YOUR-API-KEY", endpoint: "sdk.iad-01.braze.com" ) configuration.logger.level = .info configuration.sessionTimeout = 1800 configuration.push.automation = [.badge, .foregroundDisplay] // Initialize Braze let braze = Braze(configuration: configuration) Self.braze = braze // Set in-app message UI delegate braze.inAppMessagePresenter = BrazeInAppMessageUI() // Request push authorization UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in if granted { DispatchQueue.main.async { application.registerForRemoteNotifications() } } } return true } // Handle push token registration func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) { Self.braze?.notifications.register(deviceToken: deviceToken) } // Handle push notification received func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void ) { if let braze = Self.braze, braze.notifications.handleBackgroundNotification(userInfo: userInfo, fetchCompletionHandler: completionHandler) { return } completionHandler(.noData) } } // User identification and tracking class UserManager { func identifyUser(userId: String) { AppDelegate.braze?.changeUser(userId: userId) } func updateUserProfile() { guard let user = AppDelegate.braze?.user else { return } user.set(firstName: "Jane") user.set(lastName: "Doe") user.set(email: "jane@example.com") user.set(customAttribute: "loyalty_tier", value: "gold") user.set(customAttribute: "account_balance", value: 250.50) user.set(customAttribute: "favorite_brands", array: ["Apple", "Nike", "Patagonia"]) } func logProductView(productId: String, name: String, price: Double) { AppDelegate.braze?.logCustomEvent( name: "product_viewed", properties: [ "product_id": productId, "product_name": name, "price": price, "currency": "USD" ] ) } func logPurchase(productId: String, price: Double, quantity: Int) { AppDelegate.braze?.logPurchase( productId: productId, currency: "USD", price: price, quantity: quantity, properties: ["source": "mobile_app"] ) } } // Content Cards integration class ContentCardsViewController: UIViewController { var cardsSubscription: Braze.Cancellable? override func viewDidLoad() { super.viewDidLoad() // Subscribe to content cards updates cardsSubscription = AppDelegate.braze?.contentCards.subscribeToUpdates { [weak self] cards in self?.displayCards(cards) } // Request refresh AppDelegate.braze?.contentCards.requestRefresh() } func displayCards(_ cards: [Braze.ContentCard]) { for card in cards { // Log impression when card is displayed card.logImpression(using: AppDelegate.braze!) // Access card properties print("Card: \(card.title ?? "No title")") print("Description: \(card.description ?? "No description")") print("Image URL: \(card.imageURL?.absoluteString ?? "No image")") } } func cardTapped(_ card: Braze.ContentCard) { // Log click card.logClick(using: AppDelegate.braze!) // Handle card action if let url = card.url { UIApplication.shared.open(url) } } deinit { cardsSubscription?.cancel() } } ``` ## SDK Integration - Android SDK The Braze Android SDK integrates with Android applications for push notifications (FCM), in-app messages, content cards, and user analytics with Kotlin and Java support. ```kotlin // Application class class MyApplication : Application() { companion object { lateinit var braze: Braze } override fun onCreate() { super.onCreate() // Configure and initialize Braze val brazeConfig = BrazeConfig.Builder() .setApiKey("YOUR-API-KEY") .setCustomEndpoint("sdk.iad-01.braze.com") .setSessionTimeout(1800) .setHandlePushDeepLinksAutomatically(true) .setIsFirebaseCloudMessagingRegistrationEnabled(true) .setFirebaseCloudMessagingSenderIdKey("YOUR-FCM-SENDER-ID") .build() Braze.configure(this, brazeConfig) braze = Braze.getInstance(this) } } // Activity with user identification class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Identify user after login identifyUser("user_12345") } private fun identifyUser(userId: String) { Braze.getInstance(this).changeUser(userId) // Set user attributes Braze.getInstance(this).currentUser?.apply { setFirstName("Jane") setLastName("Doe") setEmail("jane@example.com") setCountry("US") setHomeCity("Chicago") setCustomUserAttribute("loyalty_tier", "gold") setCustomUserAttribute("account_balance", 250.50) setCustomUserAttribute("favorite_categories", arrayOf("electronics", "books", "outdoor")) } } fun logProductView(productId: String, productName: String, price: Double) { val properties = BrazeProperties() properties.addProperty("product_id", productId) properties.addProperty("product_name", productName) properties.addProperty("price", price) properties.addProperty("currency", "USD") Braze.getInstance(this).logCustomEvent("product_viewed", properties) } fun logPurchase(productId: String, price: Double, quantity: Int) { val properties = BrazeProperties() properties.addProperty("source", "android_app") Braze.getInstance(this).logPurchase( productId, "USD", BigDecimal(price), quantity, properties ) } } // Content Cards Fragment class ContentCardsFragment : Fragment(), IContentCardsUpdateHandler { private var contentCardsSubscriber: IEventSubscriber<ContentCardsUpdatedEvent>? = null override fun onResume() { super.onResume() // Subscribe to content cards updates contentCardsSubscriber = IEventSubscriber { event -> activity?.runOnUiThread { handleContentCardsUpdate(event.allCards) } } Braze.getInstance(requireContext()).subscribeToContentCardsUpdates(contentCardsSubscriber!!) Braze.getInstance(requireContext()).requestContentCardsRefresh(false) } private fun handleContentCardsUpdate(cards: List<Card>) { cards.forEach { card -> // Log impression card.logImpression() // Access card data when (card) { is CaptionedImageCard -> { Log.d("ContentCards", "Captioned: ${card.title} - ${card.description}") } is ClassicCard -> { Log.d("ContentCards", "Classic: ${card.title}") } is BannerCard -> { Log.d("ContentCards", "Banner: ${card.imageUrl}") } } } } fun onCardClicked(card: Card) { card.logClick() card.url?.let { url -> val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) startActivity(intent) } } override fun onPause() { super.onPause() contentCardsSubscriber?.let { Braze.getInstance(requireContext()).removeSingleSubscription(it, ContentCardsUpdatedEvent::class.java) } } } ``` ## Summary Braze provides a comprehensive customer engagement platform that enables businesses to create personalized, cross-channel messaging experiences at scale. The platform's REST API supports complete lifecycle management including user data ingestion via `/users/track`, immediate and scheduled message delivery, campaign triggering, template management, subscription handling, and detailed analytics export. Key integration patterns include server-side user tracking with batch updates, API-triggered transactional campaigns for real-time messaging, catalog-powered product recommendations, and segment-based audience targeting with connected audience filters. The native SDKs (Web, iOS Swift, Android) offer seamless client-side integration for user identification, event logging, push notification handling, in-app messaging, and content cards. Best practices include identifying users immediately after authentication, tracking meaningful custom events and purchases for segmentation, implementing proper push notification permission flows, and subscribing to content card updates for real-time personalization. The platform supports advanced features like Live Activities for iOS, feature flags for controlled rollouts, SDK authentication for enhanced security, and Currents for streaming event data to external analytics platforms. All API requests require Bearer token authentication with scoped permissions, enabling fine-grained access control across different teams and use cases.