Posted in

How to authenticate API requests?

Hey there, fellow devs! If you’re running an API business like we are, you know authentication isn’t just a “nice-to-have”—it’s the foundation of keeping your service safe, trustworthy, and actually usable. Last quarter, we had a close call: a client’s test environment got hit by a random script trying to spoof requests, and it taught us a hard lesson. Skipping or botching API auth doesn’t just leave your data wide open—it can tank your client’s trust, cost them money, and even get you flagged as unsecure. API

In this post, I’m gonna break down the real, practical stuff we’ve tested (and lived) to make sure your API requests only come from the right people, no fluff, no jargon that makes you zone out. Let’s dive in.

First, let’s cut through the confusion: what even is API authentication, and why should you care as a provider? If you’re an API supplier, every request hitting your server needs a way to prove it’s not a random stranger pretending to be your client. Without this, anyone can send a request to your /payment endpoint, drain test funds, or scrape sensitive data. For us, it’s non-negotiable because our clients (think fintech startups and e-commerce brands) handle user info—they can’t risk a breach, and neither can we. We don’t just lock our API; we make it easy for our clients to set up without needing a CS degree.

Now, the actual methods you’ll actually use (no “theoretical best practice” that no one implements):

  1. API Keys – The low-effort workhorse, but don’t mess this up
    API keys are the first thing most devs reach for, and for good reason: they’re simple. You generate a unique string for each client, they stick it in a header (like Authorization: ApiKey abc123xyz), and your server checks if that key’s valid before processing the request. We’ve used this for our smaller clients who don’t want to deal with more complex setups, and it works—if you do it right.
    But here’s the mistake most people make: hardcoding API keys in public repos, frontend code, or even commit logs. We’ve had a client reach out panicking because their dev accidentally pasted their test key in a public GitHub repo, and some bad actors scraped it to spam our test endpoints. That’s avoidable. Our rule for clients is: store keys in environment variables, not client-side code, and rotate them every 90 days (we send automated reminders for this, no nagging required). Also, never use the same key for both test and live environments—we create separate keys for each, so if one leaks, the other stays safe.

  2. OAuth 2.0 – For clients that need granular control (and deeper security)
    OAuth 2.0 is the go-to when clients need more than just a static key—like limiting what the API can access (e.g., a shipping app only gets order data, not payment info) or letting end-users grant access without sharing their credentials. A lot of devs think OAuth is too complicated, but we’ve simplified it for our enterprise clients by providing pre-built integrations with tools like Auth0 and Okta.
    Let’s make this real: when a client uses OAuth, they send a temporary access token instead of a permanent key. Tokens expire after 15-60 minutes, which means if one gets leaked, it’s useless within an hour—way better than a key that works until you rotate it. We also give our clients refresh tokens to get new access tokens without re-logging in, and we track every token use so if something goes off, we can revoke it in seconds. For example, a big retail client had a suspicious token use—we flagged it, they revoked it, and no data was lost. Win-win.

  3. Webhooks Signing – For when clients receive events from your API
    Wait, webhooks? That’s a big one most people forget. When you send a webhook to a client (like “a user just placed an order”), you need to prove that webhook actually came from you, not a spoofed request. Our clients constantly ask us, “How do I know that order alert isn’t from some guy on the internet?” The fix is easy: we sign every webhook payload with a secret key, send a signature header, and our clients verify it on their end before processing.
    Pro tip: Make sure the client uses the exact same secret we gave them when calculating the signature. We once had a client complain that our webhooks were being rejected, and it turned out they changed the secret in their dashboard but forgot to update the code. We added a test endpoint so clients can check their signature setup in 2 clicks, which cuts down support tickets a ton.

  4. Mutual TLS (mTLS) – For the super-sensitive stuff (enterprise only)
    If you’re handling top-secret data (like healthcare patient info or bank transactions), mTLS is the extra layer you need. With mTLS, both the client and your API prove their identity with digital certificates, not just keys or tokens. It’s stricter, which means fewer things to mess up, but it’s a bit more setup. We only offer this for our enterprise clients because it’s overkill for small teams, but for the ones that need it, it’s a lifesaver. We provide a simple guide to install certificates, so even teams without a security expert can get it running.

Now, the stuff that’s not a method, but will make or break your API auth:

  • Rate limits + Key scoping: Even if you have a perfect key, a bad actor can spam your API with it. We limit each key to 1000 requests per minute, and let clients scope keys (e.g., “test key only for /checkout endpoints, live key for everything”) so if a key is leaked, the damage is minimal.
  • Revocation: Accidents happen—someone quits a team, a key gets exposed, a client cancels their plan. Make sure you can revoke a key instantly. Our dashboard has a 1-click revoke button, and we send an email alert every time a key is revoked, so clients don’t get blindsided.
  • Monitoring: We log every auth attempt, so we can spot weird patterns (like a key from a country the client has never used, or 1000 requests in 10 seconds) and flag it. Last month, we stopped a brute force attack on a client’s test key by flagging the odd location—no downtime, no data loss.

Let’s talk about what not to do: Skip “security through obscurity”—hiding your endpoint won’t stop someone from guessing it. Don’t use basic auth (username + password in the URL, ugh)—it’s super easy to log or leak. We’ve seen clients try this, and it’s exactly how their data got scraped. And don’t overcomplicate it—if a client can’t set up your auth in 5 minutes, they’ll go to a competitor who makes it simple.

At the end of the day, API auth is about trust. Your clients are relying on you to keep their data safe, and the right method doesn’t have to be a headache. If you’re looking to upgrade your API’s security, or just want to chat through what would work for your use case, hit up our team to talk procurement. We’re here to make this easy, not scary.

Flavoring & Fragrances References:
OWASP API Security Top 10, NIST SP 800-63-3, OAuth 2.0 Authorization Framework RFC 6749, Mutual TLS Best Practices


Shaanxi Hibo Biotechnology Co., Ltd.
As one of the most professional api manufacturers and suppliers in China, we’re featured by quality products and good service. Please rest assured to wholesale discount api in stock here from our factory. We also accept customized orders.
Address: Room 804, Unit 2, Building 4, i Metropolis, No.11 Tangyan South Road, Gaoxin District, Xi’an City, Shaanxi Province
E-mail: hibo02@xaltbio.com
WebSite: https://www.hibobio.com/