### Install SendinBlue Python SDK via Setuptools Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Install the SendinBlue API v3 Python SDK using Setuptools. This can be done for the current user or system-wide. ```sh python setup.py install --user ``` -------------------------------- ### Get Account Information with SendinBlue API v3 Python SDK Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md This example demonstrates how to configure API key authentication and retrieve account information, including plan and credits details, using the SendinBlue API v3 Python SDK. Ensure you replace 'YOUR_API_KEY' with your actual API key. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.AccountApi(sib_api_v3_sdk.ApiClient(configuration)) try: # Get your account information, plan and credits details api_response = api_instance.get_account() pprint(api_response) except ApiException as e: print("Exception when calling AccountApi->get_account: %s\n" % e) ``` -------------------------------- ### Install and Configure SendinBlue API v3 Python Library Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt Install the library using pip and configure your API key for authentication. All API clients use a shared ApiClient instance. ```python # Install # pip install sib-api-v3-sdk import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # All API clients accept the shared ApiClient client = sib_api_v3_sdk.ApiClient(configuration) ``` -------------------------------- ### Create a CRM Note Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/CRMApi.md Create a new note within the CRM. This example shows the initial setup for API key authorization required before making the API call. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed ``` -------------------------------- ### Install SendinBlue Python SDK via pip Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Use this command to install the SendinBlue API v3 Python SDK using pip. You might need root permissions. ```sh pip install sib-api-v3-sdk ``` -------------------------------- ### Get All Webhooks Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/WebhooksApi.md Retrieves a list of all configured webhooks. ```APIDOC ## GET /webhooks ### Description Get a list of all configured webhooks. ### Method GET ### Endpoint /webhooks ### Response #### Success Response (200) - **GetWebhooks** (GetWebhooks) - A list of webhooks ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Get All Folders Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/FoldersApi.md Retrieves a list of all available folders. ```APIDOC ## GET /contacts/folders ### Description Get all folders ### Method GET ### Endpoint /contacts/folders ### Response #### Success Response (200) - **GetFolders** (object) - Contains a list of all folders ### Response Example ```json { "folders": [ { "id": 123, "name": "Folder A" }, { "id": 456, "name": "Folder B" } ] } ``` ``` -------------------------------- ### Get All Lists Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ListsApi.md Retrieves a paginated list of all available lists. You can control the number of results per page, the starting index, and the sort order. ```APIDOC ## GET /lists ### Description Retrieves a paginated list of all available lists. You can control the number of results per page, the starting index, and the sort order. ### Method GET ### Endpoint /lists ### Query Parameters - **limit** (int) - Optional - Number of documents per page. Default is 10. - **offset** (int) - Optional - Index of the first document of the page. Default is 0. - **sort** (str) - Optional - Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed. Default is 'desc'. ### Response #### Success Response (200) - **GetLists** - Returns a GetLists object containing the list details. ### Request Example ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['partner-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.ListsApi(sib_api_v3_sdk.ApiClient(configuration)) limit = 10 offset = 0 sort = 'desc' try: api_response = api_instance.get_lists(limit=limit, offset=offset, sort=sort) pprint(api_response) except ApiException as e: print("Exception when calling ListsApi->get_lists: %s\n" % e) ``` ``` -------------------------------- ### Get a Company using CompaniesApi Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/CompaniesApi.md Retrieves a specific company by its ID. Includes API key setup and error handling for API calls. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.CompaniesApi(sib_api_v3_sdk.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 and Send SMS Campaign Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt This example demonstrates creating an SMS campaign with a name, sender ID, content, and target list. It then sends the campaign immediately. Scheduling is possible by uncommenting and setting the `scheduled_at` parameter. ```python import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.SMSCampaignsApi(sib_api_v3_sdk.ApiClient(configuration)) create_sms_campaign = sib_api_v3_sdk.CreateSmsCampaign( name="Flash Sale SMS", sender="MyStore", # Sender name (max 11 chars) content="Flash Sale! 30% off everything today. Shop now: https://mystore.com. Reply STOP to opt-out.", recipients=sib_api_v3_sdk.CreateSmsCampaignRecipients(list_ids=[10]), # scheduled_at="2024-03-20T10:00:00.000Z" ) try: response = api_instance.create_sms_campaign(create_sms_campaign) campaign_id = response.id print(f"SMS campaign created: {campaign_id}") api_instance.send_sms_campaign_now(campaign_id) print("SMS campaign sent!") except ApiException as e: print("Exception: %s\n" % e) ``` -------------------------------- ### Get a CRM Note Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/CRMApi.md Retrieve a specific note using its ID. This example demonstrates setting up API keys for authorization and handling potential API exceptions. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.CRMApi(sib_api_v3_sdk.ApiClient(configuration)) id = 'id_example' # str | Note ID to get try: # Get a note api_response = api_instance.crm_notes_id_get(id) pprint(api_response) except ApiException as e: print("Exception when calling CRMApi->crm_notes_id_get: %s\n" % e) ``` -------------------------------- ### Create and Send Email Campaign Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt This example shows how to create a new email campaign with specified content, sender, recipients, and subject. It then sends the campaign immediately. To schedule, uncomment and set the `scheduled_at` parameter. ```python import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.EmailCampaignsApi(sib_api_v3_sdk.ApiClient(configuration)) email_campaign = sib_api_v3_sdk.CreateEmailCampaign( name="Spring Sale 2024", subject="Exclusive Spring Deals Just For You!", sender=sib_api_v3_sdk.CreateEmailCampaignSender(name="My Store", email="offers@mystore.com"), html_content="

Spring Sale

Use code SPRING20 for 20% off!

", recipients=sib_api_v3_sdk.CreateEmailCampaignRecipients(list_ids=[10, 15]), reply_to="support@mystore.com", # scheduled_at="2024-03-20T10:00:00.000Z" # omit to send immediately ) try: # Create the campaign create_response = api_instance.create_email_campaign(email_campaign) campaign_id = create_response.id print(f"Campaign created: {campaign_id}") # Send immediately api_instance.send_email_campaign_now(campaign_id) print("Campaign sent!") except ApiException as e: print("Exception: %s\n" % e) ``` -------------------------------- ### Get Contact Details Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md Retrieves detailed information for a specific contact using their identifier. Optional start and end dates can be provided to filter statistics related to campaigns. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) identifier = 'identifier_example' # str | Email (urlencoded) OR ID of the contact OR its SMS attribute value start_date = 'start_date_example' # str | **Mandatory if endDate is used.** Starting date (YYYY-MM-DD) of the statistic events specific to campaigns. Must be lower than equal to endDate (optional) end_date = 'end_date_example' # str | **Mandatory if startDate is used.** Ending date (YYYY-MM-DD) of the statistic events specific to campaigns. Must be greater than equal to startDate. (optional) try: # Get a contact's details api_response = api_instance.get_contact_info(identifier, start_date=start_date, end_date=end_date) pprint(api_response) except ApiException as e: print("Exception when calling ContactsApi->get_contact_info: %s\n" % e) ``` -------------------------------- ### Configure API Key Authorization Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md Demonstrates how to configure API key authorization for both 'api-key' and 'partner-key'. This setup is required before making API calls. ```python configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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' ``` -------------------------------- ### Monitor Background Job Status Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt Provides examples for retrieving the status of a specific background process using its ID and listing all available processes. Requires API key setup. ```python import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.ProcessApi(sib_api_v3_sdk.ApiClient(configuration)) process_id = 78 # ID returned from import_contacts, request_contact_export, etc. try: process = api_instance.get_process(process_id) pprint(process) # GetProcess with status: 'queued', 'in_progress', 'completed', 'failed' # {'id': 78, 'status': 'completed', 'name': 'import', 'export_url': 'https://...'} # List all processes all_processes = api_instance.get_processes(limit=10, offset=0) pprint(all_processes) except ApiException as e: print("Exception when calling ProcessApi->get_process: %s\n" % e) ``` -------------------------------- ### Create/Update Products in Batch - Python Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/EcommerceApi.md Use this snippet to create multiple products at once. Ensure API keys are configured correctly. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.EcommerceApi(sib_api_v3_sdk.ApiClient(configuration)) create_update_batch_products = sib_api_v3_sdk.CreateUpdateBatchProducts() # CreateUpdateBatchProducts | Values to create a batch of products try: # Create products in batch api_response = api_instance.create_update_batch_products(create_update_batch_products) pprint(api_response) except ApiException as e: print("Exception when calling EcommerceApi->create_update_batch_products: %s\n" % e) ``` -------------------------------- ### Get Contact Campaign Statistics Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md Fetches email campaign statistics for a given contact. Requires an identifier and optionally accepts start and end dates to define the reporting period. The difference between dates should not exceed 90 days. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) identifier = 'identifier_example' # str | Email (urlencoded) OR ID of the contact start_date = 'start_date_example' # str | Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the statistic events specific to campaigns. Must be lower than equal to endDate (optional) end_date = 'end_date_example' # str | Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the statistic events specific to campaigns. Must be greater than equal to startDate. Maximum difference between startDate and endDate should not be greater than 90 days (optional) try: # Get email campaigns' statistics for a contact api_response = api_instance.get_contact_stats(identifier, start_date=start_date, end_date=end_date) pprint(api_response) except ApiException as e: print("Exception when calling ContactsApi->get_contact_stats: %s\n" % e) ``` -------------------------------- ### Get Transactional Blocked Contacts Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/TransactionalEmailsApi.md Fetches a list of blocked or unsubscribed transactional contacts. Specify start and end dates for filtering, along with limit, offset, sender emails, and sort order. Ensure dates are in YYYY-MM-DD format. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # create an instance of the API class api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration)) start_date = 'start_date_example' # str | Mandatory if endDate is used. Starting date (YYYY-MM-DD) from which you want to fetch the blocked or unsubscribed contacts (optional) end_date = 'end_date_example' # str | Mandatory if startDate is used. Ending date (YYYY-MM-DD) till which you want to fetch the blocked or unsubscribed contacts (optional) limit = 50 # int | Number of documents returned per page (optional) (default to 50) offset = 0 # int | Index of the first document on the page (optional) (default to 0) senders = ['senders_example'] # list[str] | Comma separated list of emails of the senders from which contacts are blocked or unsubscribed (optional) 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 the list of blocked or unsubscribed transactional contacts api_response = api_instance.get_transac_blocked_contacts(start_date=start_date, end_date=end_date, limit=limit, offset=offset, senders=senders, sort=sort) pprint(api_response) except ApiException as e: print("Exception when calling TransactionalEmailsApi->get_transac_blocked_contacts: %s\n" % e) ``` -------------------------------- ### Import SendinBlue Python SDK Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Import the necessary SendinBlue SDK library after installation. ```python import sib_api_v3_sdk ``` -------------------------------- ### Update a Folder - Python Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md This example demonstrates how to update a folder's details. It requires configuring both 'api-key' and 'partner-key' authorizations and instantiating the ContactsApi client. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) folder_id = 789 # int | Id of the folder update_folder = sib_api_v3_sdk.CreateUpdateFolder() # CreateUpdateFolder | Name of the folder try: # Update a folder api_instance.update_folder(folder_id, update_folder) except ApiException as e: print("Exception when calling ContactsApi->update_folder: %s\n" % e) ``` -------------------------------- ### Create Note Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/NotesApi.md This snippet demonstrates how to create a note using the NotesApi. It includes setting up the API client, defining the note data, and handling potential API exceptions. ```APIDOC ## POST /crm/notes ### Description Creates a note for a contact or company. ### Method POST ### Endpoint /crm/notes ### Parameters #### Request Body - **body** (NoteData) - Required - Note data to create a note. ### Request Example ```python body = sib_api_v3_sdk.NoteData() api_response = api_instance.crm_notes_post(body) ``` ### Response #### Success Response (200) - **NoteId** (NoteId) - The ID of the created note. #### Response Example ```json { "id": 123 } ``` ### Authorization - api-key - partner-key ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Get Account Information Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/AccountApi.md Retrieves your account information, including plan and credits details. This is a GET request to the /account endpoint. ```APIDOC ## GET /account ### Description Get your account information, plan and credits details ### Method GET ### Endpoint /account ### Parameters This endpoint does not need any parameter. ### Response #### Success Response (200) - **GetAccount** (GetAccount) - Details of the account information, plan and credits. ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Create a List Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md This method allows you to create a new list. It requires a `CreateList` object containing the list's details. ```APIDOC ## Create a List ### Description Creates a new list. ### Method POST ### Endpoint `/contacts/lists` ### Parameters #### Request Body - **create_list** (CreateList) - Required - Values to create a list ### Request Example ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) create_list = sib_api_v3_sdk.CreateList() try: api_response = api_instance.create_list(create_list) pprint(api_response) except ApiException as e: print("Exception when calling ContactsApi->create_list: %s\n" % e) ``` ### Response #### Success Response (201) - **Response Body** (CreateModel) - Details of the created list. ### Authorization - api-key - partner-key ``` -------------------------------- ### Get Master Account Details Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/MasterAccountApi.md Retrieves the details of the master account. Requires API key or partner key authentication. Use this to get information about your primary Sendinblue account. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.MasterAccountApi(sib_api_v3_sdk.ApiClient(configuration)) try: # Get the details of requested master account api_response = api_instance.corporate_master_account_get() pprint(api_response) except ApiException as e: print("Exception when calling MasterAccountApi->corporate_master_account_get: %s\n" % e) ``` -------------------------------- ### Create List (Python) Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ContactsApi.md This example shows how to create a new list within the Contacts API. It utilizes the CreateList object and requires valid API key authentication. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) create_list = sib_api_v3_sdk.CreateList() # CreateList | Values to create a list try: # Create a list api_response = api_instance.create_list(create_list) pprint(api_response) except ApiException as e: print("Exception when calling ContactsApi->create_list: %s\n" % e) ``` -------------------------------- ### EcommerceApi.get_products Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Retrieves a list of all available products. ```APIDOC ## GET /products ### Description Return all your products. ### Method GET ### Endpoint /products ``` -------------------------------- ### WebhooksApi - get_webhooks Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get all webhooks. ```APIDOC ## GET /webhooks ### Description Get all webhooks. ### Method GET ### Endpoint /webhooks ``` -------------------------------- ### WebhooksApi - create_webhook Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Create a webhook. ```APIDOC ## POST /webhooks ### Description Create a webhook. ### Method POST ### Endpoint /webhooks ``` -------------------------------- ### FilesApi - crm_files_get Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get all files. ```APIDOC ## GET /crm/files ### Description Get all files. ### Method GET ### Endpoint /crm/files ``` -------------------------------- ### Create and Manage CRM Deals Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt Demonstrates creating a new deal, linking it to a contact, and fetching all deals. Ensure API keys and necessary SDK components are configured. ```python try: deal = deals_api.crm_deals_post(sib_api_v3_sdk.Body3( name="Enterprise Contract Q1", attributes={"deal_stage": "Proposal", "amount": 50000, "close_date": "2024-03-31"} )) deal_id = deal.id print(f"Deal created: {deal_id}") # Link deal to a contact deals_api.crm_deals_link_unlink_id_patch( deal_id, sib_api_v3_sdk.Body5( link_contact_ids=[1034], unlink_contact_ids=[] ) ) print("Deal linked to contact") # Fetch deal list all_deals = deals_api.crm_deals_get() pprint(all_deals) except ApiException as e: print("Exception: %s\n" % e) ``` -------------------------------- ### Create a task Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/TasksApi.md Creates a new task. ```APIDOC ## POST /crm/tasks ### Description Create a task. ### Method POST ### Endpoint /crm/tasks ### Parameters #### Request Body - **task** (object) - Required - Task object to be created. - **name** (str) - Required - Name of the task - **status** (str) - Required - Status of the task - **dueDate** (str) - Required - Due date of the task - **assigneeId** (int) - Required - Assignee ID - **notes** (str) - Optional - Notes for the task - **type** (str) - Optional - Type of the task - **contacts** (array) - Optional - List of contact IDs associated with the task - **deals** (array) - Optional - List of deal IDs associated with the task - **companies** (array) - Optional - List of company IDs associated with the task ### Response #### Success Response (201) - **Task** - Details of the newly created task. ### Authorization - api-key - partner-key ``` -------------------------------- ### get_blocked_domains Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/TransactionalEmailsApi.md Get the list of all blocked domains. ```APIDOC ## GET /smtp/blockedDomains ### Description Retrieve a list of all domains that are currently blocked, preventing emails from being sent to them. ### Method GET ### Endpoint /smtp/blockedDomains ``` -------------------------------- ### WhatsappCampaignsApi - get_whatsapp_campaign Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get a Whatsapp campaign. ```APIDOC ## GET /whatsappCampaigns/{campaignId} ### Description Get a Whatsapp campaign. ### Method GET ### Endpoint /whatsappCampaigns/{campaignId} ``` -------------------------------- ### Manage Contact Lists and Folders Source: https://context7.com/sendinblue/apiv3-python-library/llms.txt This snippet demonstrates how to create a folder, then create a list within that folder, and finally add contacts to the created list. Ensure you handle potential API exceptions for each operation. ```python import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint configuration = sib_api_v3_sdk.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = sib_api_v3_sdk.ContactsApi(sib_api_v3_sdk.ApiClient(configuration)) # Create a folder try: folder = api_instance.create_folder(sib_api_v3_sdk.CreateUpdateFolder(name="Newsletter Subscribers")) folder_id = folder.id # e.g. 7 print(f"Created folder: {folder_id}") except ApiException as e: print("Create folder error: %s\n" % e) # Create a list in the folder try: new_list = api_instance.create_list(sib_api_v3_sdk.CreateList(name="Q1 2024 Leads", folder_id=folder_id)) list_id = new_list.id # e.g. 25 print(f"Created list: {list_id}") except ApiException as e: print("Create list error: %s\n" % e) # Add contacts to the list try: result = api_instance.add_contact_to_list( list_id=list_id, contact_emails=sib_api_v3_sdk.AddContactToList(emails=["alice@example.com", "bob@example.com"]) ) pprint(result) # Returns PostContactInfo with success/failure breakdown except ApiException as e: print("Add to list error: %s\n" % e) ``` -------------------------------- ### Get Products using EcommerceApi Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/EcommerceApi.md Retrieve a list of all products with options to filter by ID, name, price, and categories, and to control pagination and sorting. Ensure API key authorization is correctly configured. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.EcommerceApi(sib_api_v3_sdk.ApiClient(configuration)) limit = 50 # int | Number of documents per page (optional) (default to 50) offset = 0 # int | Index of the first document in 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) ids = ['ids_example'] # list[str] | Filter by product ids (optional) name = 'name_example' # str | Filter by product name, minimum 3 characters should be present for search (optional) price = ['price_example'] # list[str] | Filter by product price, like price[lte] (optional) categories = ['categories_example'] # list[str] | Filter by category ids (optional) try: # Return all your products api_response = api_instance.get_products(limit=limit, offset=offset, sort=sort, ids=ids, name=name, price=price, categories=categories) pprint(api_response) except ApiException as e: print("Exception when calling EcommerceApi->get_products: %s\n" % e) ``` -------------------------------- ### WebhooksApi - get_webhook Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get a webhook details. ```APIDOC ## GET /webhooks/{webhookId} ### Description Get a webhook details. ### Method GET ### Endpoint /webhooks/{webhookId} ``` -------------------------------- ### MasterAccountApi - corporate_sub_account_id_get Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get sub-account details. ```APIDOC ## GET /corporate/subAccount/{id} ### Description Get sub-account details. ### Method GET ### Endpoint /corporate/subAccount/{id} ``` -------------------------------- ### Create API Key for Sub-Account Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/MasterAccountApi.md This snippet demonstrates how to generate a new API v3 key for a sub-account. It requires the necessary API key configurations. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.MasterAccountApi(sib_api_v3_sdk.ApiClient(configuration)) create_api_key_request = sib_api_v3_sdk.CreateApiKeyRequest() # CreateApiKeyRequest | Values to generate API key for sub-account try: # Create an API key for a sub-account api_response = api_instance.corporate_sub_account_key_post(create_api_key_request) pprint(api_response) except ApiException as e: print("Exception when calling MasterAccountApi->corporate_sub_account_key_post: %s\n" % e) ``` -------------------------------- ### FilesApi - crm_files_id_data_get Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get file details. ```APIDOC ## GET /crm/files/{id}/data ### Description Get file details. ### Method GET ### Endpoint /crm/files/{id}/data ``` -------------------------------- ### Create a List using Python Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ListsApi.md Use this method to create a new contact list. Requires a configured API key and a CreateList object. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ListsApi(sib_api_v3_sdk.ApiClient(configuration)) create_list = sib_api_v3_sdk.CreateList() # CreateList | Values to create a list try: # Create a list api_response = api_instance.create_list(create_list) pprint(api_response) except ApiException as e: print("Exception when calling ListsApi->create_list: %s\n" % e) ``` -------------------------------- ### TransactionalEmailsApi - get_smtp_templates Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get the list of email templates. ```APIDOC ## GET /smtp/templates ### Description Get the list of email templates. ### Method GET ### Endpoint /smtp/templates ``` -------------------------------- ### Get All Processes with Filtering Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/ProcessApi.md Retrieve a list of all processes for your account, with options to limit the number of results, set an offset, and sort the order. API key authentication is required. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.ProcessApi(sib_api_v3_sdk.ApiClient(configuration)) limit = 10 # int | Number limitation for the result returned (optional) (default to 10) offset = 0 # int | Beginning point in the list to retrieve from. (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: # Return all the processes for your account api_response = api_instance.get_processes(limit=limit, offset=offset, sort=sort) pprint(api_response) except ApiException as e: print("Exception when calling ProcessApi->get_processes: %s\n" % e) ``` -------------------------------- ### Create Webhook - Python Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/WebhooksApi.md Use this method to create a new webhook. Ensure API key authorization is configured correctly. ```python from __future__ import print_function import time import sib_api_v3_sdk from sib_api_v3_sdk.rest import ApiException from pprint import pprint # Configure API key authorization: api-key configuration = sib_api_v3_sdk.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 = sib_api_v3_sdk.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 = sib_api_v3_sdk.WebhooksApi(sib_api_v3_sdk.ApiClient(configuration)) create_webhook = sib_api_v3_sdk.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) ``` -------------------------------- ### TransactionalEmailsApi - get_blocked_domains Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get the list of blocked domains. ```APIDOC ## GET /smtp/blockedDomains ### Description Get the list of blocked domains. ### Method GET ### Endpoint /smtp/blockedDomains ``` -------------------------------- ### WhatsappCampaignsApi - get_whatsapp_templates Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Return all your created whatsapp templates. ```APIDOC ## GET /whatsappCampaigns/template-list ### Description Return all your created whatsapp templates. ### Method GET ### Endpoint /whatsappCampaigns/template-list ``` -------------------------------- ### EmailCampaignsApi - get_shared_template_url Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get a shared template url. ```APIDOC ## GET /emailCampaigns/{campaignId}/sharedUrl ### Description Get a shared template url. ### Method GET ### Endpoint /emailCampaigns/{campaignId}/sharedUrl ``` -------------------------------- ### EmailCampaignsApi - get_email_campaign Source: https://github.com/sendinblue/apiv3-python-library/blob/master/README.md Get an email campaign report. ```APIDOC ## GET /emailCampaigns/{campaignId} ### Description Get an email campaign report. ### Method GET ### Endpoint /emailCampaigns/{campaignId} ``` -------------------------------- ### Get Products Source: https://github.com/sendinblue/apiv3-python-library/blob/master/docs/EcommerceApi.md Retrieves a list of all products, with options for filtering and pagination. ```APIDOC ## GET /products ### Description Return all your products with filtering and sorting options. ### Method GET ### Endpoint /products ### Parameters #### Query Parameters - **limit** (int) - Optional - Number of documents per page (default to 50) - **offset** (int) - Optional - Index of the first document in the page (default to 0) - **sort** (str) - Optional - Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed (default to desc) - **ids** (list[str]) - Optional - Filter by product ids - **name** (str) - Optional - Filter by product name, minimum 3 characters should be present for search - **price** (list[str]) - Optional - Filter by product price, like price[lte] - **categories** (list[str]) - Optional - Filter by category ids ### Response #### Success Response (200) - **GetProducts** - A list of products ### Authorization [api-key](../README.md#api-key), [partner-key](../README.md#partner-key) ```