Skip to content

ElasticEmail - the C# library for the Elastic Email REST API

Notifications You must be signed in to change notification settings

ElasticEmail/elasticemail-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElasticEmail - the C# library for the Elastic Email REST API

This API is based on the REST API architecture, allowing the user to easily manage their data with this resource-based approach.

Every API call is established on which specific request type (GET, POST, PUT, DELETE) will be used.

The API has a limit of 20 concurrent connections and a hard timeout of 600 seconds per request.

To start using this API, you will need your Access Token (available here). Remember to keep it safe. Required access levels are listed in the given request’s description.

Downloadable library clients can be found in our Github repository here

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 4.0.0
  • SDK version: 4.0.24
  • Generator version: 7.7.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Generate the DLL using your preferred tool (e.g. dotnet build)

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using ElasticEmail.Api;
using ElasticEmail.Client;
using ElasticEmail.Model;

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using ElasticEmail.Api;
using ElasticEmail.Client;
using ElasticEmail.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.elasticemail.com/v4";
            // Configure API key authorization: apikey
            config.ApiKey.Add("X-ElasticEmail-ApiKey", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("X-ElasticEmail-ApiKey", "Bearer");

            var apiInstance = new CampaignsApi(config);
            var name = "name_example";  // string | Name of Campaign to delete

            try
            {
                // Delete Campaign
                apiInstance.CampaignsByNameDelete(name);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling CampaignsApi.CampaignsByNameDelete: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

All URIs are relative to https://api.elasticemail.com/v4

Class Method HTTP request Description
CampaignsApi CampaignsByNameDelete DELETE /campaigns/{name} Delete Campaign
CampaignsApi CampaignsByNameGet GET /campaigns/{name} Load Campaign
CampaignsApi CampaignsByNamePut PUT /campaigns/{name} Update Campaign
CampaignsApi CampaignsGet GET /campaigns Load Campaigns
CampaignsApi CampaignsPost POST /campaigns Add Campaign
ContactsApi ContactsByEmailDelete DELETE /contacts/{email} Delete Contact
ContactsApi ContactsByEmailGet GET /contacts/{email} Load Contact
ContactsApi ContactsByEmailPut PUT /contacts/{email} Update Contact
ContactsApi ContactsDeletePost POST /contacts/delete Delete Contacts Bulk
ContactsApi ContactsExportByIdStatusGet GET /contacts/export/{id}/status Check Export Status
ContactsApi ContactsExportPost POST /contacts/export Export Contacts
ContactsApi ContactsGet GET /contacts Load Contacts
ContactsApi ContactsImportPost POST /contacts/import Upload Contacts
ContactsApi ContactsPost POST /contacts Add Contact
EmailsApi EmailsByMsgidViewGet GET /emails/{msgid}/view View Email
EmailsApi EmailsByTransactionidStatusGet GET /emails/{transactionid}/status Get Status
EmailsApi EmailsMergefilePost POST /emails/mergefile Send Bulk Emails CSV
EmailsApi EmailsPost POST /emails Send Bulk Emails
EmailsApi EmailsTransactionalPost POST /emails/transactional Send Transactional Email
EventsApi EventsByTransactionidGet GET /events/{transactionid} Load Email Events
EventsApi EventsChannelsByNameExportPost POST /events/channels/{name}/export Export Channel Events
EventsApi EventsChannelsByNameGet GET /events/channels/{name} Load Channel Events
EventsApi EventsChannelsExportByIdStatusGet GET /events/channels/export/{id}/status Check Channel Export Status
EventsApi EventsExportByIdStatusGet GET /events/export/{id}/status Check Export Status
EventsApi EventsExportPost POST /events/export Export Events
EventsApi EventsGet GET /events Load Events
FilesApi FilesByNameDelete DELETE /files/{name} Delete File
FilesApi FilesByNameGet GET /files/{name} Download File
FilesApi FilesByNameInfoGet GET /files/{name}/info Load File Details
FilesApi FilesGet GET /files List Files
FilesApi FilesPost POST /files Upload File
InboundRouteApi InboundrouteByIdDelete DELETE /inboundroute/{id} Delete Route
InboundRouteApi InboundrouteByIdGet GET /inboundroute/{id} Get Route
InboundRouteApi InboundrouteByIdPut PUT /inboundroute/{id} Update Route
InboundRouteApi InboundrouteGet GET /inboundroute Get Routes
InboundRouteApi InboundrouteOrderPut PUT /inboundroute/order Update Sorting
InboundRouteApi InboundroutePost POST /inboundroute Create Route
ListsApi ListsByListnameContactsGet GET /lists/{listname}/contacts Load Contacts in List
ListsApi ListsByNameContactsPost POST /lists/{name}/contacts Add Contacts to List
ListsApi ListsByNameContactsRemovePost POST /lists/{name}/contacts/remove Remove Contacts from List
ListsApi ListsByNameDelete DELETE /lists/{name} Delete List
ListsApi ListsByNameGet GET /lists/{name} Load List
ListsApi ListsByNamePut PUT /lists/{name} Update List
ListsApi ListsGet GET /lists Load Lists
ListsApi ListsPost POST /lists Add List
SecurityApi SecurityApikeysByNameDelete DELETE /security/apikeys/{name} Delete ApiKey
SecurityApi SecurityApikeysByNameGet GET /security/apikeys/{name} Load ApiKey
SecurityApi SecurityApikeysByNamePut PUT /security/apikeys/{name} Update ApiKey
SecurityApi SecurityApikeysGet GET /security/apikeys List ApiKeys
SecurityApi SecurityApikeysPost POST /security/apikeys Add ApiKey
SecurityApi SecuritySmtpByNameDelete DELETE /security/smtp/{name} Delete SMTP Credential
SecurityApi SecuritySmtpByNameGet GET /security/smtp/{name} Load SMTP Credential
SecurityApi SecuritySmtpByNamePut PUT /security/smtp/{name} Update SMTP Credential
SecurityApi SecuritySmtpGet GET /security/smtp List SMTP Credentials
SecurityApi SecuritySmtpPost POST /security/smtp Add SMTP Credential
SegmentsApi SegmentsByNameDelete DELETE /segments/{name} Delete Segment
SegmentsApi SegmentsByNameGet GET /segments/{name} Load Segment
SegmentsApi SegmentsByNamePut PUT /segments/{name} Update Segment
SegmentsApi SegmentsGet GET /segments Load Segments
SegmentsApi SegmentsPost POST /segments Add Segment
StatisticsApi StatisticsCampaignsByNameGet GET /statistics/campaigns/{name} Load Campaign Stats
StatisticsApi StatisticsCampaignsGet GET /statistics/campaigns Load Campaigns Stats
StatisticsApi StatisticsChannelsByNameGet GET /statistics/channels/{name} Load Channel Stats
StatisticsApi StatisticsChannelsGet GET /statistics/channels Load Channels Stats
StatisticsApi StatisticsGet GET /statistics Load Statistics
SubAccountsApi SubaccountsByEmailCreditsPatch PATCH /subaccounts/{email}/credits Add, Subtract Email Credits
SubAccountsApi SubaccountsByEmailDelete DELETE /subaccounts/{email} Delete SubAccount
SubAccountsApi SubaccountsByEmailGet GET /subaccounts/{email} Load SubAccount
SubAccountsApi SubaccountsByEmailSettingsEmailPut PUT /subaccounts/{email}/settings/email Update SubAccount Email Settings
SubAccountsApi SubaccountsGet GET /subaccounts Load SubAccounts
SubAccountsApi SubaccountsPost POST /subaccounts Add SubAccount
SuppressionsApi SuppressionsBouncesGet GET /suppressions/bounces Get Bounce List
SuppressionsApi SuppressionsBouncesImportPost POST /suppressions/bounces/import Add Bounces Async
SuppressionsApi SuppressionsBouncesPost POST /suppressions/bounces Add Bounces
SuppressionsApi SuppressionsByEmailDelete DELETE /suppressions/{email} Delete Suppression
SuppressionsApi SuppressionsByEmailGet GET /suppressions/{email} Get Suppression
SuppressionsApi SuppressionsComplaintsGet GET /suppressions/complaints Get Complaints List
SuppressionsApi SuppressionsComplaintsImportPost POST /suppressions/complaints/import Add Complaints Async
SuppressionsApi SuppressionsComplaintsPost POST /suppressions/complaints Add Complaints
SuppressionsApi SuppressionsGet GET /suppressions Get Suppressions
SuppressionsApi SuppressionsUnsubscribesGet GET /suppressions/unsubscribes Get Unsubscribes List
SuppressionsApi SuppressionsUnsubscribesImportPost POST /suppressions/unsubscribes/import Add Unsubscribes Async
SuppressionsApi SuppressionsUnsubscribesPost POST /suppressions/unsubscribes Add Unsubscribes
TemplatesApi TemplatesByNameDelete DELETE /templates/{name} Delete Template
TemplatesApi TemplatesByNameGet GET /templates/{name} Load Template
TemplatesApi TemplatesByNamePut PUT /templates/{name} Update Template
TemplatesApi TemplatesGet GET /templates Load Templates
TemplatesApi TemplatesPost POST /templates Add Template
VerificationsApi VerificationsByEmailDelete DELETE /verifications/{email} Delete Email Verification Result
VerificationsApi VerificationsByEmailGet GET /verifications/{email} Get Email Verification Result
VerificationsApi VerificationsByEmailPost POST /verifications/{email} Verify Email
VerificationsApi VerificationsFilesByIdDelete DELETE /verifications/files/{id} Delete File Verification Result
VerificationsApi VerificationsFilesByIdResultDownloadGet GET /verifications/files/{id}/result/download Download File Verification Result
VerificationsApi VerificationsFilesByIdResultGet GET /verifications/files/{id}/result Get Detailed File Verification Result
VerificationsApi VerificationsFilesByIdVerificationPost POST /verifications/files/{id}/verification Start verification
VerificationsApi VerificationsFilesPost POST /verifications/files Upload File with Emails
VerificationsApi VerificationsFilesResultGet GET /verifications/files/result Get Files Verification Results
VerificationsApi VerificationsGet GET /verifications Get Emails Verification Results

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

apikey

  • Type: API key
  • API key parameter name: X-ElasticEmail-ApiKey
  • Location: HTTP header