API / backend service
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
For agents
- An API serves programs, not people, so every endpoint is directly exposed. Typical class: M, L with many clients or sensitive data.
- Rule 1: every endpoint has an explicit auth rule and checks access to the specific object (BOLA/IDOR).
- Rule 2: validate input by schema, use one error format, and return 429 with Retry-After when limiting.
- Rule 3: keep an inventory and a machine-readable spec that match the real routes.
Which class?
- S: a read-only public API with no personal data.
- M: accounts, personal data, or keys for third-party services.
- L: many clients, payments, admin functions, sensitive data.
- XL: very high traffic across many regions.
Audit checklist
Every project
- Facts are verified from current official documentation
- What: Commands, libraries, APIs and platform policies in the project come from current official documents, not from memory.
- How to check: Open the dependency list and the platform configuration; for each non-trivial choice find the official page it relies on (link in a comment or a decision note).
- Evidence: Decision note or code comment with the official URL and the date it was checked.
- Packages come from official sources, stable versions only
- What: Packages and versions are chosen from official sources; the current stable release is used, not alpha or beta.
- How to check: Read the dependency file for pre-release tags (alpha, beta, rc, next); check each package on its official registry page.
- Evidence: Dependency file without pre-release versions.
- HTTPS everywhere
- What: The site or API is served only over HTTPS, and HTTP redirects to it.
- How to check: Request the
http://address and confirm a redirect; check for a Strict-Transport-Security header; check for mixed content. - Evidence: Response headers of the first request; browser console without mixed-content warnings.
- No secrets in code, chat, commits or logs
- What: Passwords, keys and tokens live in environment variables or a secret manager;
.envis ignored by git; the repository has only.env.example. - How to check: Check
.gitignorefor.env; run a secret scanner (for example gitleaks) over the full history; search for key-like strings. - Evidence:
.gitignoreline, scanner report with zero findings,.env.examplepath.
- What: Passwords, keys and tokens live in environment variables or a secret manager;
- Reports separate “written”, “tested” and “works end to end”
- What: Status reports say clearly whether something is written, passed its tests, or was run end to end; skipped or failed steps are stated.
- How to check: Read the last HANDOFF or release notes; look for features reported as done that have no test or run record.
- Evidence: HANDOFF lines or a test log for each feature marked done.
- Project memory files exist and are current
- What: The repository has CLAUDE.md or AGENTS.md (permanent rules) and HANDOFF.md (where we stopped), updated at the end of every work round.
- How to check: Look in the repository root for both files; compare the HANDOFF date with the latest commit date.
- Evidence: File paths and the date of the last HANDOFF update.
- Every endpoint has an explicit auth rule
- What: Each endpoint declares whether it is public or protected and which role may call it; the default is protected.
- How to check: List routes and their auth setting; look for routes without one.
- Evidence: Route table with auth column.
+ If it has users, personal data or API keys (M)
Items for class M: see API / backend service: class M checklist.
+ If it has an admin panel, file uploads, many users or a store app (L)
Items for class L: see API / backend service: classes L–XL checklist.
+ If it targets millions of users (XL)
Items for class XL: see API / backend service: classes L–XL checklist.
Common mistakes
- Checking who the caller is, but not whether the object belongs to them.
- An endpoint added in a hurry with no auth rule and no entry in the inventory.
- Accepting any JSON field, so a client can set
roleorisAdmin. - Different error formats per endpoint, or stack traces in responses.
- Retried POST requests that create duplicates.
- Offset pagination and unbounded list queries.
- Old API versions kept alive forever and unpatched.
- Timeouts missing on calls to other services.
Example projects
- Public weather data API: API, S.
- API for a mobile app with accounts: API, M or L.
- Payment webhook receiver: API, L.
- Internal microservice for pricing: API, M.
- GraphQL gateway for a web app: API, M.
- Partner API with API keys and quotas: API, L.
- Backend for a social app: API, XL.
- Telegram bot webhook endpoint: API, M (see bot).
- Image processing service: API, M, uploads need care.
- Search API over public data: API, S.
- Admin API for an operations team: API, L.
- Booking engine API: API, L.
Sources
- OWASP API Security Top 10 – 2023 — OWASP
- REST Security Cheat Sheet — OWASP Cheat Sheet Series
- Authorization Cheat Sheet — OWASP Cheat Sheet Series
- Insecure Direct Object Reference Prevention Cheat Sheet — OWASP Cheat Sheet Series
- Mass Assignment Cheat Sheet — OWASP Cheat Sheet Series
- Server Side Request Forgery Prevention Cheat Sheet — OWASP Cheat Sheet Series
- RFC 9457: Problem Details for HTTP APIs — IETF
- RFC 6585: Additional HTTP Status Codes — IETF
- Retry-After header — MDN Web Docs
- Idempotent (glossary) — MDN Web Docs
- The Idempotency-Key HTTP Header Field (Internet-Draft) — IETF
- REL05-BP03 Control and limit retry calls — AWS
- Well-Architected: make mutating operations idempotent — AWS
- PostgreSQL: EXPLAIN — PostgreSQL Global Development Group
- The Twelve-Factor App: III. Config — 12factor.net
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide