Using API in email tools

Chapter 2 • Part 2

Setting up API connections in Zapier

Okay gringo. 

We quickly go through Zapier too in terms of API Webhooks. Even if you don’t use SureTriggers, I recommend reviewing that lesson, it is more detailed than this will be.

Zapier is expensive. It is also simple to use and – being the market leader – every tool connects with them first. 

So you likely won’t need API, only if the available native connections don’t cover your needs.

If you run your site on WP, I’d recommend SureTriggers instead. You may want to try your luck with Integromat/Make, less intuitive but cheaper than Zapier. Pubbly Connect I don’t like, found it unreliable and complicated with a lot of errors needing support.

But generally from these lessons you should be able to set up automations in those 2 as well. 

Smarts I expect you to have

I will not go through how the native, built in integrations Zapier works.

Connecting your apps, actions, triggers, etc. If you need help in that part, there are a plethora of Youtube walktroughs. 

We’ll only focus beyond that, setting shit up via API.

The Barbarian Or The Wizard

In most *walk-hack-collect-improve* fantasy games you can choose some kind of a Barbarian/Viking/Knighting with a sword, or a skinny wizard with a stick. (what are these called, hack-n-slash, or RPP? RRP? Something like that. Adventure games.)The wizard always sucks at the beginning. Weak as fuck, dying from tripping over his own foot. But then, by the end of the game, if you get there, he will have the first 30 pages of Biblical Punishments 101, blowing up your whole screen with flashy thunder-fire-blizzard-disco animations – while you are timidly taking your epilepsy pills in the corner of the couch.Barbarians on the other hand are fun and easy early on. They are dumb brutes, hacking through everything. Then..closing to the end, with every opponent jumping, and flying, while you are swinging some 2-man-sized blade around like some half-crazed butterfly collector…life gets hard.

Zapier offers you a similar choice. Using the half-naked webhooks step, or the more sophisticated yet fragile AI wizard. If you want to do a more complex, final boss move, the first will get pretty complex, on the other hand, the Wizard sucks altogether, until they improve it not to. We’ll start with the Barbarian. Oddly enough, that’s the most simple to get, based on the previous lessons we covered.

BodyBuild a naked Barbarian Webhook

Instead of choosing the Email tool as the action step, we’ll choose Webhooks by Zapier. You’re a monster.

Using Loops as our laboratory mouse, just as in the previous lesson, we head over to its excellently written API doc and copy the Endpoint URL. It is found on the right-hand side after the curl -x POST part.

We’ll use Post to Create a new sub, and Put to update an existing one, you can simply navigate by the tabs on the left. This is similar to most API docs.

In Zapier we can just use the forms instead of a JSON, adding the fields we want to transfer into the ‘Data’ form. Email is obvious and required, it will be mapped from the previous step, from whichever tool you want to connect it. Other fields, like First name, are optional.

Take a peak at the right-hand side of the API, below the URL. There are a couple of forms we won’t need to bother with, but we still need to authenticate. (secret handshake)

The little ‘h’ indicates that it should go to the header. So scrolling a bit down in Zapier, copy ‘Authenticate’ into the first form of the ‘header section’ then Bearer with your API key. And.That.Is.All.See. Barbarians are fun. Updating a contact is also a piece of cake. You will need to map the email, and just simply add the custom field with the value you want. Updating custom fields are more tricky in tools that use both tags and fields so we take a look at that example too.

Updating custom fields, using Zapiers API request

We’ll take a more complex example, now updating a custom field in Convertkit, using the API Request.For this, we’ll choose Convertkit as the app, instead of the barbaric Webhooks by Zapier option.

You have 2 choices, the Custom Actions AI Wizard and the API request.

On the top, the Wizard is asking their gpt-ran AI to set up the spell based on a prompt.

Take a deep sensual look at the (Beta) mark. It’s not a cautious note to look humble, it’s a manifesto. It sucks. I couldn’t have anything hexed by it that bothered to work, always had to tweak manually, sometimes with the combined effort of the Support team. It is also quite confusing for 1st time users, what it builts, how to adjust it, what goes where.

The second option at the bottom, is the manual API request builder. It’s our friendly Barbarian, maybe upgraded with armor. I recommend you to use this instead of the AI prompt, I tell you why in a sec.In Convertkit’s case, the API has more options – being a more capable tool – but the layout of the doc is similar to what we saw in Loops’ API doc. Open it now for reference.

I wanted to show this example to highlight a trap that’s easy for beginners to walk into if you were to use the Wizard.

In the doc, you see that there is a Custom Fields tab and a Subscribers tab.If you were to just give a prompt “update custom field” to the AI wizard, it would offer you the spell to update the label of an existing custom field. But that’s not what we want. That wizard just turned our dick into a frog. Bastard.

What we really wanted was to update a Subscriber’s custom field value. Starting in the API doc, rather than with a wish to a wizard, makes this apparent.

So. Using the API builder:The method will be PUT, as it’s an update, pick that, and copy the URL from the top right after the curl -x PUT part. 

https://api.convertkit.com/v3/subscribers/<subscriber_id>

Little side quest for our Knight – we have to add a middle step ‘Find subscriber’, in Zapier, to get the Subscriber ID. So find sub, using the email given in the trigger step.

Now using the Subscriber ID we found, paste the Endpoint URL adding the ID to the last part as indicated.

Unlike in the Webhooks builder, the Authentication is already taken care of, as you have to link the tool in the Account step to even get here. 

Nested trouble

Updating the custom field is a bit more tricky than it was in Loops. If you were to just add the field name and value, like in the image below, it won’t work, because Ck doesn’t know if this is a tag, a field or the name of your cat. You have to mark the key as a Custom field – and then tell it which field to update and to what value.

To do this, we’ll have to paste the code from the doc (right-hand side) into the Body part.

But if you just stick it there without looking, like an underpaid postal worker, it will reward you with an error message. You need to remove the backslashes ‘’ and paste it like this{“fields”: {“goal”: “Test”}}Also, unlike inside Convertkit, the field name shouldn’t be uppercase. GOAL >> goalReady? Cool because it still won’t work. You have to tell him that the formatting will be JSON. As the last step, fill the header form from the doc with this: -H ‘Content-Type: application/json’The final masterpiece should look like this:

And woalá, the custom field is updated. You are API Barbarian Level 20. 

In trouble? Ask the Oracle

While I recommend you to use the manual API builders in Zapier (Webhooks or within-the-app), not the AI Wizard Custom Actions, you have a secret card up in your sleeve if you ever get stuck.

Explain your problem to ChatGPT with the context, pasting the code you are using and in most cases it will give you the fix. It is much faster than trying to look up forum comments or Youtube videos.

For example if you paste the code mistakenly, it would tell you how to format it. 

This is where we end this lesson. Using these two methods – filing the forms, or adding the code snippet to the body – you will be able to manage pretty much any mailer via API through Zapier.