-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaddList.py
33 lines (28 loc) · 1.08 KB
/
addList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ElasticEmail
from ElasticEmail.apis.tags import lists_api
from ElasticEmail.model.list_payload import ListPayload
from pprint import pprint
# Defining the host is optional and defaults to https://api.elasticemail.com/v4
configuration = ElasticEmail.Configuration()
# Configure API key authorization: apikey
configuration.api_key['apikey'] = 'YOUR_API_KEY'
"""
Add list
Example api call that creates a new contacts list.
Emails – An array of existing contact emails that should be added to this list. Leave empty for all contacts
"""
with ElasticEmail.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = lists_api.ListsApi(api_client)
list_payload = ListPayload(
ListName="Best contacts",
AllowUnsubscribe=True,
Emails=[
],
) # ListPayload |
try:
api_response = api_instance.lists_post(body = list_payload)
pprint(api_response)
except ElasticEmail.ApiException as e:
print("Exception when calling ListsApi->lists_post: %s\n" % e)