Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Brevo/Brevo_Add_contacts_to_list.ipynb
2973 views
Kernel: Python 3

Naas

Brevo - Add contacts to list

Give Feedback | Bug report

Tags: #brevo #contacts #lists #create #snippet

Last update: 2024-05-30 (Created: 2024-05-30)

Description: This notebook add contacts to a list in Brevo.

Input

Import libraries

import requests

Setup variables

  • api_key: Brevo API Key

  • list_id: Brevo List ID

  • emails: List of emails to be added

api_key = "YOUR_BREVO_API_KEY" list_id = 20 emails = []

Model

Get contacts in a list

def add_contact_to_list(api_key, list_id, emails): url = f"https://api.brevo.com/v3/contacts/lists/{list_id}/contacts/add" payload = {"emails": emails} headers = { "api-key": api_key, "accept": "application/json", "content-type": "application/json" } res = requests.post(url, json=payload, headers=headers) if res.status_code == 200: return res.json() result = add_contact_to_list(api_key, list_id, emails)

Output

Display result

result