Skip to content

Latest commit

 

History

History
790 lines (588 loc) · 30.6 KB

EmailCampaignsApi.md

File metadata and controls

790 lines (588 loc) · 30.6 KB

brevo_python.EmailCampaignsApi

All URIs are relative to https://api.brevo.com/v3

Method HTTP request Description
create_email_campaign POST /emailCampaigns Create an email campaign
delete_email_campaign DELETE /emailCampaigns/{campaignId} Delete an email campaign
email_export_recipients POST /emailCampaigns/{campaignId}/exportRecipients Export the recipients of an email campaign
get_ab_test_campaign_result GET /emailCampaigns/{campaignId}/abTestCampaignResult Get an A/B test email campaign results
get_email_campaign GET /emailCampaigns/{campaignId} Get an email campaign report
get_email_campaigns GET /emailCampaigns Return all your created email campaigns
get_shared_template_url GET /emailCampaigns/{campaignId}/sharedUrl Get a shared template url
send_email_campaign_now POST /emailCampaigns/{campaignId}/sendNow Send an email campaign immediately, based on campaignId
send_report POST /emailCampaigns/{campaignId}/sendReport Send the report of a campaign
send_test_email POST /emailCampaigns/{campaignId}/sendTest Send an email campaign to your test list
update_campaign_status PUT /emailCampaigns/{campaignId}/status Update an email campaign status
update_email_campaign PUT /emailCampaigns/{campaignId} Update an email campaign
upload_image_to_gallery POST /emailCampaigns/images Upload an image to your account's image gallery

create_email_campaign

CreateModel create_email_campaign(email_campaigns)

Create an email campaign

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
email_campaigns = brevo_python.CreateEmailCampaign() # CreateEmailCampaign | Values to create a campaign

try:
    # Create an email campaign
    api_response = api_instance.create_email_campaign(email_campaigns)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->create_email_campaign: %s\n" % e)

Parameters

Name Type Description Notes
email_campaigns CreateEmailCampaign Values to create a campaign

Return type

CreateModel

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delete_email_campaign

delete_email_campaign(campaign_id)

Delete an email campaign

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | id of the campaign

try:
    # Delete an email campaign
    api_instance.delete_email_campaign(campaign_id)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->delete_email_campaign: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int id of the campaign

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

email_export_recipients

CreatedProcessId email_export_recipients(campaign_id, recipient_export=recipient_export)

Export the recipients of an email campaign

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
recipient_export = brevo_python.EmailExportRecipients() # EmailExportRecipients | Values to send for a recipient export request (optional)

try:
    # Export the recipients of an email campaign
    api_response = api_instance.email_export_recipients(campaign_id, recipient_export=recipient_export)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->email_export_recipients: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
recipient_export EmailExportRecipients Values to send for a recipient export request [optional]

Return type

CreatedProcessId

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_ab_test_campaign_result

AbTestCampaignResult get_ab_test_campaign_result(campaign_id)

Get an A/B test email campaign results

Obtain winning version of an A/B test email campaign

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the A/B test campaign

try:
    # Get an A/B test email campaign results
    api_response = api_instance.get_ab_test_campaign_result(campaign_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->get_ab_test_campaign_result: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the A/B test campaign

Return type

AbTestCampaignResult

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_email_campaign

GetEmailCampaign get_email_campaign(campaign_id, statistics=statistics)

Get an email campaign report

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
statistics = 'statistics_example' # str | Filter on the type of statistics required. Example **globalStats** value will only fetch globalStats info of the campaign in returned response. (optional)

try:
    # Get an email campaign report
    api_response = api_instance.get_email_campaign(campaign_id, statistics=statistics)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->get_email_campaign: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
statistics str Filter on the type of statistics required. Example globalStats value will only fetch globalStats info of the campaign in returned response. [optional]

Return type

GetEmailCampaign

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_email_campaigns

GetEmailCampaigns get_email_campaigns(type=type, status=status, statistics=statistics, start_date=start_date, end_date=end_date, limit=limit, offset=offset, sort=sort, exclude_html_content=exclude_html_content)

Return all your created email campaigns

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
type = 'type_example' # str | Filter on the type of the campaigns (optional)
status = 'status_example' # str | Filter on the status of the campaign (optional)
statistics = 'statistics_example' # str | Filter on the type of statistics required. Example **globalStats** value will only fetch globalStats info of the campaign in returned response.This option only returns data for events occurred in the last 6 months.For older campaigns, it’s advisable to use the **Get Campaign Report** endpoint. (optional)
start_date = 'start_date_example' # str | Mandatory if endDate is used. Starting (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. Prefer to pass your timezone in date-time format for accurate result ( only available if either 'status' not passed and if passed is set to 'sent' ) (optional)
end_date = 'end_date_example' # str | Mandatory if startDate is used. Ending (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. Prefer to pass your timezone in date-time format for accurate result ( only available if either 'status' not passed and if passed is set to 'sent' ) (optional)
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)
exclude_html_content = true # bool | Use this flag to exclude htmlContent from the response body. If set to **true**, htmlContent field will be returned as empty string in the response body (optional)

try:
    # Return all your created email campaigns
    api_response = api_instance.get_email_campaigns(type=type, status=status, statistics=statistics, start_date=start_date, end_date=end_date, limit=limit, offset=offset, sort=sort, exclude_html_content=exclude_html_content)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->get_email_campaigns: %s\n" % e)

Parameters

Name Type Description Notes
type str Filter on the type of the campaigns [optional]
status str Filter on the status of the campaign [optional]
statistics str Filter on the type of statistics required. Example globalStats value will only fetch globalStats info of the campaign in returned response.This option only returns data for events occurred in the last 6 months.For older campaigns, it’s advisable to use the Get Campaign Report endpoint. [optional]
start_date str Mandatory if endDate is used. Starting (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. Prefer to pass your timezone in date-time format for accurate result ( only available if either 'status' not passed and if passed is set to 'sent' ) [optional]
end_date str Mandatory if startDate is used. Ending (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. Prefer to pass your timezone in date-time format for accurate result ( only available if either 'status' not passed and if passed is set to 'sent' ) [optional]
limit int Number of documents per page [optional] [default to 50]
offset int Index of the first document in the page [optional] [default to 0]
sort 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]
exclude_html_content bool Use this flag to exclude htmlContent from the response body. If set to true, htmlContent field will be returned as empty string in the response body [optional]

Return type

GetEmailCampaigns

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_shared_template_url

GetSharedTemplateUrl get_shared_template_url(campaign_id)

Get a shared template url

Get a unique URL to share & import an email template from one Brevo account to another.

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign or template

try:
    # Get a shared template url
    api_response = api_instance.get_shared_template_url(campaign_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->get_shared_template_url: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign or template

Return type

GetSharedTemplateUrl

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

send_email_campaign_now

send_email_campaign_now(campaign_id)

Send an email campaign immediately, based on campaignId

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign

try:
    # Send an email campaign immediately, based on campaignId
    api_instance.send_email_campaign_now(campaign_id)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->send_email_campaign_now: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

send_report

send_report(campaign_id, send_report)

Send the report of a campaign

A PDF will be sent to the specified email addresses

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
send_report = brevo_python.SendReport() # SendReport | Values for send a report

try:
    # Send the report of a campaign
    api_instance.send_report(campaign_id, send_report)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->send_report: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
send_report SendReport Values for send a report

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

send_test_email

send_test_email(campaign_id, email_to)

Send an email campaign to your test list

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
email_to = brevo_python.SendTestEmail() # SendTestEmail | 

try:
    # Send an email campaign to your test list
    api_instance.send_test_email(campaign_id, email_to)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->send_test_email: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
email_to SendTestEmail

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update_campaign_status

update_campaign_status(campaign_id, status)

Update an email campaign status

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
status = brevo_python.UpdateCampaignStatus() # UpdateCampaignStatus | Status of the campaign

try:
    # Update an email campaign status
    api_instance.update_campaign_status(campaign_id, status)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->update_campaign_status: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
status UpdateCampaignStatus Status of the campaign

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update_email_campaign

update_email_campaign(campaign_id, email_campaign)

Update an email campaign

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
campaign_id = 789 # int | Id of the campaign
email_campaign = brevo_python.UpdateEmailCampaign() # UpdateEmailCampaign | Values to update a campaign

try:
    # Update an email campaign
    api_instance.update_email_campaign(campaign_id, email_campaign)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->update_email_campaign: %s\n" % e)

Parameters

Name Type Description Notes
campaign_id int Id of the campaign
email_campaign UpdateEmailCampaign Values to update a campaign

Return type

void (empty response body)

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

upload_image_to_gallery

UploadImageModel upload_image_to_gallery(upload_image)

Upload an image to your account's image gallery

Example

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.EmailCampaignsApi(brevo_python.ApiClient(configuration))
upload_image = brevo_python.UploadImageToGallery() # UploadImageToGallery | Parameters to upload an image

try:
    # Upload an image to your account's image gallery
    api_response = api_instance.upload_image_to_gallery(upload_image)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling EmailCampaignsApi->upload_image_to_gallery: %s\n" % e)

Parameters

Name Type Description Notes
upload_image UploadImageToGallery Parameters to upload an image

Return type

UploadImageModel

Authorization

api-key, partner-key

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]