You can send full-fledged email campaigns using the GMass API.
But… you can also use the GMass 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 GMass API docs to dig deeper into the process of sending a transactional email.
By sending transactional emails through the GMass 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 GMass.
Here’s how to send them.
Send Transactional Emails with the GMass API: Table of Contents
- Getting Your API Key and Using it to Authenticate Into the API
- Composing and Sending Your Transactional Email
- Optional Settings for Transactional Emails Through the GMass API
- Ready to Send Transactional Emails Using the GMass API?
Getting Your API Key and Using it to Authenticate Into the API
To use the GMass API you’ll need to generate or retrieve a key, then pass it to GMass.
Generating or retrieving your API key
Go to the GMass 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.
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.)
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 GMass dashboard to grab it.
Using your API key for authentication
There are two ways you can pass your API key to GMass.
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 GMass API endpoint by adding apikey=your API key.
Every GMass 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 GMass 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 GMass API which keeps this process relatively simple.
Using the transactional email endpoint, you’ll need to designate a fromEmail, fromName, to, subject, and message.
All other parameters are optional.
Your message can be plain text or include HTML elements as you put it together for the message parameter.
And the result:
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 GMass API.
That was fast.
Optional Settings for Transactional Emails Through the GMass 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 GMass’s transactional SMTP relay service.
The GMass transactional email API powers GMass’s transactional SMTP relay service
For those unfamiliar, GMass offers a free transactional email SMTP relay, smtp.gmass.co, for lower-volume transactional emailers. (Even people who aren’t paying GMass users.)
This service actually uses the GMass 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 GMass transactional SMTP relay.
Optional open and click tracking
GMass can include open and/or click tracking on the transactional emails you send through the GMass 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 GMass transactional SMTP relay and you’ve designated tracking settings in the GMass 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 GMass dashboard, it will be used for your tracking links.
And the result:
You can see the analytics from all your transactional emails in the GMass dashboard. On the main screen of the dashboard there’s a tab where you can check the details of your transactional emails.
Using your own SMTP
By default, GMass 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 GMass dashboard; that will be the SMTP service that GMass uses if you set this parameter to true.
If you set the useCustomerSmtp parameter to true and do not have a SMTP server connected to your GMass account, the API will error out.
I am on GMass’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 GMass 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 GMass transactional SMTP relay.
To demonstrate using a SMTP server, I’ll send transactional emails to GMass’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:
And here’s the result when I set useCustomerSmtp to false. The email goes through Google’s servers:
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 GMass dashboard. You can also get campaign IDs through the GMass API, using the /api/campaigns endpoint.
That transactional email will now go out like a reply to that campaign in the same thread.
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.
Ready to Send Transactional Emails Using the GMass API?
As I said earlier, sending a transactional email with the GMass 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 GMass API to send transactional emails from your own applications, good news: Full API access is included in GMass’s Premium, Professional, and Team plans.
(You can find pricing info for those on the GMass pricing page.)
And with all those plans you can also send full email campaigns inside Gmail using the GMass Chrome extension.
With unlimited emails, campaigns, and contacts, see why 300,000+ people love GMass and have given us an average of 4.8 out of 5 stars across tens of thousands of reviews.
You can try GMass 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.
Email marketing. Cold email. Mail merge. Avoid the spam folder. Easy to learn and use. All inside Gmail.
TRY GMASS FOR FREE
Download Chrome extension - 30 second install!
No credit card required