{"id":9560,"library":"brevo-python","title":"Brevo Python SDK","description":"The Brevo Python SDK is a client library for interacting with the Brevo (formerly Sendinblue) API, providing access to email, SMS, contacts, CRM, and other marketing automation services. It is a modern, Fern-generated client built on `httpx` and `pydantic`. The library is actively maintained with frequent releases, currently at version 4.0.10.","status":"active","version":"4.0.10","language":"python","source_language":"en","source_url":"https://github.com/getbrevo/brevo-python","tags":["email","marketing","CRM","API client","sendinblue"],"install":[{"cmd":"pip install brevo-python","lang":"bash","label":"Install latest version"},{"cmd":"pip install 'brevo-python<4.0'","lang":"bash","label":"Install legacy v1.x (not recommended)"}],"dependencies":[{"reason":"Underlying HTTP client for network requests.","package":"httpx","optional":false},{"reason":"Used for data validation and parsing API responses into Python models.","package":"pydantic","optional":false}],"imports":[{"note":"Version 4.x of the SDK uses `from brevo import Brevo`. Previous versions (v1.x) used `from brevo_python import Brevo` or `from sib_api_v3_sdk import ApiClient`.","wrong":"from brevo_python import Brevo","symbol":"Brevo","correct":"from brevo import Brevo"},{"note":"The exception class for API errors changed with the v4 rewrite.","wrong":"from brevo_python.rest import ApiException","symbol":"ApiError","correct":"from brevo.exceptions import ApiError"}],"quickstart":{"code":"import os\nfrom brevo import Brevo\nfrom brevo.exceptions import ApiError\n\n# Set your Brevo API key as an environment variable (e.g., BREVO_API_KEY)\napi_key = os.environ.get(\"BREVO_API_KEY\", \"\")\n\nif not api_key:\n    print(\"Error: BREVO_API_KEY environment variable not set. Please set it to your Brevo API key.\")\nelse:\n    try:\n        client = Brevo(api_key=api_key)\n        \n        # Example: Get account details\n        account = client.account.get_account()\n        print(f\"Successfully connected to Brevo API. Account email: {account.email}\")\n        print(f\"Company name: {account.company_name}\")\n        \n        # Example: Get contacts (first 10)\n        contacts_response = client.contacts.get_contacts(limit=10)\n        print(f\"Found {len(contacts_response.contacts)} contacts.\")\n        if contacts_response.contacts:\n            print(f\"First contact email: {contacts_response.contacts[0].email}\")\n\n    except ApiError as e:\n        print(f\"Brevo API Error: {e}\")\n        if \"Unauthorized\" in str(e):\n            print(\"Please check if your BREVO_API_KEY is valid and has the necessary permissions.\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart initializes the Brevo client using an API key from an environment variable and then retrieves basic account details and a list of contacts to verify connectivity."},"warnings":[{"fix":"Refer to the official Brevo SDK documentation or migration guides for v4. Update all import statements (e.g., `from brevo import Brevo`), client instantiation, and method calls.","message":"Version 4.x of `brevo-python` is a complete rewrite with significant breaking changes compared to v1.x. The module name changed from `brevo_python` to `brevo`, and the client object structure, API call methods, and exception handling are entirely different.","severity":"breaking","affected_versions":">=4.0.0 (when migrating from <4.0.0)"},{"fix":"Upgrade to `brevo-python>=4.0.9`. If unable to upgrade, you may need to explicitly catch `ApiError` and inspect its message or status code to handle this specific scenario.","message":"Prior to v4.0.9, calling `client.contacts.create_contact(..., update_enabled=True)` for an existing contact would incorrectly raise an `ApiError` even though the Brevo API returned a successful 204 No Content response.","severity":"gotcha","affected_versions":"4.0.0 - 4.0.8"},{"fix":"Upgrade to `brevo-python>=4.0.10`. On older versions, attempts to deserialize this field might fail if the API returns a string when an integer is expected, leading to `TypeError` or `ValidationError`.","message":"In `get_process` and `get_processes` responses, the `duplicate_email_id` field's expected type was changed from `Optional[int]` to `Optional[str]` (which is a URL) to match the actual API response.","severity":"gotcha","affected_versions":"4.0.0 - 4.0.9"},{"fix":"Upgrade to `brevo-python>=4.0.10`. If stuck on an older version, you might encounter deserialization errors when retrieving processes that are currently in progress.","message":"The `status` field for `get_process` and `get_processes` endpoints did not include the `\"in_process\"` literal type prior to v4.0.10, causing deserialization failures for active processes.","severity":"gotcha","affected_versions":"4.0.0 - 4.0.9"}],"env_vars":null,"search_vec":"'4.0.10':56 'access':21 'activ':48 'api':19,60 'autom':30 'brevo':1,5,16 'built':40 'client':10,39,61 'contact':25 'crm':26,59 'current':53 'email':23,57 'fern':37 'fern-gener':36 'former':17 'frequent':51 'generat':38 'httpx':42 'interact':13 'librari':11,46 'maintain':49 'market':29,58 'modern':35 'provid':20 'pydant':44 'python':2,6 'releas':52 'sdk':3,7 'sendinblu':18,62 'servic':31 'sms':24 'version':55","created_at":"2026-04-17T01:19:32.798732+00:00","updated_at":"2026-04-17T01:19:32.798732+00:00","problems":[{"fix":"Update your import statements. For example, change `from brevo_python import Brevo` to `from brevo import Brevo`.","cause":"You are attempting to use import statements from the v1.x SDK (`brevo_python`) with the v4.x SDK (`brevo-python`) installed. The module name changed in version 4.","error":"ModuleNotFoundError: No module named 'brevo_python'"},{"fix":"Ensure your `BREVO_API_KEY` environment variable or the API key passed to `Brevo()` is correct and valid. Verify it has the required permissions in your Brevo account.","cause":"The API key provided is either missing, incorrect, or does not have the necessary permissions for the requested operation.","error":"brevo.exceptions.ApiError: (401) Unauthorized"},{"fix":"Upgrade to `brevo-python>=4.0.9`. This bug was fixed to correctly return a successful (empty) response without raising an `ApiError` in this scenario.","cause":"This error message might occur when using `create_contact` with `update_enabled=True` on `brevo-python` versions before 4.0.9, even though the Brevo API successfully updated the contact.","error":"brevo.exceptions.ApiError: (400) The contact already exists."},{"fix":"Upgrade to `brevo-python>=4.0.10` to correctly handle the `duplicate_email_id` as an `Optional[str]`.","cause":"This error can occur when parsing the `duplicate_email_id` field from `get_process` or `get_processes` responses on SDK versions before 4.0.10, due to a type mismatch with the actual API response (URL string vs. expected integer).","error":"TypeError: Expected <class 'int'>, got <class 'str'>"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.10","cli_name":"","cli_version":null,"type":"library","homepage":"https://brevo.com","github":"https://github.com/getbrevo/brevo-python","docs":"https://developers.brevo.com","changelog":null,"pypi":"https://pypi.org/project/brevo-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication","crm-productivity","http-networking","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}