All articles

How to Send Transactional Emails with the SendHustle API

API·September 17, 2024·By Sam Greenspan·7 min read
How to Send Transactional Emails with the SendHustle API

You can send full-fledged email campaigns using the SendHustle API.

But… you can also use the SendHustle API to send single, one-off messages through your Gmail/Google Workspace account.

Those are transactional emails; emails that go out immediately after, generally, a user takes an action.

In this guide, I’ll expand on the SendHustle API docs to dig deeper into the process of sending a transactional email.

By sending transactional emails through the SendHustle API, your messages are sent through your Gmail/Google Workspace account.

That means you’ll find them in your Gmail Sent folder (which is great for searchability or future list building). And they’re still trackable inside SendHustle

Here’s how to send them.

Send Transactional Emails with the SendHustle API: Table of Contents

Getting Your API Key and Using it to Authenticate Into the API

To use the SendHustle API you’ll need to generate or retrieve a key, then pass it to SendHustle.

Generating or retrieving your API key

Go to the SendHustle dashboard. Click on the Settings icon on the top right. In the left fly-out panel, scroll down to API Keys, then click into that section and click on Manage API Keys.

Going to the manage API keys section of the GMass dashboard.

If you don’t have any API keys generated already, click on the red button to create one. (If you already have a key, you can always make a new one as well for this particular project.)

Create a new API key

Now you’ll be able to copy that API key by clicking the clipboard icon to its right.

If you ever need this key again, you can come back to this part of the SendHustle dashboard to grab it.

Copying your API key

Using your API key for authentication

There are two ways you can pass your API key to SendHustle.

Option 1: You can pass your key with a HTTP header, using X-apikey.

Option 2: You can include it as a query string after you call any SendHustle API endpoint by adding apikey=your API key.

Every SendHustle API endpoint starts with https://api.gmass.co/api/. For transactional emails, you could use https://api.gmass.co/api/transactional?apikey=whatever-whatever-whatever-whatever.

For my examples in this article I’m using the Swagger site for the SendHustle API. If you want to run tests there yourself, just paste your API key in the form field on the top right of the page.

Composing and Sending Your Transactional Email

There’s only one transactional email method in the SendHustle API which keeps this process relatively simple.

Using the transactional email endpoint, you’ll need to designate a fromEmail, fromName, to, subject, and message.

You can put multiple addresses in the to: field; just separate them with commas or semicolons.

All other parameters are optional.

Your message can be plain text or include HTML elements as you put it together for the message parameter.

The basic parameters for sending a transactional email via the GMass API

And the result:

The sent message and headers

So… that’s pretty much it. I’m going to cover the optional settings next but really, from here you’re already good to go on sending one-off transactional emails via the SendHustle API.

That was fast.

Optional Settings for Transactional Emails Through the SendHustle API

There are a handful of optional settings you can use as you fine-tune your transactional emails.

Before I get into them, it’ll be helpful to briefly cover the relationship between the transactional email and SendHustle’s transactional SMTP relay service.

The SendHustle transactional email API powers SendHustle’s transactional SMTP relay service

For those unfamiliar, SendHustle offers a free transactional email SMTP relay, smtp.gmass.co, for lower-volume transactional emailers. (Even people who aren’t paying SendHustle users.)

This service actually uses the SendHustle transactional API method to send those messages.

So when you’re sending transactional emails via the API, you’re skipping the whole relay step and just getting down to the roots.

This will come up a bit as we go through the optional settings — especially if you’ve been using the SendHustle transactional SMTP relay.

Optional open and click tracking

SendHustle can include open and/or click tracking on the transactional emails you send through the SendHustle API.

If you’d like to do so, set the openTrack and/or clickTrack to parameters to true.

Note: For click tracking, you’ll need to send an HTML email where you link a word or words. For example, <a href=”https://whatever.com”>click here”</a>. Straight URLs, like https://www.whatever.com, are not trackable. Quick explanation: We can’t replace a URL with a tracking link, as it’s a big spam red flag to put a URL in an email and have it link to a different destination.

Another note: If you use the SendHustle transactional SMTP relay and you’ve designated tracking settings in the SendHustle dashboard, the settings here are unrelated to those. So if you have open tracking turned on for emails with the transactional SMTP relay but, for your application using the API, you have openTrack set to false, opens will not be tracked.

If you have a custom tracking domain set up in the SendHustle dashboard, it will be used for your tracking links.

Setting open and click tracking via the API

And the result:

A transactional email sent with open and click tracking

You can see the analytics from all your transactional emails in the SendHustle dashboard. On the main screen of the dashboard there’s a tab where you can check the details of your transactional emails.

Checking the analytics of transactional emails in the GMass dashboard

Using your own SMTP

By default, SendHustle will send the transactional emails through your Gmail account, and with that, through Google’s servers.

However, if you’d like to send through your own SMTP service, you have that option as well with the useCustomerSmtp parameter.

Make sure you have a SMTP server set up in the SendHustle dashboard; that will be the SMTP service that SendHustle uses if you set this parameter to true.

And if you’ve configured DKIM in your account settings, your transactional emails will now be DKIM signed.

If you set the useCustomerSmtp parameter to true and do not have a SMTP server connected to your SendHustle account, the API will error out.

Using an SMTP server

I am on SendHustle’s in-house SMTP server here. That’s different from our transactional SMTP relay service. Here’s a helpful article on the various SMTP offerings from SendHustle if you’d like more details (and disambiguation) on all the options.

You may’ve noticed another parameter here in the /api/transactional endpoint called smtpRelay. You do not need to set that, and it won’t affect anything if you do. That parameter is for internal use when someone is sending through the API via the SendHustle transactional SMTP relay.

To demonstrate using a SMTP server, I’ll send transactional emails to SendHustle’s free email analyzer tool with useCustomerSmtp set to both true and false.

Here’s the result when I set useCustomerSmtp to true. The email goes through my designated SMTP service:

A transactional email sent through an SMTP server

And here’s the result when I set useCustomerSmtp to false. The email goes through Google’s servers:

A transactional email sent through Gmail

Threading to a prior campaign

The last parameter we’ll cover is threadToCampaign, which enables you to send your transactional email as a reply to a prior campaign.

You can get the ID of the previous campaign in a variety of ways, like checking the campaign analytics or via the SendHustle dashboard. You can also get campaign IDs through the SendHustle API, using the /api/campaigns endpoint.

Threading to a campaign

That transactional email will now go out like a reply to that campaign in the same thread.

The result for a threaded transactional email sent through the GMass API

And as you can see, I still had to set a subject for the transactional email in the API — but it’s not included here as the message went out as a reply.

Unsubscribe and bounce lists

The transactional email system will check addresses against your unsubscribe and bounce lists in SendHustle and suppress any emails to people who’ve opted out or bounced in the past.

Ready to Send Transactional Emails Using the SendHustle API?

As I said earlier, sending a transactional email with the SendHustle API is really not a complicated process.

  • Use the /api/transactional endpoint to create and send your message.
  • Set any optional settings you might want like open/click tracking, whether to send through a SMTP server or not, and threading to prior campaigns.

If you’re ready to use the SendHustle API to send transactional emails from your own applications, good news: Full API access is included in SendHustle’s Premium, Professional, and Team plans.

(You can find pricing info for those on the SendHustle pricing page.)

And with all those plans you can also send full email campaigns inside Gmail using the SendHustle Chrome extension.

With unlimited emails, campaigns, and contacts, see why 400,000+ people love SendHustle and have given us an average of 4.8 out of 5 stars across tens of thousands of reviews.

You can try SendHustle for free with no credit card required.

Download the Chrome extension and you’ll be up and running — and ready to use the API — in a matter of minutes.

See why 99% of users say they’ve had their best deliverability ever with SendHustle


Email marketing, cold email, and mail merge all in one tool — that works inside Gmail


TRY SendHustle FOR FREE

Download Chrome extension - 30 second install!
No credit card required
Love what you're reading? Get the latest email strategy and tips & stay in touch.

Send your next campaign from Gmail

SendHustle brings mail merge, follow-ups, and tracking right into the inbox you already use.

Start free