A LinkedIn post listed "20 concepts to master APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON. design": endpoint, HTTP methods, status codes, authentication, rate limiting, pagination, webhooksHTTP call a system makes to your address when something happens, like an approved payment, notifying you right away instead of you polling for changes., OpenAPI and so on. The list is good, but each item fit on one line, and the questions show up right on the line below. Are rate limiting and throttling the same thing? PUT is idempotent and POST isn't, but why? Where do I store the idempotency key?
This is the guide I wish I had read when I started designing APIs: 36 concepts in seven groups, each with what it is, when it matters and where it usually goes wrong. The examples come from this site's API and from the CRM I built for my business, with what worked and what I would do differently today.

Foundations: What Travels in a Call
1. API. A set of rules that lets one program use another without knowing its code. On the web, it almost always means an HTTP API: the client sends a request to an address and gets a response. The value of an API is in what it hides. The consumer doesn't know whether there's Postgres, a spreadsheet or three microservices on the other side, and doesn't need to.
2. Endpoint and resource. The endpoint is the address that gives access to something: GET /api/v1/blog/posts/conceitos-de-api. The resource is that "something", with a plural name and the identifier in the path. A resource name is a noun (/orders/42), and the verb goes in the HTTP method. POST /createOrder works, but it throws away everything HTTP already knows about methods.
3. HTTP methods. GET reads, POST creates or triggers an action, PUT replaces, PATCH changes part of it, DELETE removes. RFC 9110, from 2022, defines two properties that matter much more than they seem:
| Method | Safe (changes nothing) | Idempotent (repeating has the same effect) |
|---|---|---|
| GET, HEAD, OPTIONS | yes | yes |
| PUT, DELETE | no | yes |
| POST | no | no |
| PATCH (RFC 5789) | no | no |
Idempotent doesn't mean "same response". A repeated DELETE may return 404 the second time, but the effect on the server is the same: the resource doesn't exist. This table decides what can be retried automatically after a network failure, which is why it comes back in the traffic group.
4. Request and response. Every call has a method, a URL, headers and sometimes a body. The response has a status, headers and a body. Headers carry what isn't business data: format (Content-Type), authentication (Authorization), caching (Cache-Control), tracing. When an integration breaks, the answer is almost always in a header nobody looked at.
5. Status codes. Three digits that say how the call ended, grouped by the hundreds: 2xx it worked, 3xx go somewhere else, 4xx the caller made the mistake, 5xx the server did. The ones I see misused most: returning 200 with {"error": ...} in the body (the client thinks it worked), 401 instead of 403 (they're different things, see the identity group) and 500 for invalid input, which should be 400 or 422. For a quick lookup, I keep HTTP Statuses in the tools catalog.
6. Representation and Content-Type. The resource is the idea; the representation is the format it travels in, almost always JSON. The Content-Type: application/json header says what's in the body, and Accept says what the client wants back. It looks like red tape until you integrate with a system that sends XML labeled with a JSON Content-Type.
7. REST and statelessness. REST is a style, not a protocol. The part that matters most day to day is having no state between calls: each request carries everything the server needs to handle it, including the credential. That's what lets you put ten copies of the API behind a load balancer without the user losing the session when they land on another machine.
Identity: Who You Are and What You Can Do

8. Authentication. Proving who is calling. The failure response is 401 Unauthorized, which, despite the name, means "I don't know who you are". The types of authentication, from cookie sessions to passkeys, are compared in types of authentication.
9. Authorization. Deciding what someone already identified is allowed to do. The failure is 403 Forbidden: "I know who you are, and you can't". The classic API mistake is checking authentication and forgetting per-object authorization: user 7 is logged in, asks for /orders/8 and gets someone else's order. The rule I follow: authorization is checked on every database query, never only at the route entrance.
10. API key. A fixed key that identifies the calling system, not a person. It's meant for server-to-server integration. Never in front-end code, because everything that goes to the browser is public.
11. Access token. A temporary credential that proves permission, sent in the Authorization: Bearer ... header (format from RFC 6750). Temporary is the key word: if it leaks, it expires. A long-lived token is a password by another name.
12. JWT. A token format (RFC 7519, from 2015) that carries signed data: who it is, how long it's valid, what it can do. The upside is that the server validates the signature without querying the database. The downside is the same thing: an issued JWT can't be revoked before it expires unless you go back to checking something. To see what's inside one, jwt.io decodes it in the browser. The payload is only encoded, not encrypted: don't put secrets in it.
13. Scopes. What a token can do, written in the token itself: companies:read, deals:write. In my CRM, every API token has scopes, and the MCPOpen protocol that standardizes how AI apps connect to external tools and data: a server exposes actions and the agent discovers and calls them. server lists for the agent only the tools that scope allows. Without the scope, the tool doesn't even show up. That's the principle of least privilege in practice.
14. OAuth 2.0. A standard (RFC 6749, from 2012) that lets an app act on behalf of a person without getting their password. "Sign in with Google" and "allow this app to read your calendar" are OAuth. The recommended flow today is authorization code with PKCE (RFC 7636): the app generates a one-time secret, sends only its hash at the start and proves it has the original at the end. That way, a code intercepted along the way is useless.
15. OAuth 2.1. OAuth 2.0 consolidated with ten years of best practices. It's still an IETF draft (version 17, from October 2026), but it's already what new servers follow: PKCE required for every client, no more implicit and password flows, and exact redirect URI matching. If you're starting an integration now, follow 2.1.
16. CORS. The browser mechanism, defined in the WHATWG Fetch specification, that decides whether a page from one domain can read the response of an API on another domain. Two common mix-ups. CORS doesn't protect the API: curl and servers ignore CORS. And Access-Control-Allow-Origin: * with cookies doesn't work, by rule of the specification. This site avoids the problem by serving the API on the same domain, under /api.
Traffic: Protecting the API from Heavy Users
17. API gateway. A single door in front of the services, handling what they all share: TLS, authentication, rate limiting, routing, logging. It helps when you have several services. With a single API, a well-written middleware does the same without one more piece to operate.
18. Rate limiting. Limiting how many requests a client makes in a time window. Over the limit, the response is 429 Too Many Requests (RFC 6585), which can include Retry-After saying how long to wait. In this site's API, login, contact and the article correction form have their own limits, much tighter than the general one. The reason is simple: those are the routes someone would try to abuse.
19. Throttling. Many people use it as a synonym for rate limiting, and in practice the two words blur. The useful distinction: limiting rejects the excess; throttling slows it down, by queuing the excess or delaying the response. For the client, the first is a 429; the second is a slower response.
20. Quotas. A limit over a long period (per day or per month), usually tied to the plan. Rate limits protect the server from bursts. Quotas protect the business model.
21. Rate limit headers. A polite client wants to know how much is left before getting a 429. The IETF has a draft in progress (version 12, from November 2026) that standardizes the RateLimit and RateLimit-Policy headers. It's not an RFC yet, but libraries already use it: this site's express-rate-limit sends the headers in the standard format with one option turned on.
22. Timeout, retry and backoff. Every remote call needs a maximum time, and retries after a failure need to wait longer each time, with a bit of randomness, so you don't attack your own service. This matters so much that it got its own article: resilience patterns.
23. Idempotency and Idempotency-Key. What do you do with a payment POST that timed out? Retrying might charge twice; not retrying might lose the sale. The fix is for the client to send a unique key per operation in the Idempotency-Key header. The server stores the first response tied to the key and, if the same key comes back, returns that response without running it again. Stripe documents the model: a random key with enough entropy (a UUID v4 works), up to 255 characters, stored for at least 24 hours, and an error if the same key comes with different parameters. The IETF is standardizing the header in a draft (version 9, from November 2026).
In my CRM I learned this on the email side. The sequences routine has no automatic retry, with a comment in the code explaining why: resending blindly would send the customer a duplicate email. The protection is a reservation written before sending, which plays the role of the key.
Data: Delivering a Lot Without Blocking Anyone
24. Pagination. Returning the list in parts. There are two main ways:
Offset (?page=3&limit=20) |
Cursor (?cursor=abc&limit=20) |
|
|---|---|---|
| Jump to page 40 | easy | not possible |
| List changes while paging | repeats or skips items | stable |
| Database cost on high pages | grows (OFFSET walks through what it skips) |
constant, with an index |
| Good for | dashboard with page numbers | feed, sync, public API |
Slack's documentation calls page-number pagination "archaic" and recommends a cursor with a limit between 100 and 200. A confession: this site's tools list returns everything at once, capped at 500 items. It works with today's 222, and it's already noted that it needs pagination before it passes 300.
25. Filtering, sorting and search. Predictable, documented query parameters (?status=active&sort=-created_at). The catch is to allow sorting only by indexed fields. A free-form sort is an easy way for someone to take down the database by accident.
26. HTTP caching. Storing responses so you don't fetch them again, defined in RFC 9111. Cache-Control says for how long and who can store it. This site's categories route responds with public, max-age=60, stale-while-revalidate=600: fresh for one minute and, for ten more, it can be served while the new one is fetched in the background. Images uploaded through the CMS go out with max-age=31536000, immutable, because the file name changes when the image changes. Caching and CDNsNetwork of servers spread around the world that keeps copies of files and pages close to users, serving them faster and offloading the origin server. are covered in more detail in caching, CDN and images.
27. ETag and conditional requests. The ETag is a fingerprint of the resource version. With If-None-Match, the client asks "has it changed since this version?" and gets 304 Not Modified with no body when it hasn't. With If-Match on an update, it says "only save if it's still on this version", and the server responds 412 Precondition Failed if someone changed it first. RFC 9110 describes exactly this use: avoiding the "lost update", when two people edit the same record and the last one wipes out the first one's work.
28. Long-running operations and 202 Accepted. Generating a five-minute report doesn't fit in one request. The server responds 202 Accepted, which RFC 9110 calls "intentionally noncommittal", and points to a status resource the client checks later. In practice, the most common approach is to return that resource's address in the Location header or in the body.
Living Contract: Changing Without Breaking Your Consumers

29. Versioning. Shipping changes without breaking whoever already integrates. The most common way is the version in the path (/api/v1/...), which is what this site uses: easy to spot in the logs and to route. Alternatives are a header (Api-Version) or a date, as Stripe does. More important than the format is the rule: adding a field doesn't break anything; removing, renaming or changing a type does, and requires a new version.
30. Deprecation and Sunset. Warning before shutting down. Since 2025 there's a standard header, Deprecation (RFC 9745), that says since when something has been deprecated, and Sunset (RFC 8594, from 2019) says when it will stop responding. RFC 9745 settles the order: Sunset can't come before Deprecation. A well-built client logs a warning when it sees these headers.
31. Error handling and Problem Details. A good error is predictable and explains what to do. RFC 9457, from 2023, replaced RFC 7807 and defines a standard format, application/problem+json, with the fields type, title, status, detail and instance:
{
"type": "https://exemplo.com/erros/saldo-insuficiente",
"title": "Insufficient balance",
"status": 422,
"detail": "The balance is $30.00 and the purchase is $50.00.",
"instance": "/compras/7781"
}This site's API returns its own format, { "error": "CODE", "message": "..." }, which was born before I knew about RFC 9457. It works because it's consistent across every route. If I were starting today, I'd use Problem Details: generic clients and tools already understand it without reading the docs.
32. OpenAPI. A standard format for describing a REST API: routes, parameters, bodies, responses and errors. The latest version is 3.2.1, from September 2026. Browsable docs, SDKs and mocks all come out of the same file. This API's documentation lives at /api/docs, generated from the contract. To write and validate a file, Swagger Editor runs in the browser, and Mockoon spins up a fake server from it.
Styles: REST, GraphQL, gRPC, Webhooks and Real Time
33. REST, GraphQL and gRPC. Three ways to design the conversation:
| REST | GraphQL | gRPC | |
|---|---|---|---|
| Format | resources at URLs, JSON | one route, the client picks the fields | contract in Protocol Buffers |
| Transport | HTTP | HTTP | HTTP/2 |
| HTTP caching | native | takes work | doesn't apply |
| Shines at | public API, CRUD, integration | screens that combine lots of different data | service to service, low latency |
The GraphQL specification got its September 2026 edition. gRPC uses Protocol Buffers by default and follows HTTP semantics over HTTP/2. When the pain is a screen that needs six calls, before switching the whole style it's worth looking at Backend for Frontend, which solves the same problem while keeping REST. To practice queries, GraphQL Learn is the official tutorial.
34. Webhooks. Instead of the client asking every minute "anything new?", the server sends a notice when something happens, with a POST to an address the client registered. Three rules that GitHub and Stripe document:
- Check the signature. GitHub signs with HMAC SHA-256 in the
X-Hub-Signature-256header. Stripe usesStripe-Signature, with a timestamp. Both call for constant-time comparison: GitHub writes "Never use a plain == operator". - Respond fast. Stripe asks for a 2xx before any heavy logic. Store the event and process it in a queue.
- Expect duplicates. The same event can arrive twice. Store the id and ignore the repeat, which is idempotency again.
This site's draft preview link uses the same signature idea: the token holds the id and the expiry, signed with HMAC, and the check uses timingSafeEqual. To watch a webhook arrive without writing a server, Webhook.site gives you an address on the spot.
35. Real time: SSE and WebSocket. When the server needs to push data continuously. Server-Sent Events (WHATWG HTML specification) go only from server to client, over plain HTTP, with automatic reconnection: great for task progress and AI responses appearing bit by bit. WebSocket (RFC 6455, from 2011) goes both ways, for chat and collaboration. If the conversation is one-way, start with SSE.
Operations: Microservices, Observability and Testing
36. Microservices, observability and tested contracts. Microservices are small, independent services that talk through APIs. They help teams that need to ship without waiting for each other, and they charge you in networking, latency and debugging. With them, three habits stop being optional:
- Correlation id: an id generated at the entrance and passed along in every header and every log, so you can follow a request across five services.
- Health check: a route that says whether the service is up, used by the load balancer and by the deploy. This API's health check is the first thing the pipeline calls after publishing.
- Contract testing: tests that check the real response against what was documented. That's what catches the change that breaks the client before the client does. How to build the testing pyramid on the server is in back-end testing.
To call and debug by hand, I use Bruno and Hoppscotch, and for load testing, k6. And if whoever calls your API is an AI agentProgram that uses a language model to choose actions, call tools and repeat the loop until a task is done, with little human input., the next question is whether it also needs an MCP server. That comparison is in MCP or API.
Quick check
Frequently Asked Questions
What is an API, in simple terms?
It's a contract that lets one program use another without knowing its code. You make a request in the agreed format, to an agreed address, and get a response in the agreed format, including when something fails.
What's the difference between authentication and authorization?
Authentication finds out who is calling; authorization decides what that person or system can do. A failure in the first is 401, and in the second, 403.
Are rate limiting and throttling the same thing?
They're used as synonyms, but there's a useful difference. Rate limiting rejects the excess with a 429; throttling slows it down, queuing the excess or delaying the response.
PUT or PATCH: which one should I use?
PUT when the client sends the whole resource to replace the current one; PATCH when it sends only what changed. PUT is idempotent per RFC 9110; PATCH isn't, by definition.
REST or GraphQL?
REST for public APIs, system-to-system integration and when HTTP caching matters. GraphQL when several screens need to combine different data and the cost of many calls hurts. A Backend for Frontend solves part of that problem without switching styles.
How do I version an API?
The simplest way is the version in the path, like /v1. Adding fields doesn't require a new version; removing, renaming or changing a type does. Before shutting down the old version, warn with the Deprecation and Sunset headers.
What is idempotency in an API?
It's being able to repeat the same call without changing the result beyond the first time. GET, PUT and DELETE are idempotent by definition; for POST, the client sends an Idempotency-Key and the server returns the stored response on repeats.
References
- IETF, RFC 9110, HTTP Semantics, 2022; RFC 9111, HTTP Caching, 2022; RFC 5789, PATCH, 2010; RFC 6585, 429 Too Many Requests, 2012.
- IETF, RFC 9457, Problem Details for HTTP APIs, 2023; RFC 9745, Deprecation header, 2025; RFC 8594, Sunset header, 2019.
- IETF, RFC 6749, OAuth 2.0, 2012; RFC 7636, PKCE, 2015; RFC 6750, Bearer token, 2012; RFC 7519, JWT, 2015; OAuth 2.1, draft 17, 2026.
- IETF, drafts Idempotency-Key and RateLimit headers, 2026.
- WHATWG, Fetch Standard, CORS protocol and HTML, Server-sent events, accessed in 2026; IETF, RFC 6455, WebSocket, 2011.
- Stripe, Idempotent requests and Webhooks, accessed in 2026; GitHub, Validating webhook deliveries, 2026; Slack, Pagination, 2026.
- OpenAPI Initiative, OpenAPI Specification 3.2.1, 2026; GraphQL Specification, September 2026 edition; gRPC, introduction, 2026.
- Style guides: Microsoft REST API Guidelines and Google AIP, accessed in 2026.
- Books: Arnaud Lauret, The Design of Web APIs, 2nd edition, Manning, 2025, the best starting point for design centered on the consumer; JJ Geewax, API Design Patterns, Manning, 2021, for pagination, long-running operations and versioning patterns in detail.