How to Run SparkPost in Postman

Steve Tuck
Apr. 8, 2016 by Steve Tuck

postman

In case you missed the announcement last month, our SparkPost API documentation now comes with a “Run in Postman” button:

Untitled

What Does That Mean?

Cool! We’ve got a nifty new button. But what does that mean? And how do I know whether or not I’ll need (or want) it?
Here are the basics:

  • Are you (or one of your other developers) digging into the SparkPost API yourself, in addition to using the automated systems built around it?
  • Are you a little uncomfortable with the details of HTTP requests?
  • Do you have a hard time remembering what particular cURL command to use?

Postman to the rescue! It parses your API request and response and displays them in more manageable formats. It also simplifies the creation of API requests, which means you’re off the hook for finding the arcane syntax that will pull the precise information you’re in search of.

As Dave mentions in his blog post:

Postman gives less-technical users a way to make arbitrary HTTP requests using a point and click user interface. Collections make it easy to organize your requests and, to a point, share them. Environments make it easy to switch authentication keys and make other things configurable without editing each request.

Is your interest piqued? Good! Then without further ado, let’s dive in…

Getting Started

So what do you need to do to start using this?

Firstly, when you click this button, you’ll be directed to open this collection with your installed Postman app.

You will then see the “SparkPost API” collection show up in the left-side pane, and you can expand the various folders in the collection.

Untitled1

There are currently 76 different request types in the collection; we’ll be adding more as the API becomes even richer.

You can try running these right away – for example Message Events / Get Samples.  You’ll see results come right back in the Response window.

postman

This particular request works straight away, because just getting samples back doesn’t require authorization.

Setting up Authorization

If you try most of the other requests – such as “List All Sending Domains” – you’ll get a message saying

because each account’s data is private. You’ll need an API key set up to access this information.

postman

Here’s where a neat feature of Postman comes in. The Environments collection is set up to look for a Postman variable called {{API_KEY}}.  You can see this by viewing the request headers.

postman

If you don’t have an API key yet, you’ll want to create one.

Once you have your API key in hand, go to “Manage Environments.”

postman

Choose Add, and type a name, e.g. “My SparkPost setup.”  Then add your key and value.

Key should be just the words API_KEY  (without the curly braces this time), and the value is your specific hex string.

postman

Hit Add.  Choose “My SparkPost Setup” from your drop-down list of environments in Postman.

postman

Re-run your API request, and your authorization will be used for each of the collection’s requests without any further editing.

Here’s what I get back from “List all Sending Domains” — I can see my domain is set up and ready to go.

Untitled8

Now you’re set to explore the other requests in this collection.  Happy exploring!

Related Content

Seasonal Marketing Strategies: 3 Emails I’m Loving This Summer

Breaking down the design, elements and creative seasonal marketing strategies of three of our favorite summer email campaigns.

read more

5 Tips to Grow Your E-Commerce Business with Email

Email is a key channel for e-commerce businesses looking to thrive and grow. Here are our top 5 tips for growing your e-commerce business with email.

read more

How to Determine the Subaccount ID from a Subaccount API Key

For ESPs needing to determine a subaccount CID to pull analytics data from SparkPost, this hack allows you to do so using the subaccount API.

read more

Get started and start sending

Try SparkPost and see how easy it is to deliver your app’s email on time and to the inbox.

Try Free

Send this to a friend