Creating a Postman Collection for Sitecore Send (Moosend)

When working with various REST APIs it’s nice to be able to manage your sample and test requests in a single location. In a previous post, I introduced the Sitecore CDP REST APIs and shared my Postman collection. In this post, I will show you how to create a collection for Sitecore Send (Moosend). The good news Moosend provides an API Blueprint specification available here. However, you are not able to import this document directly into Postman. In this post, I will show you how you can convert this Blueprint spec so it can be imported into postman and automatically generate a collection of requests for testing and development with Moosend.

1. API Blueprint Converters

While you cannot import an API Blueprint specification into postman as it’s not a supported import format (currently) there are several tools available online and open-source that will convert Blueprint to other supported specifications like OpenAPI or even convert to Postman. I decided to go with apib2swagger as it is open source, maintained, and seemed pretty straightforward to install and use. They also just added support for OpenApi 3.0.3 while I was in the process of checking it out (version 13.0.1).

2. Install and run converter

To install the apib2Swaggger run the following make sure you install 13.0.1 or higher:

  npm install -g apib2swagger@13.0.1

Download a copy of the Moosend blueprint spec and run the following command to convert it to OpenApi3 .json:

apib2swagger -i moosendapp.apib –open-api-3 -o moosendapp-openapi3.json

3 Verify the Converted File

We can verify the conversion if we open it in Swagger Editor. There were a handful of errors but nothing major and these won’t prevent me from importing into Postman and these could be corrected here or once imported:

4. Import into postman

Now all I have to do is import my converted file into Postman:

Boom! Postman creates our lovely Sitecore Send (Moosend) collection:

5. Authentication

Authentication is achieved through the use of an API key. Before you can use the collection you need an API key for your account. The API key is included in all the requests sent to Moosend. When I look at the imported collection there is a hardcoded apiKey (it’s not mine), this is specified in all the requests. It is included in the download blueprint specification.

Ideally, this should be a variable as you most likely will be working with different accounts. This can be easily replaced using the inbuilt find and replace feature in postman and replacing it with {{apiKey}}, alternatively, replace before importing the converted open API spec. We can then create a new apiKey variable and populate it with your own apiKey. You can obtain your API key if you head over to Moosend -> Settings -> api key.

Variables and Path Variables

The imported collection has several global variables the following is a list including the API key we replaced.

VariableDescriptionExamples
baseUrlthe base URL for the moosend apihttps://api.moosend.com/v3
FormatThe format of the request and responsejson
PageSizeThe page size used for paging of the results.10
StatusThe status of the mailing list
SubscriberIDUnique Subscriber Id11610245-4749-4eb6-9d32-563a3ade4f10
PageThe current page using when paging results.1
TypeSent
apiKeyYour unique Moosend API key26245e43-f1c3-44ee-92ad-a6fc5a93856d

While global variables are usually fairly static path variables are more dynamic and change with each request i.e. you receive a response from a request and you use response value(s) as the path variable for another request.

Documented Examples

The imported collection also contains the documentation and an example response under each request.

My postman collection is available on GitHub as a json file. You can import it into Postman and use it when working with your own Sitecore Send instance.

Enjoy some REST!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s