Session 4 / 15๐Ÿ”Žืขื‘

In one sentence

Students understand HTTP and REST, and build a real API with a webhook, security and JSON responses.

Preparation before the session

Time plan

  1. 00:00โ€“00:15 Review: the smart form
  2. 00:15โ€“00:45 APIs and HTTP: the way systems talk
  3. 00:45โ€“01:15 Custom webhooks and data structures
  4. 01:15โ€“01:30 โ˜• Break
  5. 01:30โ€“01:50 Webhook response and security
  6. 01:50โ€“02:15 The HTTP module: auth, query, body
  7. 02:15โ€“02:50 Building together: a lead-intake API
  8. 02:50โ€“03:00 Summary and practice

Lecture parts and activity type

PartActivity type
What is an API?Explanation
Webhook โ€” when the system calls youExplanation + demo
Webhook response โ€” returning an answerSimulation
Securing a webhookDemo
The HTTP module in depthDemo
Make an API call โ€” the middle wayExplanation
Building together: a lead-intake APIBuilding together

The 3 messages that must get across

  1. Push is better than pull when possible.
  2. Return the response early.
  3. Every production webhook is secured.

Questions for class discussion

  • Which systems in your organization can send webhooks?
  • What's the risk in an unsecured webhook?
  • Who in the organization needs to see API docs?

Live demo script

Talking to an API

  1. GET โ€” HTTP โ†’ Make a request, the users/1 URL, Parse response โ†’ Run once.
  2. Query โ€” URL: โ€ฆ/posts, Query parameters: userId = 1. In the bubble: Data is an array โ€” {{length(1.data)}}.
  3. POST โ€” Method POST, Body type Raw, Content type JSON, Request content: {"title":"Hello","body":"from Make","userId":1}.
  4. Status โ€” In the bubble: Status code 201.

A first webhook with a response

  1. Webhook โ€” Webhooks โ†’ Custom webhook โ†’ Add โ†’ hello โ†’ copy.
  2. Send โ€” Run once โ†’ Hoppscotch POST with a JSON body.
  3. Create JSON โ€” JSON โ†’ Create JSON โ†’ data structure: Generate from {"greeting":"x"} โ†’ greeting = Hello {{1.name}}!.
  4. Response โ€” Webhooks โ†’ Webhook response: status 200, body = the JSON string, Content-Type header.
  5. ON โ€” Scheduling Immediately โ†’ ON โ†’ send another request.

A secure leads API

  1. Webhook โ€” Custom webhook Leads API, Get request headers: Yes.
  2. Authentication โ€” Router: a route with a filter on the header = course-2026-secret; fallback โ†’ Response 401 {"ok":false,"error":"unauthorized"}.
  3. Validation โ€” An inner Router: email Matches pattern; fallback โ†’ Response 400 {"ok":false,"error":"invalid email"}.
  4. Enrichment โ€” Set multiple variables: clean name/email/phone, domain, score, leadId.
  5. Response โ€” Create JSON โ†’ Webhook response 201.
  6. Tests โ€” Hoppscotch: no key (401), a wrong email (400), valid (201).

Problems students will run into

ProblemQuick fix
400 on the POSTContent type isn't JSON, or the JSON is invalid.
Special characters appear as \u05e9That's fine โ€” it's encoded JSON. Parse response returns normal text.
I got AcceptedThe scenario isn't ON and isn't in Run once, or Webhook response isn't in the chain.
Garbled charactersAdd charset=utf-8 to Content-Type.
Always 401Get request headers is off, or the header name is in capital letters in the comparison.
Both the fallback and a normal route ranThe fallback wasn't ticked โ€” it's set up as a route with an empty filter.
429The free API has a daily quota. Switch to Webhook.site for testing.
gender nullThe name isn't known โ€” that's fine, handle it with ifempty.

Tips from the classroom

  • Demonstrate the difference between Accepted and a tailored response โ€” it's an "aha" moment.
  • Hoppscotch in the browser saves installations.
  • Spend time reading an API's error response.

Adapting to different levels

For students who struggle: Webhook + response only, without security.

For fast students: The batch and HMAC challenges.

Answer key โ€” multiple-choice questions

Students see the answers in shuffled order, so the key gives the wording of the right answer.

#Right answer
1Webhook = the system sends to us when there is an event; polling = we ask every X minutes
2Get request headers: Yes in the webhook
3Too many requests โ€” slow down
4It prevents broken JSON when there are quotes/lines/special characters
5Call any endpoint with an existing connection's auth
6As early as possible, before slow actions
74xx/5xx won't stop the scenario
8Webhooks โ†’ the queue

Homework

  1. The API should return 3 correct responses.
  2. Preparing for session 5: make sure you have access to Google Sheets, Gmail, Drive and Calendar in the course account.