API Security Best Practices
Authentication, object authorization, input validation, webhooks, abuse controls, and logging for production APIs.
Read guideArcjet Learning Center
Application-layer guidance for securing APIs, stopping automated abuse, and controlling resource consumption.
Web security protects application entry points, APIs, identities, data, and constrained resources from unauthorized access and abuse. Valid syntax is not proof of a safe request: an authenticated caller can target another tenant's object, a bot can automate a legitimate checkout flow, and a distributed client can exhaust an expensive operation without crossing a simple per-IP threshold. Effective protection combines strict authentication and object-level authorization with input validation, resource-aware limits, automation detection, observable decisions, and controls close to the application logic that understands the requested operation and its business impact. Controls should degrade predictably when shared security dependencies are slow or unavailable.
Begin with API security best practices for the complete control baseline. Read the API abuse guide to understand valid-looking malicious automation, then use the rate limiting guide to select algorithms, identifiers, and failure behavior for resource controls. Use the application and framework checklists for stack-specific controls, and the secrets guides when the risk is credential or PII leakage.
Authentication, object authorization, input validation, webhooks, abuse controls, and logging for production APIs.
Read guideIdentity-aware rate limits and bot detection on the routes that matter — not only a perimeter WAF.
Read guideDetect, classify, and apply policy to AI agents that hit logins, checkouts, scrapers, and APIs.
Read guideAPI abuse is the automated or malicious use of valid API functionality in ways that create fraud, cost, disruption, or data loss.
Read guideToken bucket, leaky bucket, sliding window, or fixed window?
Read guideRuntime application security enforces controls in the path of the action, using the application's own context.
Read guideWhat each layer sees, and why teams add bots, rate limits, and attack blocking in application code instead of only at the edge.
Read guideThe rule ships with the feature and runs in the request path.
Read guideDetect injection, abuse, exfiltration, and agent manipulation in the handler, then deny before the query, the charge, or the model.
Read guideTreat User-Agent as a claim, then verify with reverse DNS, public IP ranges, and application context.
Read guideBot detection is classifying automated HTTP clients and enforcing a policy: allow a verified crawler, constrain a script, or deny abuse.
Read guideCAPTCHA is no longer an effective primary control.
Read guideBot spoofing is a client claiming to be a known, usually trusted, automated agent while actually being someone else.
Read guideDetect bots where route, user, and business context reveal scraping, credential stuffing, and abuse.
Read guideProtect a React Hook Form by combining client and server validation, rate limiting, bot detection, and email verification.
Read guideSecure a Node.js/Express API by calling Arcjet protect() in middleware before the route runs.
GraphQL security is more than an HTTP rate limit: one request can batch, alias, or nest enough work to exhaust the process.
Read guideToken-bucket rate limits and bot detection on Yoga and Next.js, plus SHA-256 persisted operations.
Read guideServerless and edge apps expose many independently invocable functions, so a perimeter WAF is not enough.
Read guideAre Next.js server actions a security risk?
Read guideWere you affected by the Next.js middleware bypasses?
Read guideSQL injection is untrusted input that becomes SQL syntax.
Read guideDoes Next.js need a WAF? Yes, for scanners, known CVEs, and PCI DSS 4.0. Prefer an in-app Shield rule you can dry-run behind.
Read guideAuthentication names the user, Permit.io decides whether that identity may act on an object, and Arcjet stops attacks and abuse on the request.
Read guideTell a denial-of-service flood from a large customer by identity, not volume.
Read guideRate limiting controls how many actions an identity can perform in a period.
Read guideChange Arcjet rate limits at runtime without redeploying.
Read guideSeven-item App Router checklist: dependencies, validation, secrets, server-only code, headers, centralized checks, and CI scanning.
Read guideRemix v2 and React Router 7: module side effects, signed cookies, CSRF, headers, validation, and uploads.
Read guideA practical web app checklist: auth, input validation, secrets, headers, dependency risk, and in-app controls.
Read guidePlan for four threats: brute force, credential stuffing, SQL injection, and session theft.
Read guidePin node:22-bookworm for builds and node:22-bookworm-slim or gcr.io/distroless/nodejs22-debian13:nonroot for the runner.
Secure NestJS 10 and 11 with @arcjet/nest v1.
Read guideAdd structured JSON logging to Next.js 15 with Pino via the Instrumentation hook or next-logger v5.
Read guideInstall Tailscale first, deny inbound except tailscale0, then install Coolify on the tailnet.
Deploy Arcjet on Fly.io with v1 config, Fly-Client-IP detection, rate limiting, and bot protection.
Read guideSecure Node.js containers with a non-root USER, Node 22 on current Debian, Distroless or Wolfi bases, a read-only root, secret scanning, and.
Read guideNode.js trusts a frozen Mozilla CA snapshot, not OrbStack's local CA.
Read guideGet the real client IP on Firebase from x-fah-client-ip after FIREBASE_CONFIG platform detection.
Read guideNEXT_PUBLIC_ env vars are inlined into the browser bundle.
Read guideTest Next.js API routes for auth gaps, abuse paths, and Arcjet decisions without flaky end-to-end suites.
Read guideTest live Arcjet rules with Newman or k6 against the same binary you deploy.
Read guideForce two requests through the same check-then-act window so a one-time coupon or token is used twice.
Read guideA public package that shares an internal name installs instead — reserve your npm scope and pin it in .npmrc.
Read guideA trivial package is a short dependency you could write yourself. Prefer natives such as padStart over tiny npm helpers.
Read guideWhen someone else can publish a package you trust, or serve a replacement at a URL you pin — accounts, domains, Polyfill.io.
Read guideCredentials leave via repos, CI logs, container layers, or deleted forks — detect, rotate, and close the path.
Read guideProduction secrets in env vars are plaintext with no audit trail. Store an ID and fetch at runtime instead.
Read guideImplement slog.LogValuer on types that hold secrets so only allow-listed fields are logged.
Read guideProduction PII detection: placement, latency budgets, fail-open versus fail-closed, staged rollout, and review questions.
Read guide