Package io.mailtrap.api.emailcampaigns
Interface EmailCampaigns
- All Known Implementing Classes:
EmailCampaignsImpl
public interface EmailCampaigns
Email Campaigns API. Manage email marketing campaigns and retrieve their performance
statistics.
These endpoints are token-scoped: the account is resolved from the API token, so the path takes no account id.
-
Method Summary
Modifier and TypeMethodDescriptioncancelEmailCampaign(long emailCampaignId) Cancel ascheduledcampaign, returning it to thedraftstate.createEmailCampaign(CreateEmailCampaign request) Create a new email campaign in thedraftstate.voiddeleteEmailCampaign(long emailCampaignId) Delete an email campaign.getEmailCampaign(long emailCampaignId) Get a single email campaign by ID.List the account's email campaigns, newest first.getEmailCampaignStats(long emailCampaignId, EmailCampaignStatsFilter filter) Get aggregated performance statistics for an email campaign.resetEmailCampaign(long emailCampaignId) Reset ascheduledcampaign back to thedraftstate.scheduleEmailCampaign(long emailCampaignId, ScheduleEmailCampaignRequest request) Schedule adraftcampaign to start sending at a future time.startEmailCampaign(long emailCampaignId) Start sending adraftcampaign immediately.terminateEmailCampaign(long emailCampaignId) Terminate a campaign that is currently sending (started,queuedorpaused), aborting the in-flight send.updateEmailCampaign(long emailCampaignId, UpdateEmailCampaign request) Update an existingdraftemail campaign.
-
Method Details
-
getEmailCampaigns
List the account's email campaigns, newest first.- Parameters:
filter- filtering and pagination parameters;nullfor the first page with API defaults- Returns:
- a page of campaigns and the pagination metadata
-
createEmailCampaign
Create a new email campaign in thedraftstate.- Parameters:
request- the campaign attributes (name,domainId,fromLocalPartand a templatesubjectare required)- Returns:
- the created email campaign
-
getEmailCampaign
Get a single email campaign by ID.- Parameters:
emailCampaignId- unique email campaign ID- Returns:
- the email campaign
-
updateEmailCampaign
Update an existingdraftemail campaign. Only the provided attributes are changed.- Parameters:
emailCampaignId- unique email campaign IDrequest- the attributes to update- Returns:
- the updated email campaign
-
deleteEmailCampaign
void deleteEmailCampaign(long emailCampaignId) Delete an email campaign. Only a campaign in thedraftstate can be deleted.- Parameters:
emailCampaignId- unique email campaign ID
-
startEmailCampaign
Start sending adraftcampaign immediately.- Parameters:
emailCampaignId- unique email campaign ID- Returns:
- the started email campaign
-
scheduleEmailCampaign
EmailCampaignResponse scheduleEmailCampaign(long emailCampaignId, ScheduleEmailCampaignRequest request) Schedule adraftcampaign to start sending at a future time. The scheduled time is reported back incurrentStateMetadata.scheduledAt.- Parameters:
emailCampaignId- unique email campaign IDrequest- when to start sending the campaign- Returns:
- the scheduled email campaign
-
cancelEmailCampaign
Cancel ascheduledcampaign, returning it to thedraftstate.- Parameters:
emailCampaignId- unique email campaign ID- Returns:
- the cancelled email campaign
-
terminateEmailCampaign
Terminate a campaign that is currently sending (started,queuedorpaused), aborting the in-flight send.- Parameters:
emailCampaignId- unique email campaign ID- Returns:
- the terminated email campaign
-
resetEmailCampaign
Reset ascheduledcampaign back to thedraftstate.- Parameters:
emailCampaignId- unique email campaign ID- Returns:
- the reset email campaign
-
getEmailCampaignStats
EmailCampaignStatsResponse getEmailCampaignStats(long emailCampaignId, EmailCampaignStatsFilter filter) Get aggregated performance statistics for an email campaign. If the campaign has never been started, all counts and rates are returned as0.- Parameters:
emailCampaignId- unique email campaign IDfilter- aggregation window;nullfor the whole period since the campaign was last started- Returns:
- aggregated campaign statistics
-