Sitecore Send APIs

Sitecore Send APIs

Introduction


The result repository: Sitecore Send APIs (Unofficial)


During Sitecore SUGCON EU 2024 in Dublin I attended Alex Doroshenko's presentation "It is all about APIs". I really enjoyed it and I share the same passion and love to the APIs as him: APIs are powerful and it's always good to have an option: do something using UI or API.

One part of his presentation was about Sitecore Send APIs. Overall there are not so much information about it, apart from Documented API.

So I came up with an idea: why not to summarize all Sitecore Send APIs references available (together with some experience I have with other APIs) into one place and share it with a community, so here's Git repository about it.

Structure

.NET Client

.NET Client for Sitecore Send is published to Nuget and can be used in your application.

Usage is the following:

var apiConfiguration = new ApiConfiguration
{
    ApiKey = "[YOUR API KEY]",
};

// or any other service
IMailingListService mailingListService = new MailingListService(apiConfiguration);

var response = await mailingListService.GetAllMailingLists();

// ensure response is not null and Success is true
if (response is {Success: true})
{
    IList<MailingList>? allLists = response.Data?.MailingLists;
    // handle allLists
}

Currently it's a wrapper around Sitecore Send Documented API. But I'm planning to extend it.

I also implemented integration tests, so you can reference README for running them. Also those tests can be used as example of usage the client.

Postman

Postman collection was generated based on previously generated for Moosend (see article from Neil Killen for more details).

It contains the following folders:

  • Public API - documented API
  • Internal API - some internal API, which is used in Sitecore Send admin panel.
  • Tracking API - API requests used to track Sitecore Send events

Features:

  • apiKey should be configured on Environment level and is automatically used in all requests
  • internal variables, e.g. CampaignID or mailingListId - you can retrieve it once by id and then use in other get statistics / update requests

Configure API Key:

configure api key

Variable set is implemented using Tests section:

set Postman variable

Open API (Swagger) specification

One more thing was to provide a way to generate API clients for any language (not only C#). So best tool I know is Open API.

Using documentation and Chat GPT I generated really large specification file - 3308 lines currently.

You just need to authorize and run requests:

Swagger

Client for your language can be generated just directly from SwaggerHub:

Open API client generate

Just to show the process of generate in Chat GPT:

Open API generation process with Chat GPT

Quite long and monotonous work, but it was worth it.

Current state and contributions

.Net SDK library is still in progress and you can check roadmap in the dotnet README.

If you're Sitecore Send enthusiast and have some ideas how to improve (or something is not working / you found a bug) - fill free to contact me via email, in Sitecore Slack or in X.

Conclusion

I hope this repository can be place, where any developer working with Sitecore Send can find something useful for everyday work.

Later I'll share some examples how to use Sitecore Send APIs for automation and make your developer's life easier.