### Setup Authorization and Get Segments Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md Configure API key authorization and retrieve a list of segments. Ensure your API key is correctly set in the configuration. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::ContactsApi.new limit = 10 # Integer | Number of documents per page offset = 0 # Integer | Index of the first document of the page opts = { sort: 'desc' # String | Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed } begin #Get all the Segments result = api_instance.get_segments(limit, offset, opts) p result rescue Brevo::ApiError => e puts "Exception when calling ContactsApi->get_segments: #{e}" end ``` -------------------------------- ### Setup Authorization and Get All Deals Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/DealsApi.md Configure API key authorization and retrieve all deals using the DealsApi. Supports filtering by name, company, contact, modification/creation date, and pagination. ```ruby require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::DealsApi.new opts = { filters_attributes_deal_name: 'filters_attributes_deal_name_example', # String | Filter by attributes. If you have a filter for the owner on your end, please send it as filters[attributes.deal_owner] and utilize the account email for the filtering. filters_linked_companies_ids: 'filters_linked_companies_ids_example', # String | Filter by linked companies ids filters_linked_contacts_ids: 'filters_linked_contacts_ids_example', # String | Filter by linked companies ids modified_since: 'modified_since_example', # String | Filter (urlencoded) the contacts modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). Prefer to pass your timezone in date-time format for accurate result. created_since: 'created_since_example', # String | Filter (urlencoded) the contacts created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). Prefer to pass your timezone in date-time format for accurate result. offset: 789, # Integer | Index of the first document of the page limit: 50, # Integer | Number of documents per page sort: 'sort_example', # String | Sort the results in the ascending/descending order. Default order is **descending** by creation if `sort` is not passed sort_by: 'sort_by_example' # String | The field used to sort field names. } begin #Get all deals result = api_instance.crm_deals_get(opts) p result rescue Brevo::ApiError => e puts "Exception when calling DealsApi->crm_deals_get: #{e}" end ``` -------------------------------- ### Get Product Info Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets the details of a product. ```APIDOC ## GET /products/{id} ### Description Get a product's details. ### Method GET ### Endpoint /products/{id} #### Path Parameters - **id** (string) - Required - The ID of the product. ``` -------------------------------- ### Get Shared Template URL Ruby Example Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EmailCampaignsApi.md Demonstrates how to obtain a unique URL for sharing an email template between Brevo accounts. Requires API key configuration. ```ruby require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EmailCampaignsApi.new campaign_id = 789 # Integer | Id of the campaign or template begin #Get a shared template url result = api_instance.get_shared_template_url(campaign_id) p result rescue Brevo::ApiError => e puts "Exception when calling EmailCampaignsApi->get_shared_template_url: #{e}" end ``` -------------------------------- ### Create Event with Brevo Ruby SDK Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EventsApi.md Use this snippet to create an event for a contact. Ensure you have the Brevo gem installed and configure your API key for authorization. The example demonstrates setting up the API client and handling potential errors. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EventsApi.new event = Brevo::Event.new # Event | begin #Create an event api_instance.create_event(event) rescue Brevo::ApiError => e puts "Exception when calling EventsApi->create_event: #{e}" end ``` -------------------------------- ### Install Brevo Ruby Gem Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Add the 'brevo' gem to your application's Gemfile for installation via Bundler, or install it directly using the gem command. ```shell gem 'brevo' ``` ```shell $ bundle ``` ```shell $ ( sudo ) gem install brevo ``` -------------------------------- ### Get Domain Configuration using Brevo Ruby SDK Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/DomainsApi.md Use this snippet to retrieve the configuration details for a specific domain. Ensure you have the Brevo SDK installed and configured with your API keys. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::DomainsApi.new domain_name = 'domain_name_example' # String | Domain name begin #Validate domain configuration result = api_instance.get_domain_configuration(domain_name) p result rescue Brevo::ApiError => e puts "Exception when calling DomainsApi->get_domain_configuration: #{e}" end ``` -------------------------------- ### Get Products Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Returns all your products. ```APIDOC ## GET /products ### Description Return all your products. ### Method GET ### Endpoint /products ``` -------------------------------- ### Get All Webhooks Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/WebhooksApi.md Retrieves a list of all configured webhooks. ```APIDOC ## GET /webhooks ### Description Get all webhooks ### Method GET ### Endpoint /webhooks ### Response #### Success Response (200) - **WebhooksList** (WebhooksList) - A list of all webhooks ### Request Example ```ruby require 'brevo' Brevo.configure do |config| config.api_key['api-key'] = 'YOUR API KEY' end api_instance = Brevo::WebhooksApi.new result = api_instance.get_webhooks p result ``` ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Setup Authorization and Create Folder Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md Configure API key authorization and create a new folder. Replace 'YOUR API KEY' with your actual API key. The response will contain details of the created folder. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::ContactsApi.new create_folder = Brevo::CreateUpdateFolder.new # CreateUpdateFolder | Name of the folder begin #Create a folder result = api_instance.create_folder(create_folder) p result rescue Brevo::ApiError => e puts "Exception when calling ContactsApi->create_folder: #{e}" end ``` -------------------------------- ### Get Segments Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md Retrieves a list of all segments available in your Brevo account. You can specify the number of documents per page and the starting index. ```APIDOC ## Get Segments ### Description Get all the Segments ### Method GET ### Endpoint /contacts/segments ### Parameters #### Query Parameters - **limit** (Integer) - Required - Number of documents per page. Default: 10 - **offset** (Integer) - Required - Index of the first document of the page. Default: 0 - **sort** (String) - Optional - Sort the results in the ascending/descending order of record creation. Default: desc ### Response #### Success Response (200) - **GetSegments** - Details of the segments retrieved. ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Configure Authorization and Get Product Info Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EcommerceApi.md Sets up API key authorization and retrieves details for a specific product using its ID. Ensure the product ID is correctly provided. ```ruby require 'brevo' Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EcommerceApi.new id = 'id_example' # String | Product ID begin #Get a product's details result = api_instance.get_product_info(id) p result rescue Brevo::ApiError => e puts "Exception when calling EcommerceApi->get_product_info: #{e}" end ``` -------------------------------- ### Get Corporate User Permission (Ruby) Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/MasterAccountApi.md Checks the permissions of a specific admin user by their email address. Requires correct API key setup. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::MasterAccountApi.new email = 'email_example' # String | Email of the invited user begin #Check admin user permissions result = api_instance.get_corporate_user_permission(email) p result rescue Brevo::ApiError => e puts "Exception when calling MasterAccountApi->get_corporate_user_permission: #{e}" end ``` -------------------------------- ### Activate eCommerce with Brevo Ruby SDK Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Initialize the Brevo eCommerce integration for your account. This only needs to be done once. ```ruby require 'brevo' api = Brevo::EcommerceApi.new # --- Activate eCommerce (first time only) --- api.ecommerce_activate_post ``` -------------------------------- ### Get WhatsApp Account Configuration Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/WhatsAppCampaignsApi.md Use this method to retrieve your WhatsApp API account information. Ensure Brevo SDK is installed and configured with your API key. ```ruby require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::WhatsAppCampaignsApi.new begin #Get your WhatsApp API account information result = api_instance.get_whats_app_config p result rescue Brevo::ApiError => e puts "Exception when calling WhatsAppCampaignsApi->get_whats_app_config: #{e}" end ``` -------------------------------- ### Create or Update Product with Brevo Ruby SDK Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Sync individual products to Brevo, including details like ID, name, URL, image, price, and categories. Use this for both creation and updates. ```ruby # --- Create / update a product --- api.create_update_product(Brevo::CreateUpdateProduct.new( id: 'SKU-001', name: 'Acme Widget Pro', url: 'https://acme.com/products/widget-pro', image_url: 'https://acme.com/images/widget-pro.jpg', sku: 'SKU-001', price: 49.99, categories: ['electronics', 'widgets'], meta_info: { 'color' => 'blue', 'weight_g' => 250 } )) ``` -------------------------------- ### Get Payment Request Details in Ruby Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/PaymentsApi.md Retrieve details for a specific payment request using its ID. This example requires proper API key configuration. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::PaymentsApi.new id = 'id_example' # String | Id of the payment Request begin #Get payment request details result = api_instance.get_payment_request(id) p result rescue Brevo::ApiError => e puts "Exception when calling PaymentsApi->get_payment_request: #{e}" end ``` -------------------------------- ### Setup Authorization and Create List Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md Configure API key authorization and create a new contact list. Remember to replace 'YOUR API KEY' with your actual API key. The result will contain details of the newly created list. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::ContactsApi.new create_list = Brevo::CreateList.new # CreateList | Values to create a list begin #Create a list result = api_instance.create_list(create_list) p result rescue Brevo::ApiError => e puts "Exception when calling ContactsApi->create_list: #{e}" end ``` -------------------------------- ### Setup Authorization and Create Order Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EcommerceApi.md Configure API key authorization and create a new order. Ensure your API key is correctly set. ```ruby Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EcommerceApi.new order = Brevo::Order.new # Order | begin #Managing the status of the order api_instance.create_order(order) rescue Brevo::ApiError => e puts "Exception when calling EcommerceApi->create_order: #{e}" end ``` -------------------------------- ### Configure and Use Brevo API Client Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Load the Brevo gem, configure API key authorization for 'api-key' and 'partner-key', instantiate the AccountApi, and call get_account to retrieve account information. Handles potential API errors. ```ruby # Load the gem require 'brevo' # Setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::AccountApi.new begin #Get your account information, plan and credits details result = api_instance.get_account p result rescue Brevo::ApiError => e puts "Exception when calling AccountApi->get_account: #{e}" end ``` -------------------------------- ### Configure Brevo API Key and Create/Update Product Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EcommerceApi.md Configures API key authorization for Brevo and shows how to create or update a product. Replace 'YOUR API KEY' with your valid key. The 'brevo' gem must be required before execution. ```ruby require 'brevo' Brevo.configure do |config| config.api_key['api-key'] = 'YOUR API KEY' config.api_key['partner-key'] = 'YOUR API KEY' end api_instance = Brevo::EcommerceApi.new create_update_product = Brevo::CreateUpdateProduct.new begin result = api_instance.create_update_product(create_update_product) p result rescue Brevo::ApiError => e puts "Exception when calling EcommerceApi->create_update_product: #{e}" end ``` -------------------------------- ### Send Email Campaign Now Ruby Example Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EmailCampaignsApi.md Shows how to send an email campaign immediately using its campaign ID. Ensure your API keys are correctly configured. ```ruby require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EmailCampaignsApi.new campaign_id = 789 # Integer | Id of the campaign begin #Send an email campaign immediately, based on campaignId api_instance.send_email_campaign_now(campaign_id) rescue Brevo::ApiError => e puts "Exception when calling EmailCampaignsApi->send_email_campaign_now: #{e}" end ``` -------------------------------- ### Get WhatsApp Templates with Options Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/WhatsAppCampaignsApi.md Retrieve all your created WhatsApp templates. Supports filtering by date range, pagination, sorting, and source. Ensure Brevo SDK is installed and configured with your API key. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::WhatsAppCampaignsApi.new opts = { start_date: 'start_date_example', # String | **Mandatory if endDate is used**. Starting (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the templates created. **Prefer to pass your timezone in date-time format for accurate result** end_date: 'end_date_example', # String | **Mandatory if startDate is used**. Ending (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the templates created. **Prefer to pass your timezone in date-time format for accurate result** limit: 50, # Integer | Number of documents per page offset: 0, # Integer | Index of the first document in the page sort: 'desc', # String | Sort the results in the ascending/descending order of record modification. Default order is **descending** if `sort` is not passed source: 'source_example' # String | source of the template } begin #Return all your created WhatsApp templates result = api_instance.get_whats_app_templates(opts) p result rescue Brevo::ApiError => e puts "Exception when calling WhatsAppCampaignsApi->get_whats_app_templates: #{e}" end ``` -------------------------------- ### Get Specific Pipeline by ID - Ruby Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/DealsApi.md Retrieves a specific pipeline using its ID. Requires the pipeline ID as a parameter and proper API key setup. Includes error handling for API calls. ```ruby require 'brevo' Brevo.configure do |config| config.api_key['api-key'] = 'YOUR API KEY' config.api_key['partner-key'] = 'YOUR API KEY' end api_instance = Brevo::DealsApi.new pipeline_id = 'pipeline_id_example' begin result = api_instance.crm_pipeline_details_pipeline_id_get(pipeline_id) p result rescue Brevo::ApiError => e puts "Exception when calling DealsApi->crm_pipeline_details_pipeline_id_get: #{e}" end ``` -------------------------------- ### Create Marketing Webhook with Brevo Ruby SDK Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Set up a webhook for marketing-related events. This allows you to track opens, clicks, unsubscribes, and list additions. ```ruby # --- Create a marketing webhook --- api.create_webhook(Brevo::CreateWebhook.new( url: 'https://myapp.com/webhooks/marketing', events: ['opened', 'click', 'unsubscribed', 'listAddition'], type: 'marketing' )) ``` -------------------------------- ### Batch Import Products with Brevo Ruby SDK Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Efficiently import multiple products by sending them in a batch. Each product in the batch can have its own ID, name, and price. ```ruby # --- Batch-import products --- api.create_update_batch_products(Brevo::CreateUpdateBatchProducts.new( products: [ Brevo::CreateUpdateProducts.new(id: 'SKU-002', name: 'Widget Mini', price: 19.99), Brevo::CreateUpdateProducts.new(id: 'SKU-003', name: 'Widget Max', price: 99.99) ] )) ``` -------------------------------- ### Get Orders Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets order details. ```APIDOC ## GET /orders ### Description Get order details. ### Method GET ### Endpoint /orders ``` -------------------------------- ### Manage Lists with Brevo Ruby SDK Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Demonstrates creating, renaming, retrieving contacts from, and deleting lists using the Brevo Ruby SDK. Ensure the Brevo client is initialized. ```ruby require 'brevo' api = Brevo::ListsApi.new # --- Create a list inside folder 2 --- new_list = api.create_list(Brevo::CreateList.new(name: 'Newsletter Q3 2024', folder_id: 2)) puts "List ID: #{new_list.id}" # --- Rename it --- api.update_list(new_list.id, Brevo::UpdateList.new(name: 'Newsletter Q3 2024 – Final')) # --- Get contacts in the list --- result = api.get_contacts_from_list(new_list.id, limit: 100, offset: 0) puts "#{result.count} contacts in list" # --- Get all lists --- all = api.get_lists(limit: 50, offset: 0) all.lists.each { |l| puts " #{l.id}: #{l.name} (#{l.total_subscribers} subs)" } # --- Delete the list --- api.delete_list(new_list.id) ``` -------------------------------- ### Get Category Info Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets the details of a category. ```APIDOC ## GET /categories/{id} ### Description Get a category details. ### Method GET ### Endpoint /categories/{id} #### Path Parameters - **id** (string) - Required - The ID of the category. ``` -------------------------------- ### Install and Configure Brevo Ruby Gem Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Add the gem to your Gemfile and configure it with your API key. Includes verification of connectivity. ```ruby gem 'brevo', '~> 4.0' require 'brevo' Brevo.configure do |config| config.api_key['api-key'] = ENV['BREVO_API_KEY'] # Optional: partner key for reseller integrations # config.api_key['partner-key'] = ENV['BREVO_PARTNER_KEY'] config.debugging = false # set true to log request/response detail config.timeout = 30 # seconds; 0 = never times out (default) config.verify_ssl = true # always true in production end # Verify connectivity begin account = Brevo::AccountApi.new.get_account puts "Connected as: #{account.email}" puts "Plan: #{account.plan.map(&:type).join(', ')}" rescue Brevo::ApiError => e puts "Auth failed (#{e.code}): #{e.message}" end ``` -------------------------------- ### Install Brevo Ruby Gem from Git Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md If the Ruby gem is hosted at a Git repository, specify the git URL in your Gemfile. ```ruby gem 'brevo', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' ``` -------------------------------- ### Get Email Campaign Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets an email campaign report. ```APIDOC ## GET /emailCampaigns/{campaignId} ### Description Get an email campaign report. ### Method GET ### Endpoint /emailCampaigns/{campaignId} #### Path Parameters - **campaignId** (string) - Required - The ID of the campaign. ``` -------------------------------- ### Get Shared Template URL Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets a shared template URL for an email campaign. ```APIDOC ## GET /emailCampaigns/{campaignId}/sharedUrl ### Description Get a shared template url. ### Method GET ### Endpoint /emailCampaigns/{campaignId}/sharedUrl #### Path Parameters - **campaignId** (string) - Required - The ID of the campaign. ``` -------------------------------- ### Configure Brevo SDK with API Key Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ExternalFeedsApi.md Set up authorization for the Brevo SDK using an API key. Ensure you replace 'YOUR API KEY' with your actual key. You can optionally set a prefix for the API key. ```ruby Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end ``` -------------------------------- ### Get A/B Test Campaign Result Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets the results of an A/B test email campaign. ```APIDOC ## GET /emailCampaigns/{campaignId}/abTestCampaignResult ### Description Get an A/B test email campaign results. ### Method GET ### Endpoint /emailCampaigns/{campaignId}/abTestCampaignResult #### Path Parameters - **campaignId** (string) - Required - The ID of the campaign. ``` -------------------------------- ### Get E-commerce Attribution Metrics Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets attribution metrics for one or more Brevo campaigns or workflows. ```APIDOC ## GET /ecommerce/attribution/metrics ### Description Get attribution metrics for one or more Brevo campaigns or workflows. ### Method GET ### Endpoint /ecommerce/attribution/metrics ``` -------------------------------- ### List Management Source: https://context7.com/getbrevo/brevo-ruby/llms.txt Examples for creating, updating, retrieving, and deleting lists within the Brevo platform using the Ruby SDK. ```APIDOC ## List Management Operations ### Description This section covers the direct manipulation of email lists, including creation, modification, retrieval, and deletion. ### Methods - `create_list`: Creates a new list within a specified folder. - `update_list`: Renames an existing list. - `get_list`: Retrieves details of a specific list. - `get_lists`: Retrieves all lists with pagination. - `delete_list`: Deletes a specified list. ### Examples ```ruby require 'brevo' api = Brevo::ListsApi.new # Assuming ListsApi is the correct client # --- Create a list inside folder 2 --- new_list = api.create_list(Brevo::CreateList.new(name: 'Newsletter Q3 2024', folder_id: 2)) puts "List ID: #{new_list.id}" # --- Rename it --- api.update_list(new_list.id, Brevo::UpdateList.new(name: 'Newsletter Q3 2024 – Final')) # --- Get contacts in the list --- result = api.get_contacts_from_list(new_list.id, limit: 100, offset: 0) puts "#{result.count} contacts in list" # --- Get all lists --- all = api.get_lists(limit: 50, offset: 0) all.lists.each { |l| puts " #{l.id}: #{l.name} (#{l.total_subscribers} subs)" } # --- Delete the list --- api.delete_list(new_list.id) ``` ``` -------------------------------- ### Create a New Domain with Brevo API Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/DomainsApi.md Use this method to create a new domain. Requires domain name and API key configuration. ```ruby require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::DomainsApi.new opts = { domain_name: Brevo::CreateDomain.new # CreateDomain | domain's name } begin #Create a new domain result = api_instance.create_domain(opts) p result rescue Brevo::ApiError => e puts "Exception when calling DomainsApi->create_domain: #{e}" end ``` -------------------------------- ### Get E-commerce Display Currency Configuration Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets the ISO 4217 compliant display currency code for your Brevo account. ```APIDOC ## GET /ecommerce/config/displayCurrency ### Description Get the ISO 4217 compliant display currency code for your Brevo account. ### Method GET ### Endpoint /ecommerce/config/displayCurrency ``` -------------------------------- ### Get E-commerce Attribution Products by Conversion Source ID Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets attributed product sales for a single Brevo campaign or workflow. ```APIDOC ## GET /ecommerce/attribution/products/{conversionSource}/{conversionSourceId} ### Description Get attributed product sales for a single Brevo campaign or workflow. ### Method GET ### Endpoint /ecommerce/attribution/products/{conversionSource}/{conversionSourceId} #### Path Parameters - **conversionSource** (string) - Required - The source of the conversion. - **conversionSourceId** (string) - Required - The ID of the conversion source. ``` -------------------------------- ### Create Contact - Ruby Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md This Ruby snippet demonstrates how to create a new contact. It requires setting up API key authorization and instantiating the ContactsApi. Includes basic error handling for API calls. ```ruby # load the gem require 'brevo' # setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::ContactsApi.new create_contact = Brevo::CreateContact.new # CreateContact | Values to create a contact begin #Create a contact result = api_instance.create_contact(create_contact) p result rescue Brevo::ApiError => e puts "Exception when calling ContactsApi->create_contact: #{e}" end ``` -------------------------------- ### Get E-commerce Attribution Metrics by Conversion Source ID Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Gets detailed attribution metrics for a single Brevo campaign or workflow. ```APIDOC ## GET /ecommerce/attribution/metrics/{conversionSource}/{conversionSourceId} ### Description Get detailed attribution metrics for a single Brevo campaign or workflow. ### Method GET ### Endpoint /ecommerce/attribution/metrics/{conversionSource}/{conversionSourceId} #### Path Parameters - **conversionSource** (string) - Required - The source of the conversion. - **conversionSourceId** (string) - Required - The ID of the conversion source. ``` -------------------------------- ### Configure Authorization and Get Orders Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EcommerceApi.md Sets up API key authorization and retrieves a list of orders. Supports filtering by modification or creation date, and pagination. ```ruby require 'brevo' Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::EcommerceApi.new opts = { limit: 50, # Integer | Number of documents per page offset: 0, # Integer | Index of the first document in the page sort: 'desc', # String | Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed modified_since: 'modified_since_example', # String | Filter (urlencoded) the orders modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.** created_since: 'created_since_example' # String | Filter (urlencoded) the orders created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.** } begin #Get order details result = api_instance.get_orders(opts) p result rescue Brevo::ApiError => e puts "Exception when calling EcommerceApi->get_orders: #{e}" end ``` -------------------------------- ### Get Shared Template URL Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/EmailCampaignsApi.md Get a unique URL to share & import an email template from one Brevo account to another. ```APIDOC ## POST /email/campaigns/shared_template ### Description Get a unique URL to share & import an email template from one Brevo account to another. ### Method POST ### Endpoint /email/campaigns/shared_template ### Parameters #### Request Body - **campaign_id** (Integer) - Required - Id of the campaign or template ### Request Example { "campaign_id": 789 } ### Response #### Success Response (200) - **GetSharedTemplateUrl** (GetSharedTemplateUrl.md) - Description of the response object ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### crm_tasks_id_get Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Get a task. ```APIDOC ## GET /crm/tasks/{id} ### Description Get a task. ### Method GET ### Endpoint /crm/tasks/{id} ``` -------------------------------- ### Setup Authorization and Create DOI Contact Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/ContactsApi.md Configure API key authorization and create a contact using the Double-Opt-In (DOI) flow. Ensure you replace 'YOUR API KEY' with your actual API key. ```ruby require 'brevo' Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::ContactsApi.new create_doi_contact = Brevo::CreateDoiContact.new # CreateDoiContact | Values to create the Double opt-in (DOI) contact begin #Create Contact via DOI (Double-Opt-In) Flow api_instance.create_doi_contact(create_doi_contact) rescue Brevo::ApiError => e puts "Exception when calling ContactsApi->create_doi_contact: #{e}" end ``` -------------------------------- ### crm_tasks_get Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Get all tasks. ```APIDOC ## GET /crm/tasks ### Description Get all tasks. ### Method GET ### Endpoint /crm/tasks ``` -------------------------------- ### Create Domain Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/DomainsApi.md Creates a new domain within your Brevo account. This is the first step before authenticating the domain. ```APIDOC ## POST /senders/domains ### Description Creates a new domain. ### Method POST ### Endpoint /senders/domains ### Parameters #### Request Body - **domain_name** (CreateDomain) - Optional - domain's name ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Get Account Information Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md This snippet demonstrates how to retrieve account information, including plan and credits details, using the Brevo Ruby client library. ```APIDOC ## Get Account Information ### Description Retrieves your account information, plan, and credits details. ### Method `GET` (Implicitly via Ruby client method) ### Endpoint (Not directly exposed in this format, but corresponds to account information retrieval) ### Parameters None explicitly listed for this method call. ### Request Example ```ruby # Load the gem require 'brevo' # Setup authorization Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::AccountApi.new begin #Get your account information, plan and credits details result = api_instance.get_account p result rescue Brevo::ApiError => e puts "Exception when calling AccountApi->get_account: #{e}" end ``` ### Response #### Success Response (200) Details about the account, plan, and credits. #### Response Example (Response structure not detailed in the source text) ``` -------------------------------- ### crm_files_get Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Get all files. ```APIDOC ## crm_files_get ### Description Get all files. ### Method GET ### Endpoint /crm/files ``` -------------------------------- ### get_tier_group Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Get tier group. ```APIDOC ## GET /loyalty/tier/programs/{pid}/tier-groups/{gid} ### Description Get tier group. ### Method GET ### Endpoint /loyalty/tier/programs/{pid}/tier-groups/{gid} ``` -------------------------------- ### Configure Brevo SDK and Validate Sender by OTP Source: https://github.com/getbrevo/brevo-ruby/blob/main/docs/SendersApi.md Set up API key authorization for the Brevo SDK and then validate a sender's email address using an OTP. Ensure your API key is correctly configured before making the call. ```ruby Brevo.configure do |config| # Configure API key authorization: api-key config.api_key['api-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key config.api_key['partner-key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) #config.api_key_prefix['partner-key'] = 'Bearer' end api_instance = Brevo::SendersApi.new sender_id = 789 # Integer | Id of the sender opts = { otp: Brevo::Otp.new # Otp | otp } begin #Update a sender api_instance.validate_sender_by_otp(sender_id, opts) rescue Brevo::ApiError => e puts "Exception when calling SendersApi->validate_sender_by_otp: #{e}" end ``` -------------------------------- ### crm_tasktypes_get Source: https://github.com/getbrevo/brevo-ruby/blob/main/README.md Get all task types. ```APIDOC ## GET /crm/tasktypes ### Description Get all task types. ### Method GET ### Endpoint /crm/tasktypes ```