Home › API design › REST API design AGENTS.md

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: REST API design rules

## Resources and methods
- Plural nouns, kebab-case paths: `/v1/order-items/{id}`. Nest at most one level (`/users/{id}/orders`).
- `GET` read (safe), `POST` create or action, `PUT` full replace, `PATCH` partial update, `DELETE` remove. Actions that don't fit use a sub-resource (`POST /orders/{id}/cancel`).
- JSON fields in one casing across the API (match the existing API; default `camelCase`). Timestamps ISO 8601 in UTC; money as integer minor units + currency.

## Status codes
- `200` OK, `201` Created (with `Location`), `204` No Content, `400` malformed, `401` unauthenticated, `403` forbidden, `404` not found, `409` conflict, `422` validation failed, `429` rate limited (with `Retry-After`), `5xx` server faults only.

## Errors
- One shape everywhere, RFC 9457 Problem Details: `{ "type", "title", "status", "detail", "errors": [{ "field", "message" }] }`. Never return stack traces.

## Lists
- Paginate every list: cursor-based (`?limit=50&cursor=...` returning `nextCursor`). Cap `limit`.
- Filtering and sorting via query params (`?status=paid&sort=-createdAt`).

## Safety and evolution
- `POST` endpoints that create payments or orders accept an `Idempotency-Key` header.
- Additive changes only within a version: new optional fields are fine; removing/renaming fields or changing types needs a new version or deprecation period (`Deprecation`/`Sunset` headers).
- Update the OpenAPI spec (`openapi.yaml`) in the same change and keep it valid (`npx @redocly/cli lint`).

More: all API design rules · all AGENTS.md rules

Related rules

Blazor (.NET 10) AGENTS.md

AGENTS.md for Blazor Web Apps on .NET 10: render modes, components, forms and validation, state, and bUnit tests.

AGENTS.md.NET / ASP.NET Core

Celery background jobs AGENTS.md

AGENTS.md for Celery 5 task queues in Python/Django: idempotent tasks, retries, time limits, and safe enqueueing.

AGENTS.mdPython

Deno 2 AGENTS.md

AGENTS.md for Deno 2 projects: deno.json tasks, JSR and npm imports, permissions, and built-in tooling.

AGENTS.mdDeno

Express 5 API AGENTS.md

AGENTS.md for Express 5 REST APIs in TypeScript with zod validation, error middleware, and supertest.

AGENTS.mdNode.js / TypeScript

Flask 3 AGENTS.md

AGENTS.md for Flask 3 apps: app factory, blueprints, SQLAlchemy 2.0, and pytest with the test client.

AGENTS.mdFlask

Go stdlib HTTP service AGENTS.md

AGENTS.md for Go 1.27 services using only net/http, slog, and database/sql or pgx, with no web framework.

AGENTS.mdGo

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.