We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Security Architecture
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Security Architecture
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
When Stripe wants to verify that an API request is coming from your application, it uses an API key. When you call the OpenAI API, you include an API key. When Twilio sends an SMS on your behalf, it authenticates your account with an API key.
API keys are long, random strings assigned to a developer account or an application. Include the key in the request header, and the server looks it up to identify the caller, check permissions, and enforce rate limits.
Here is the important distinction: API keys identify applications, not people. A single Stripe API key might be used by a backend service processing charges for millions of customers. The key tells Stripe "this request comes from Merchant Account #1234," not "this request comes from Alice the customer." When you need to know which human is making the request, you use OAuth or . When you need to know which application is making the request, you use API keys.
Every major API-first company uses API keys: Stripe (sk_live_), Twilio (AC + auth token), SendGrid, Mailgun, OpenAI, Anthropic, AWS (access key ID + secret), Google Cloud (API key for public APIs, service account for private ones).
Key format matters. Well-designed API keys communicate information through their prefix:
| Prefix | Meaning | Example |
|---|---|---|
sk_live_ | Secret key, production | Stripe live mode |
sk_test_ | Secret key, test environment | Stripe test mode |
pk_live_ | Publishable key (safe for frontend) | Stripe client-side |
OPENAI_API_KEY | Single key, no prefix convention | OpenAI |
AC + AUTH_TOKEN | Account SID + auth token pair | Twilio |
The sk_ vs pk_ distinction is important. A publishable key can appear in client-side JavaScript because it can only perform limited, non-destructive operations (like creating a Stripe checkout session). A secret key can create charges, issue refunds, and access sensitive data. It must never appear in frontend code, mobile apps, or version control.
How to send the key:
| Method | Example | Security |
|---|---|---|
| Header (recommended) | X-API-Key: sk_live_abc123... | Not logged in URLs, not cached by browsers |
| Bearer token header | Authorization: Bearer sk_live_abc123... | Standard Authorization header pattern |
| Query parameter | ?api_key=sk_live_abc123... | Bad. Logged in server access logs, browser history, referrer headers |
Server-side storage: Store API keys as SHA-256 hashes. If the database is compromised, the attacker gets hashes, not usable keys. This works because API keys have high entropy (256-bit random), so brute-forcing the hash is computationally infeasible. This is different from passwords, which have low entropy and need bcrypt/Argon2 for slow hashing.
It is easy and good
“It is really nice and good Please join the course”