### Get All Folders - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/ContactsApi.md This example demonstrates how to fetch all available folders. It allows for pagination and sorting of the results. Remember to configure your API key before making the call. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.ContactsApi(brevo_python.ApiClient(configuration)) limit = 10 # int | Number of documents per page (optional) (default to 10) offset = 0 # int | Index of the first document of the page (optional) (default to 0) sort = 'desc' # str | Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed (optional) (default to desc) try: # Get all folders api_response = api_instance.get_folders(limit=limit, offset=offset, sort=sort) pprint(api_response) except ApiException as e: print("Exception when calling ContactsApi->get_folders: %s\n" % e) ``` -------------------------------- ### Install brevo-python via Setuptools Source: https://github.com/getbrevo/brevo-python/blob/main/README.md Install the brevo-python package using Setuptools. This can be done for the current user or all users. ```sh python setup.py install --user ``` -------------------------------- ### Install Brevo Python SDK Source: https://context7.com/getbrevo/brevo-python/llms.txt Install the brevo-python package using pip. This is the first step before configuring and using the SDK. ```python pip install brevo-python ``` -------------------------------- ### Get Balance Limit with Brevo Python SDK Source: https://github.com/getbrevo/brevo-python/blob/main/docs/BalanceApi.md This example demonstrates how to fetch specific balance limits for a given loyalty program, balance definition, and balance limit ID. It requires proper API key configuration and valid IDs. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.BalanceApi(brevo_python.ApiClient(configuration)) pid = 'pid_example' # str | Loyalty Program Id bdid = 'bdid_example' # str | Balance Definition Id blid = 'blid_example' # str | Balance Limit Id version = 'draft' # str | Version (optional) (default to draft) try: # Get balance limits api_response = api_instance.get_balance_limit(pid, bdid, blid, version=version) pprint(api_response) except ApiException as e: print("Exception when calling BalanceApi->get_balance_limit: %s\n" % e) ``` -------------------------------- ### Get Attribution Metrics by Conversion Source - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md This example shows how to retrieve detailed attribution metrics for a specific Brevo campaign or workflow. You need to provide the conversion source and its ID. API key authorization is required. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # configuration.api_key_prefix['api-key'] = 'Bearer' configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # configuration.api_key_prefix['partner-key'] = 'Bearer' api_instance = brevo_python.EcommerceApi(brevo_python.ApiClient(configuration)) conversion_source = 'conversion_source_example' conversion_source_id = 'conversion_source_id_example' try: api_response = api_instance.ecommerce_attribution_metrics_conversion_source_conversion_source_id_get(conversion_source, conversion_source_id) pprint(api_response) except ApiException as e: print("Exception when calling EcommerceApi->ecommerce_attribution_metrics_conversion_source_conversion_source_id_get: %s\n" % e) ``` -------------------------------- ### Get Lists in a Folder with API Key Source: https://github.com/getbrevo/brevo-python/blob/main/docs/FoldersApi.md This example shows how to fetch all lists associated with a specific folder. You can control the results using limit, offset, and sort parameters. API key authentication is required. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.FoldersApi(brevo_python.ApiClient(configuration)) folder_id = 789 # int | Id of the folder limit = 10 # int | Number of documents per page (optional) (default to 10) offset = 0 # int | Index of the first document of the page (optional) (default to 0) sort = 'desc' # str | Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed (optional) (default to desc) try: # Get lists in a folder api_response = api_instance.get_folder_lists(folder_id, limit=limit, offset=offset, sort=sort) pprint(api_response) except ApiException as e: print("Exception when calling FoldersApi->get_folder_lists: %s\n" % e) ``` -------------------------------- ### get_product_info Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md Get a product's details. ```APIDOC ## GET /products/{id} ### Description Get a product's details ### Method GET ### Endpoint /products/{id} ### Parameters #### Path Parameters - **id** (int) - Required - Product ID ### Response #### Success Response (200) - **product** (Product) - Description ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### Get Specific Pipeline - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/DealsApi.md This snippet retrieves details for a specific pipeline using its ID. It includes authentication setup and error handling. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.DealsApi(brevo_python.ApiClient(configuration)) pipeline_id = 'pipeline_id_example' # str | try: # Get a pipeline api_response = api_instance.crm_pipeline_details_pipeline_id_get(pipeline_id) pprint(api_response) except ApiException as e: print("Exception when calling DealsApi->crm_pipeline_details_pipeline_id_get: %s\n" % e) ``` -------------------------------- ### Create Balance Order - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/BalanceApi.md This example demonstrates how to create a balance order for a loyalty program. It includes configuration for both 'api-key' and 'partner-key' authorization. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.BalanceApi(brevo_python.ApiClient(configuration)) pid = 'pid_example' # str | Loyalty Program Id body = brevo_python.CreateOrderPayload() # CreateOrderPayload | Order Payload try: # Create balance order api_response = api_instance.create_balance_order(pid, body) pprint(api_response) except ApiException as e: print("Exception when calling BalanceApi->create_balance_order: %s\n" % e) ``` -------------------------------- ### Create/Update Product - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md This code example demonstrates how to create or update a product. It requires proper API key configuration for authentication. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.EcommerceApi(brevo_python.ApiClient(configuration)) create_update_product = brevo_python.CreateUpdateProduct() # CreateUpdateProduct | Values to create/update a product try: # Create/Update a product api_response = api_instance.create_update_product(create_update_product) pprint(api_response) except ApiException as e: print("Exception when calling EcommerceApi->create_update_product: %s\n" % e) ``` -------------------------------- ### Get CRM Tasks - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/CRMApi.md Retrieve a list of CRM tasks with options to filter, sort, and paginate. This example shows how to configure API key authorization and make the request. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.CRMApi(brevo_python.ApiClient(configuration)) filter_type = 'filter_type_example' # str | Filter by task type (ID) (optional) filter_status = 'filter_status_example' # str | Filter by task status (optional) filter_date = 'filter_date_example' # str | Filter by date (optional) filter_assign_to = 'filter_assign_to_example' # str | Filter by assignTo id (optional) filter_contacts = 'filter_contacts_example' # str | Filter by contact ids (optional) filter_deals = 'filter_deals_example' # str | Filter by deals ids (optional) filter_companies = 'filter_companies_example' # str | Filter by companies ids (optional) date_from = 56 # int | dateFrom to date range filter type (timestamp in milliseconds) (optional) date_to = 56 # int | dateTo to date range filter type (timestamp in milliseconds) (optional) offset = 789 # int | Index of the first document of the page (optional) limit = 50 # int | Number of documents per page (optional) (default to 50) sort = 'sort_example' # str | Sort the results in the ascending/descending order. Default order is **descending** by creation if `sort` is not passed (optional) sort_by = 'sort_by_example' # str | The field used to sort field names. (optional) try: # Get all tasks api_response = api_instance.crm_tasks_get(filter_type=filter_type, filter_status=filter_status, filter_date=filter_date, filter_assign_to=filter_assign_to, filter_contacts=filter_contacts, filter_deals=filter_deals, filter_companies=filter_companies, date_from=date_from, date_to=date_to, offset=offset, limit=limit, sort=sort, sort_by=sort_by) pprint(api_response) except ApiException as e: print("Exception when calling CRMApi->crm_tasks_get: %s\n" % e) ``` -------------------------------- ### Get Orders Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md Retrieves a list of orders with options for filtering and sorting. You can specify the number of documents per page, the starting index, sort order, and filter by modification or creation date. ```APIDOC ## Get Orders ### Description Retrieves a list of orders with options for filtering and sorting. You can specify the number of documents per page, the starting index, sort order, and filter by modification or creation date. ### Method GET ### Endpoint /orders ### Parameters #### Query Parameters - **limit** (int) - Optional - Number of documents per page. Default is 50. - **offset** (int) - Optional - Index of the first document in the page. Default is 0. - **sort** (str) - Optional - Sort the results in the ascending/descending order of record creation. Default order is descending. - **modified_since** (str) - Optional - Filter orders modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). - **created_since** (str) - Optional - Filter orders created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). ### Response #### Success Response (200) - **GetOrders** - The response object containing the list of orders. ### Response Example { "example": "response body" } ``` -------------------------------- ### DomainsApi - Domain Management and Authentication Source: https://context7.com/getbrevo/brevo-python/llms.txt Registers sending domains, retrieves DNS configuration records, and authenticates them. Includes examples for creating domains, getting DNS configuration, authenticating domains, and listing domains. ```APIDOC ## DomainsApi — Domain Management and Authentication `DomainsApi` registers sending domains, retrieves DNS configuration records, and authenticates them. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.DomainsApi(brevo_python.ApiClient(configuration)) try: # Create a new sending domain created = api_instance.create_domain(brevo_python.CreateDomain(name="mail.yourdomain.com")) dns = created.dns_records print(f"Domain created. Configure DNS records:") print(f" DKIM: {dns.dkim_record.type} {dns.dkim_record.host_name} -> {dns.dkim_record.value}") print(f" SPF: {dns.spf_record.type} {dns.spf_record.host_name}") # Validate current DNS configuration config = api_instance.get_domain_configuration("mail.yourdomain.com") print(f"DNS Verified: DKIM={config.dkim_check}, SPF={config.spf_check}") # Authenticate once DNS is propagated auth_result = api_instance.authenticate_domain("mail.yourdomain.com") print(f"Authenticated: {auth_result.authenticated}") # List all domains domains = api_instance.get_domains() for d in domains.domains: print(f" {d.domain_name} — Authenticated: {d.authenticated}") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` ``` -------------------------------- ### Manage Brevo Webhooks with Python SDK Source: https://context7.com/getbrevo/brevo-python/llms.txt This example shows how to create, list, update, and delete webhooks using the Brevo Python SDK. Configure the webhook URL, events, and type appropriately. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.WebhooksApi(brevo_python.ApiClient(configuration)) webhook_payload = brevo_python.CreateWebhook( url="https://webhooks.example.com/brevo-events", description="Production transactional webhook", events=[ "delivered", "hardBounce", "softBounce", "blocked", "spam", "invalid", "deferred", "click", "opened", "unsubscribed" ], type="transactional", # "transactional" or "marketing" domain="yourdomain.com", is_batched=True # batch events for efficiency ) try: result = api_instance.create_webhook(webhook_payload) webhook_id = result.id print(f"Webhook created: ID {webhook_id}") # List all webhooks all_webhooks = api_instance.get_webhooks(type="transactional") for wh in all_webhooks.webhooks: print(f" [{wh.id}] {wh.url} — Events: {wh.events}") # Update a webhook api_instance.update_webhook(webhook_id, brevo_python.UpdateWebhook( events=["delivered", "hardBounce", "click"] )) # Delete a webhook api_instance.delete_webhook(webhook_id) print("Webhook deleted") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### Create Webhook using Brevo Python SDK Source: https://github.com/getbrevo/brevo-python/blob/main/docs/WebhooksApi.md Demonstrates how to create a new webhook using the WebhooksApi. Ensure API keys are configured correctly. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.WebhooksApi(brevo_python.ApiClient(configuration)) create_webhook = brevo_python.CreateWebhook() # CreateWebhook | Values to create a webhook try: # Create a webhook api_response = api_instance.create_webhook(create_webhook) pprint(api_response) except ApiException as e: print("Exception when calling WebhooksApi->create_webhook: %s\n" % e) ``` -------------------------------- ### Get a Company using CompaniesApi Source: https://github.com/getbrevo/brevo-python/blob/main/docs/CompaniesApi.md Retrieve details of a specific company by its ID. This example demonstrates how to instantiate the client, make the API call, and handle the response or potential exceptions. API key authorization is required. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.CompaniesApi(brevo_python.ApiClient(configuration)) id = 'id_example' # str | try: # Get a company api_response = api_instance.companies_id_get(id) pprint(api_response) except ApiException as e: print("Exception when calling CompaniesApi->companies_id_get: %s\n" % e) ``` -------------------------------- ### Create WhatsApp Template and Campaign Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates creating a transactional WhatsApp template and then scheduling a campaign using that template. Ensure the template is approved before use. ```python template = brevo_python.CreateWhatsAppTemplate( name="order_confirmation", language="en_US", category="TRANSACTIONAL", media_url="https://example.com/banner.jpg", body_text="Hello {{1}}, your order #{{2}} has been confirmed!", header_text="Order Confirmed", footer_text="Thank you for shopping with us." ) try: tpl_result = api_instance.create_whats_app_template(template) print(f"Template created: {tpl_result.id}") # Create a WhatsApp campaign wa_campaign = brevo_python.CreateWhatsAppCampaign( name="Order Confirmation Blast", template_id=tpl_result.id, scheduled_at="2024-07-01T12:00:00+00:00", recipients=brevo_python.CreateWhatsAppCampaignRecipients(list_ids=[6]) ) result = api_instance.create_whats_app_campaign(wa_campaign) print(f"WhatsApp campaign ID: {result.id}") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### Create and Send Email Campaigns with Brevo Python SDK Source: https://context7.com/getbrevo/brevo-python/llms.txt Illustrates creating a classic email campaign with specified content, recipients, and sender details, then sending it immediately or updating its status. Ensure correct campaign parameters and API key. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.EmailCampaignsApi(brevo_python.ApiClient(configuration)) campaign = brevo_python.CreateEmailCampaign( name="Summer Sale 2024", subject="Exclusive Summer Deals Just for You 🌞", sender=brevo_python.CreateEmailCampaignSender(name="Acme Store", email="store@acme.com"), type="classic", html_content="

Summer Sale!

Up to 50% off.

", recipients=brevo_python.CreateEmailCampaignRecipients(list_ids=[3, 5], exclusion_list_ids=[10]), scheduled_at="2024-07-01T09:00:00+00:00", # or omit to draft reply_to="support@acme.com", utm_campaign="summer-sale-2024", header="Exclusive deals await you!", footer="You received this email because you signed up on acme.com" ) try: result = api_instance.create_email_campaign(campaign) campaign_id = result.id print(f"Campaign created: ID {campaign_id}") # Send immediately (overrides scheduled_at) api_instance.send_email_campaign_now(campaign_id) print("Campaign sent immediately!") # Or update status to 'suspended'/'active' api_instance.update_campaign_status(campaign_id, brevo_python.UpdateCampaignStatus(status="suspended")) except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### Delete Child Domain API Example Source: https://github.com/getbrevo/brevo-python/blob/main/docs/ResellerApi.md This example demonstrates how to delete a sender domain for a reseller child account. You need to provide the child's identifier and the domain name to be deleted. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.ResellerApi(brevo_python.ApiClient(configuration)) child_identifier = 'child_identifier_example' # str | Either auth key or id of reseller's child domain_name = 'domain_name_example' # str | Pass the existing domain that needs to be deleted try: # Delete the sender domain of the reseller child based on the childIdentifier and domainName passed api_instance.delete_child_domain(child_identifier, domain_name) except ApiException as e: print("Exception when calling ResellerApi->delete_child_domain: %s\n" % e) ``` -------------------------------- ### Configure Brevo API Key and Settings Source: https://context7.com/getbrevo/brevo-python/llms.txt Set up the Configuration object with your API key, and optionally configure partner keys, proxy, SSL verification, and debug logging. ```python import brevo_python # Basic API key setup configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Optional: set a partner key for resellers configuration.api_key['partner-key'] = 'YOUR_PARTNER_KEY' # Optional: configure proxy and SSL configuration.proxy = 'http://proxy.example.com:8080' configuration.verify_ssl = True # Optional: enable debug logging to a file configuration.debug = True configuration.logger_file = '/tmp/brevo_debug.log' # Create a shared ApiClient for all API instances api_client = brevo_python.ApiClient(configuration) # Check debug info print(configuration.to_debug_report()) ``` -------------------------------- ### conversations_messages_id_get Source: https://github.com/getbrevo/brevo-python/blob/main/docs/ConversationsApi.md Get a message. ```APIDOC ## GET /conversations/messages/{id} ### Description Get a message. ### Method GET ### Endpoint /conversations/messages/{id} ### Parameters #### Path Parameters - **id** (string) - Required - ID of the message ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### Create WhatsApp Template and Campaign Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates how to create a WhatsApp template and then use it to send a campaign to a list of recipients. ```APIDOC ## Create WhatsApp Template and Campaign ### Description This example shows how to programmatically create a WhatsApp template and subsequently launch a WhatsApp campaign using the Brevo Python SDK. It includes error handling for API exceptions. ### Usage ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.ApiClient(configuration) template = brevo_python.CreateWhatsAppTemplate( name="order_confirmation", language="en_US", category="TRANSACTIONAL", media_url="https://example.com/banner.jpg", body_text="Hello {{1}}, your order #{{2}} has been confirmed!", header_text="Order Confirmed", footer_text="Thank you for shopping with us." ) try: # Create a WhatsApp template tpl_result = api_instance.create_whats_app_template(template) print(f"Template created: {tpl_result.id}") # Create a WhatsApp campaign wa_campaign = brevo_python.CreateWhatsAppCampaign( name="Order Confirmation Blast", template_id=tpl_result.id, scheduled_at="2024-07-01T12:00:00+00:00", recipients=brevo_python.CreateWhatsAppCampaignRecipients(list_ids=[6]) ) result = api_instance.create_whats_app_campaign(wa_campaign) print(f"WhatsApp campaign ID: {result.id}") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` ``` -------------------------------- ### Manage Contact Lists with Brevo Python SDK Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates creating folders and lists, adding/removing contacts from lists, and retrieving all lists. Ensure API key is set and handle potential API exceptions. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' contacts_api = brevo_python.ContactsApi(brevo_python.ApiClient(configuration)) try: # Create a folder and a list inside it folder = contacts_api.create_folder(brevo_python.CreateUpdateFolder(name="Newsletter Subscribers")) print(f"Folder ID: {folder.id}") new_list = contacts_api.create_list( brevo_python.CreateList(name="June 2024 Subscribers", folder_id=folder.id) ) list_id = new_list.id print(f"List ID: {list_id}") # Add contacts to the list result = contacts_api.add_contact_to_list( list_id=list_id, contact_emails=brevo_python.AddContactToList(emails=["alice@example.com", "bob@example.com"]) ) print(f"Contacts added: {result.contacts}") # Retrieve all lists (paginated) all_lists = contacts_api.get_lists(limit=10, offset=0, sort="desc") for lst in all_lists.lists: print(f" List [{lst.id}]: {lst.name} — {lst.total_subscribers} subscribers") # Remove a contact from a list contacts_api.remove_contact_from_list( list_id=list_id, contact_emails=brevo_python.RemoveContactFromList(emails=["bob@example.com"]) ) except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### get_orders Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md Get order details. ```APIDOC ## GET /orders ### Description Get order details ### Method GET ### Endpoint /orders ### Parameters #### Query Parameters - **limit** (int) - Optional - Number of documents per page - **offset** (int) - Optional - Tuple to start from on given page - **email** (string) - Optional - Filter by email of the customer - **status** (string) - Optional - Filter by order status - **startDate** (string) - Optional - Filter by start date of orders (YYYY-MM-DD) - **endDate** (string) - Optional - Filter by end date of orders (YYYY-MM-DD) - **sort** (string) - Optional - Sort the results by attribute name. Default value: date_desc. Possible values: date_asc, date_desc, id_asc, id_desc ### Response #### Success Response (200) - **orders** (list[Order]) - Description - **total** (int) - Description ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### Create and List SMTP Templates Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates how to create a new SMTP template and then list active templates. Ensure the sender email is valid. ```python template_payload = brevo_python.CreateSmtpTemplate( template_name="Welcome Email", subject="Welcome to {{params.company}}!", html_content="

Hi {{params.firstName}}, welcome aboard!

", sender=brevo_python.CreateSmtpTemplateSender(email="noreply@example.com", name="Example"), is_active=True, reply_to="support@example.com", to_field="{{contact.EMAIL}}" ) try: created = api_instance.create_smtp_template(template_payload) print(f"Template ID: {created.id}") # Template ID: 7 # List all active templates templates = api_instance.get_smtp_templates(is_active=True, limit=10, offset=0) for t in templates.templates: print(f" [{t.id}] {t.name} - Subject: {t.subject}") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### get_category_info Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md Get category details. ```APIDOC ## GET /categories/{id} ### Description Get a category details ### Method GET ### Endpoint /categories/{id} ### Parameters #### Path Parameters - **id** (int) - Required - Category ID ### Response #### Success Response (200) - **category** (Category) - Description ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### conversations_pushed_messages_id_get Source: https://github.com/getbrevo/brevo-python/blob/main/docs/ConversationsApi.md Get an automated message. ```APIDOC ## GET /conversations/pushedMessages/{id} ### Description Get an automated message. ### Method GET ### Endpoint /conversations/pushedMessages/{id} ### Parameters #### Path Parameters - **id** (string) - Required - ID of the automated message ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### Create and List SMTP Templates Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates how to create a new SMTP template and then list active templates using the Brevo Python SDK. ```APIDOC ## Create SMTP Template ### Description Creates a new transactional email template. ### Method `create_smtp_template(template_payload)` ### Parameters - **template_payload** (CreateSmtpTemplate) - Required - The template data. ### Request Example ```python template_payload = brevo_python.CreateSmtpTemplate( template_name="Welcome Email", subject="Welcome to {{params.company}}!", html_content="

Hi {{params.firstName}}, welcome aboard!

", sender=brevo_python.CreateSmtpTemplateSender(email="noreply@example.com", name="Example"), is_active=True, reply_to="support@example.com", to_field="{{contact.EMAIL}}" ) ``` ## List SMTP Templates ### Description Retrieves a list of SMTP templates, with options to filter by active status and pagination. ### Method `get_smtp_templates(is_active=None, limit=None, offset=None)` ### Parameters - **is_active** (bool) - Optional - Filter templates by active status. - **limit** (int) - Optional - Number of templates to return per page. - **offset** (int) - Optional - The number of templates to skip. ### Response Example ```python templates = api_instance.get_smtp_templates(is_active=True, limit=10, offset=0) for t in templates.templates: print(f" [{t.id}] {t.name} - Subject: {t.subject}") ``` ``` -------------------------------- ### get_smtp_templates Source: https://github.com/getbrevo/brevo-python/blob/main/docs/TransactionalEmailsApi.md Get the list of all your email templates. ```APIDOC ## GET /smtp/templates ### Description Get the list of all your email templates. ### Method GET ### Endpoint /smtp/templates ### Parameters #### Query Parameters - **template_id** (integer) - Optional - Filter the templates by their ID - **name** (string) - Optional - Filter the templates by their name - **limit** (integer) - Optional - Number of documents to retrieve - **offset** (integer) - Optional - Tuple to start the list from - **sort** (string) - Optional - Sort the results in ascending or descending order. Possible values are: `asc`, `desc`. ``` -------------------------------- ### Create Transaction with Brevo Python SDK Source: https://github.com/getbrevo/brevo-python/blob/main/docs/BalanceApi.md Demonstrates how to create a new loyalty program transaction using the Brevo Python SDK. Ensure API key authorization is correctly configured. ```python from __future__ import print_function import time import brevo_python from brevo_python.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api-key'] = 'Bearer' # Configure API key authorization: partner-key configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['partner-key'] = 'Bearer' # create an instance of the API class api_instance = brevo_python.BalanceApi(brevo_python.ApiClient(configuration)) pid = 'pid_example' # str | Loyalty Program Id body = brevo_python.CreateTransactionPayload() # CreateTransactionPayload | Transaction Payload try: # Create new transaction api_response = api_instance.begin_transaction(pid, body) pprint(api_response) except ApiException as e: print("Exception when calling BalanceApi->begin_transaction: %s\n" % e) ``` -------------------------------- ### UserApi - get_invited_users_list Source: https://github.com/getbrevo/brevo-python/blob/main/README.md Get the list of all your users. ```APIDOC ## GET /organization/invited/users ### Description Get the list of all your users. ### Method GET ### Endpoint /organization/invited/users ``` -------------------------------- ### Manage Loyalty Balance Transactions with BalanceApi Source: https://context7.com/getbrevo/brevo-python/llms.txt Demonstrates creating a balance definition, initiating an earn transaction, completing it, and checking contact balances. Ensure 'YOUR_API_KEY' and 'your-program-id' are replaced with actual values. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' balance_api = brevo_python.BalanceApi(brevo_python.ApiClient(configuration)) pid = "your-program-id" try: # Create a balance definition (e.g., "points" currency) bd = balance_api.loyalty_balance_programs_pid_balance_definitions_post( pid=pid, body=brevo_python.CreateBalanceDefinitionPayload( name="Points", unit="pts", is_default=True ) ) bdid = bd.id print(f"Balance definition created: {bdid}") # Begin a transaction (earn points) txn = balance_api.begin_transaction(pid=pid, body=brevo_python.CreateTransactionPayload( contact_id=1234, balance_definition_id=bdid, amount=150, type="earn", meta_data={"order_id": "ORD-2024-001", "reason": "Purchase reward"} )) print(f"Transaction started: {txn.id}") # Complete the transaction balance_api.complete_transaction(pid=pid, tid=txn.id, body={}) print("Transaction completed — 150 pts earned") # Check contact balances balances = balance_api.get_contact_balances(pid=pid) for b in balances.balance_data: print(f" Contact {b.contact_id}: {b.balance} pts") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### Manage Sub-Accounts with MasterAccountApi Source: https://context7.com/getbrevo/brevo-python/llms.txt Illustrates fetching master account details, creating a new sub-account, generating an SSO token for it, and listing all sub-accounts. Replace 'YOUR_MASTER_API_KEY' with your actual API key. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_MASTER_API_KEY' api_instance = brevo_python.MasterAccountApi(brevo_python.ApiClient(configuration)) try: # Get master account details master = api_instance.corporate_master_account_get() print(f"Master: {master.company_name}, Plan: {master.plan_info.type}") # Create a new sub-account sub = api_instance.corporate_sub_account_post(brevo_python.CreateSubAccount( company_name="ACME Sub-Division", email="admin@acme-sub.com", plan=3, # plan id language="en" )) sub_id = sub.id print(f"Sub-account created: {sub_id}") # Generate SSO token for sub-account sso = api_instance.corporate_sub_account_sso_token_post( brevo_python.SsoTokenRequest(id=sub_id) ) print(f"SSO Token URL: https://account.brevo.com/account/login/delegation?token={sso.token}") # List all sub-accounts subs = api_instance.corporate_sub_account_get(limit=20, offset=0) for s in subs.sub_accounts: print(f" [{s.id}] {s.company_name} — Active: {s.active}") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### TransactionalEmailsApi - get_smtp_templates Source: https://github.com/getbrevo/brevo-python/blob/main/README.md Get the list of email templates. ```APIDOC ## GET /smtp/templates ### Description Get the list of email templates. ### Method GET ### Endpoint /smtp/templates ``` -------------------------------- ### TransactionalEmailsApi - get_blocked_domains Source: https://github.com/getbrevo/brevo-python/blob/main/README.md Get the list of blocked domains. ```APIDOC ## GET /smtp/blockedDomains ### Description Get the list of blocked domains. ### Method GET ### Endpoint /smtp/blockedDomains ``` -------------------------------- ### Activate eCommerce App - Python Source: https://github.com/getbrevo/brevo-python/blob/main/docs/EcommerceApi.md This snippet demonstrates how to activate the eCommerce app using the Brevo Python SDK. Ensure your API key is correctly configured. ```python import brevo_python configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # configuration.api_key_prefix['api-key'] = 'Bearer' configuration = brevo_python.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' # configuration.api_key_prefix['partner-key'] = 'Bearer' api_instance = brevo_python.EcommerceApi(brevo_python.ApiClient(configuration)) try: api_instance.ecommerce_activate_post() except brevo_python.ApiException as e: print("Exception when calling EcommerceApi->ecommerce_activate_post: %s\n" % e) ``` -------------------------------- ### Create, Get, and Update Contacts Source: https://context7.com/getbrevo/brevo-python/llms.txt Shows how to create a new contact with attributes and list memberships, retrieve contact details, and update existing contact information. Ensure list IDs exist. ```python import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.ContactsApi(brevo_python.ApiClient(configuration)) # Create a new contact with attributes and list membership new_contact = brevo_python.CreateContact( email="john.doe@example.com", attributes={"FIRSTNAME": "John", "LASTNAME": "Doe", "SMS": "+14155552671"}, list_ids=[3, 7], update_enabled=True, # update if already exists email_blacklisted=False, sms_blacklisted=False, ext_id="CRM-12345" ) try: result = api_instance.create_contact(new_contact) print(f"Created contact ID: {result.id}") # Created contact ID: 1234 # Retrieve contact details contact = api_instance.get_contact_info("john.doe@example.com") print(f"Contact: {contact.email}, Lists: {contact.list_ids}") print(f"Attributes: {contact.attributes}") # Update contact attributes update = brevo_python.UpdateContact( attributes={"FIRSTNAME": "Jonathan"}, list_ids=[3, 7, 12], unlink_list_ids=[], email_blacklisted=False ) api_instance.update_contact("john.doe@example.com", update) print("Contact updated successfully") except ApiException as e: print(f"Error: {e.status} - {e.body}") ``` -------------------------------- ### ContactsApi - Get All Contacts Source: https://github.com/getbrevo/brevo-python/blob/main/README.md Retrieves a list of all contacts. ```APIDOC ## GET /contacts ### Description Get all the contacts. ### Method GET ### Endpoint /contacts ``` -------------------------------- ### get_inbound_email_events Source: https://github.com/getbrevo/brevo-python/blob/main/docs/InboundParsingApi.md Get the list of all the events for the received emails. ```APIDOC ## GET /inbound/events ### Description Get the list of all the events for the received emails. This endpoint will show the list of all the events for the received emails. ### Method GET ### Endpoint /inbound/events ### Parameters #### Query Parameters - **sender** (str) - Optional - Sender email address. - **start_date** (str) - Optional - Start date (YYYY-MM-DD) of the search. - **end_date** (str) - Optional - End date (YYYY-MM-DD) of the search. - **limit** (int) - Optional - Number of documents per page. - **offset** (int) - Optional - Tuple to be added. Server response must be in the given order. - **sort** (str) - Optional - Sort the results in ascending or descending order. ### Response #### Success Response (200) - **GetInboundEmailEvents** (object) - Details about the events. ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ```