APIs for Infrastructure Teams
DNS, cloud, webhooks, and automation patterns.
Learning objectives
- Name infrastructure tasks automatable via API
- Understand webhooks (server-to-server callbacks)
- Sketch a safe automation flow for Workshop Co.
Panels are APIs with buttons
When Marcus clicks “Add A record” in a DNS panel, the browser sends an API request. Scripts skip the UI and call the same endpoint — useful for:
- DNS updates during failover (Book 3 + 7)
- Provisioning VPS instances
- SSL certificate orders and renewals
- Creating monitoring alerts
- Posting to Rocket.Chat or Slack when a server is down
Webhooks — reverse APIs
A webhook is when a service POSTs to your URL when something happens:
Stripe → POST https://workshopco.ca/webhooks/stripe
Body: { "type": "checkout.session.completed", ... }
Your server verifies the signature, updates the database, sends confirmation email. Same pattern for contact forms posting to Rocket.Chat (Workshop Co. could mirror this).
Worked example — DNS failover script (conceptual)
# Pseudocode — not provider-specific
if health_check_fails("203.0.113.10"):
dns_api.update_record(
zone="workshopco.ca",
name="www",
type="A",
value="198.51.100.5" # Montreal DR
)
notify("Marcus", "Failover: DNS pointed to DR")
Good automation checks state before changing it. Running the failover script twice should not flip-flop records.
Design an automation
When Workshop Co. receives a contact form submission, Marcus wants:
- Message in team chat
- Row appended to a Google Sheet
- Optional: LLM summary of the visitor's question (preview of Book 8 capstone)
Draw the webhook/API flow: form → your server → which APIs?
Sample flow
- Browser POST →
/contact-submiton Workshop Co. server - Server POST → Rocket.Chat incoming webhook (chat)
- Server POST → Google Sheets API (append row)
- Server POST → LLM API with redacted PII (summary only if no email in prompt)
Check
Webhook vs polling — why is webhook preferred for “payment completed”?
Answer
Instant and efficient — Stripe pushes when ready. Polling would hammer the API every N seconds and delay confirmation.